Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import errors when testing #120

Closed
doronbehar opened this issue Sep 15, 2023 · 2 comments
Closed

import errors when testing #120

doronbehar opened this issue Sep 15, 2023 · 2 comments

Comments

@doronbehar
Copy link

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
Copy link
Contributor

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
Copy link
Author

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 NixOS/nixpkgs#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants