libnano / primer3-py

Simple oligo analysis and primer design
https://libnano.github.io/primer3-py
GNU General Public License v2.0
157 stars 43 forks source link

import errors when testing #120

Closed doronbehar closed 1 year ago

doronbehar commented 1 year ago

Hello,

I'd like to make NixOS run the tests of this package during build. Here's a log of the errors we see here, when we run python -m pytest:

============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-7.4.0, pluggy-1.2.0
rootdir: /build/source
collected 4 items / 4 errors                                                   

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_p3helpers.py ___________________
ImportError while importing test module '/build/source/tests/test_p3helpers.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/lx8vhp4fxclp494svlfis3sb2g8z4l9h-python3-3.10.12/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_p3helpers.py:27: in <module>
    from primer3 import p3helpers  # type: ignore
E   ImportError: cannot import name 'p3helpers' from 'primer3' (/build/source/primer3/__init__.py)
_________________ ERROR collecting tests/test_primerdesign.py __________________
ImportError while importing test module '/build/source/tests/test_primerdesign.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/lx8vhp4fxclp494svlfis3sb2g8z4l9h-python3-3.10.12/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_primerdesign.py:44: in <module>
    from primer3 import (
primer3/bindings.py:43: in <module>
    from primer3 import (  # type: ignore
E   ImportError: cannot import name 'thermoanalysis' from 'primer3' (/build/source/primer3/__init__.py)
________________ ERROR collecting tests/test_thermoanalysis.py _________________
ImportError while importing test module '/build/source/tests/test_thermoanalysis.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/lx8vhp4fxclp494svlfis3sb2g8z4l9h-python3-3.10.12/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_thermoanalysis.py:37: in <module>
    from primer3 import bindings
primer3/bindings.py:43: in <module>
    from primer3 import (  # type: ignore
E   ImportError: cannot import name 'thermoanalysis' from 'primer3' (/build/source/primer3/__init__.py)
__________________ ERROR collecting tests/test_threadsafe.py ___________________
ImportError while importing test module '/build/source/tests/test_threadsafe.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/nix/store/lx8vhp4fxclp494svlfis3sb2g8z4l9h-python3-3.10.12/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_threadsafe.py:37: in <module>
    from primer3 import thermoanalysis  # type: ignore
E   ImportError: cannot import name 'thermoanalysis' from 'primer3' (/build/source/primer3/__init__.py)
=========================== short test summary info ============================
ERROR tests/test_p3helpers.py
ERROR tests/test_primerdesign.py
ERROR tests/test_thermoanalysis.py
ERROR tests/test_threadsafe.py
!!!!!!!!!!!!!!!!!!! Interrupted: 4 errors during collection !!!!!!!!!!!!!!!!!!!!
============================== 4 errors in 0.18s ===============================
benpruitt commented 1 year ago

It looks like the Cython modules are not built. How did you build or install primer3-py prior to invoking python -m pytest. It looks like you are running the tests from within the package directory, in which case you need to do an "in place" build: python setup.py build_ext --inplace

doronbehar commented 1 year ago

Hey and thanks for trying to help :). Indeed we run python -m pytest in the package's directory, after it was installed at a certain location. In fact, here at NixOS we investigate similar issues we experience with other packages that use Cython extension modules, over at https://github.com/NixOS/nixpkgs/issues/255262 .

If I run python setup.py build_ext --inplace before I run python -m pytest indeed that helps and all the tests pass. Perhaps this issue can be closed, as we probably need to further investigate the issue on NixOS by ourselves.