mikolmogorov / Flye

De novo assembler for single molecule sequencing reads using repeat graphs
Other
743 stars 164 forks source link

Flye install fails with Python 3.12 #669

Open pushkarnk opened 5 months ago

pushkarnk commented 5 months ago

With Python 3.12 installed on the Ubuntu dev release, when I tried to make, install and run the install test, the test fails with :

python3 flye/tests/test_toy.py
Running toy test:

Traceback (most recent call last):
  File "/usr/local/bin/flye", line 33, in <module>
    sys.exit(load_entry_point('flye==2.9.3', 'console_scripts', 'flye')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/bin/flye", line 25, in importlib_load_entry_point
    return next(matches).load()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 994, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/local/lib/python3.12/dist-packages/flye/main.py", line 19, in <module>
    import flye.polishing.alignment as aln
  File "/usr/local/lib/python3.12/dist-packages/flye/polishing/alignment.py", line 18, in <module>
    import flye.utils.fasta_parser as fp
  File "/usr/local/lib/python3.12/dist-packages/flye/utils/fasta_parser.py", line 26, in <module>
    from flye.six.moves import range
ModuleNotFoundError: No module named 'flye.six.moves'
Traceback (most recent call last):
  File "/root/Flye/flye/tests/test_toy.py", line 41, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/Flye/flye/tests/test_toy.py", line 36, in main
    test_toy()
  File "/root/Flye/flye/tests/test_toy.py", line 29, in test_toy
    subprocess.check_call(["flye", "--pacbio-corr", reads_file, "-g", "500k",
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['flye', '--pacbio-corr', '/root/Flye/flye/tests/data/ecoli_500kb_reads_hifi.fastq.gz', '-g', '500k', '-o', 'flye_toy_test', '-t', '8', '-m', '1000']' returned non-zero exit status 1.

In short, Python 3.12 fails to find the "moves" module which is dynamically loaded using flye/six.py. This is likely to be because Python3 has gradually moved away from find_module() to find_spec() for path-based finders searching the meta path:

Changed in version 3.4: The [find_spec()](https://docs.python.org/3/library/importlib.html#importlib.abc.MetaPathFinder.find_spec) method of meta path finders replaced find_module(), which is now deprecated. While it will continue to work without change, the import machinery will try it only if the finder does not implement [find_spec()](https://docs.python.org/3/library/importlib.html#importlib.abc.MetaPathFinder.find_spec).

Changed in version 3.10: Use of find_module() by the import system now raises [ImportWarning](https://docs.python.org/3/library/exceptions.html#ImportWarning).

Changed in version 3.12: find_module() has been removed. Use [find_spec()](https://docs.python.org/3/library/importlib.html#importlib.abc.MetaPathFinder.find_spec) instead.

flye/six.py hasn't yet moved from find_module() to find_spec() and this is likely to be the reason for the above error.

pushkarnk commented 5 months ago

Fix proposed via https://github.com/fenderglass/Flye/pull/670

mikolmogorov commented 4 months ago

Thanks, will work on that in the next release.

a-detiste commented 10 hours ago

six should be removed too