rmcgibbo / openmm-cmd

OpenMM Command Line Application
7 stars 3 forks source link

Python 2.6 compatibility #20

Closed cbenzer closed 10 years ago

cbenzer commented 10 years ago

We are running all our scientific Linux boxes under CentOS 6 which means the default Python installation is 2.6. I ran into the following compatibility issues:

Issue 1 : ordereddict not available in Python 2.6. This could be resolved by installing the backport of ordereddict into Python 2.6 using "pip install ordereddict". Pip (python-pip) is available in EPEL repository. After that I had to change the line "from collections import OrderedDict" to "from ordereddict import OrderedDict" in the file openmm.

Issue 2: argparse not available in Python 2.6. This could be resolved by installing argparse into Python 2.6 using "pip install argparse".

After resolving issues 1 and 2 I was able to run "open-mm -h". Subsequently I tried running a simple test using the input.pdb file from the OpenMM 5.2 example folder.

Issue 3: Several warnings on TypeErrror:

Traceback (most recent call last):
  File "/usr/lib64/python2.6/logging/__init__.py", line 776, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.6/logging/__init__.py", line 654, in format
    return fmt.format(record)
  File "/usr/lib/python2.6/site-packages/openmm-0.1-py2.6.egg/ipcfg/openmmapplication.py", line 88, in format
    return super(LevelFormatter, self).format(record)
TypeError: super() argument 1 must be type, not classobj

This is probably related to this issue http://stackoverflow.com/questions/1713038/super-fails-with-error-typeerror-argument-1-must-be-type-not-classobj and is somehow masked by being default in Python 3.X but the need to be declared explicitly in version below 3.0

Issue 4: Not researched so far ... :-)

Traceback (most recent call last):
  File "/usr/bin/openmm", line 5, in <module>
    pkg_resources.run_script('openmm==0.1', 'openmm')
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 461, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1194, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/lib/python2.6/site-packages/openmm-0.1-py2.6.egg/EGG-INFO/scripts/openmm", line 1077, in <module>
    openmm.start()
  File "/usr/lib/python2.6/site-packages/openmm-0.1-py2.6.egg/EGG-INFO/scripts/openmm", line 926, in start
    force_reporters(simulation)
  File "/usr/lib/python2.6/site-packages/openmm-0.1-py2.6.egg/EGG-INFO/scripts/openmm", line 1071, in force_reporters
    reporter.report(simulation, state)
  File "/usr/lib/python2.6/site-packages/openmm-0.1-py2.6.egg/ipcfg/restartreporter.py", line 190, in report
    with bz2.BZ2File(tmp_fn, 'w') as f:
AttributeError: 'bz2.BZ2File' object has no attribute '__exit__'

I would be grateful if you could work on the Python 2.6 compatibility and make life a little bit easier for all the RHEL and CentOS users.

Thanks a lot!

rmcgibbo commented 10 years ago

The argparse backport will probably be required, but I can fix the other problems. Thanks for the heads up!

cbenzer commented 10 years ago

Great. Looking forward to give the tool a test run, especially the restarting options as I need to break my simulations into smaller chunks.

rmcgibbo commented 10 years ago

I merged fixes for the issues you identified. With my python2.6.8 installation, everything is humming smoothly. Let me know if you have any issues.

cbenzer commented 10 years ago

Installed the updated code and first test run succeeded out of the box.