Issue #43 resolved

ImportError, functools total_ordering py v2.6.6

cometsong
created an issue

Good morning!

We have recently installed the bx-python libraries. Running the maf_to_fasta script, we get an ImportError as it tried to use 'lrucache.py' and import total_ordering from functools.

Unfortunately, the latest stable version of python for the latest stable release of debian (squeeze 6) is only 2.6.6, which does not include the total_ordering function in functools.

Looking into this, I discovered a workaround version-check hacked into the django code for the same situation... https://github.com/django/django/blob/5cbfb48b92cb26a335f9c8c0f79d3390290103e2/django/utils/functional.py And a related python bug report: http://bugs.python.org/issue10042

Is it possible to modify the bx code to match the django-style version check? Or should I just [wait for next debian|make-install py2.7 and check for library breaks|etc]? :)

The traceback error we receive is below. Thanks! Benjamin

=> python maf_to_fasta.py < foo.maf > bar.fasta Traceback (most recent call last): File "maf_to_fasta.py", line 13, in <module> from bx.align import maf File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx/align/maf.py", line 14, in <module> from bx import interval_index_file File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx/interval_index_file.py", line 87, in <module> from bx.misc import filecache File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx/misc/filecache.py", line 4, in <module> from bx_extras.lrucache import LRUCache File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx_extras/lrucache.py", line 40, in <module> from functools import total_ordering ImportError: cannot import name total_ordering

Comments (3)

  1. cometsong reporter

    Good morning!

    We have recently installed the bx-python libraries. Running the maf_to_fasta script, we get an ImportError as it tried to use 'lrucache.py' and import total_ordering from functools.

    Unfortunately, the latest stable version of python for the latest stable release of debian (squeeze 6) is only 2.6.6, which does not include the total_ordering function in functools.

    Looking into this, I discovered a workaround version-check hacked into the django code for the same situation... https://github.com/django/django/blob/5cbfb48b92cb26a335f9c8c0f79d3390290103e2/django/utils/functional.py

    And a related python bug report: http://bugs.python.org/issue10042

    Is it possible to modify the bx code to match the django-style version check? Or should I just [wait for next debian|make-install py2.7 and check for library breaks|etc]? :)

    The traceback error we receive is below.

    Thanks!

    Benjamin

    (note: the formatting is funky, this is a re-post to be readable.)

    > python maf_to_fasta.py < foo.maf > bar.fasta 
    Traceback (most recent call last):
      File "maf_to_fasta.py", line 13, in <module>
        from bx.align import maf
      File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx/align/maf.py", line 14, in <module>
        from bx import interval_index_file
      File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx/interval_index_file.py", line 87, in <module>
        from bx.misc import filecache
      File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx/misc/filecache.py", line 4, in <module>
        from bx_extras.lrucache import LRUCache
      File "/usr/local/lib/python2.6/dist-packages/bx_python-0.7.1-py2.6-linux-x86_64.egg/bx_extras/lrucache.py", line 40, in <module>
        from functools import total_ordering
    ImportError: cannot import name total_ordering
    
  2. mruffalo

    This is my fault; I added this without noticing when functools.total_ordering was added to the standard library. The Node class previously defined the cmp__ function, and I removed all usage of this since it's no longer supported in Python 3. I saved myself some typing with total_ordering, but this isn't necessary and can easily be replaced.

    I've just created pull request #4 to address this.

  3. Log in to comment