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

Python tests fail: No module named 'segyio._segyio' #511

Closed
yurivict opened this issue Aug 15, 2021 · 7 comments
Closed

Python tests fail: No module named 'segyio._segyio' #511

yurivict opened this issue Aug 15, 2021 · 7 comments

Comments

@yurivict
Copy link

yurivict commented Aug 15, 2021

setup.py test fails:

_____________________________________________________________________________ ERROR collecting test/segyio_c.py ______________________________________________________________________________
ImportError while importing test module '/disk-samsung/freebsd-ports/science/py-segyio/work-py38/segyio-1.9.7/python/test/segyio_c.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test/segyio_c.py:13: in <module>
    import segyio._segyio as _segyio
E   ModuleNotFoundError: No module named 'segyio._segyio'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================== 1 error in 0.62 seconds ===================================================================================
*** Error code 2

Python-3.8
FreeBSD 13

@jokva
Copy link

jokva commented Aug 16, 2021

Is the python extension built and made available? Try setup.py build_ext --inplace build and see if the problem persists.

@yurivict
Copy link
Author

yurivict commented Aug 16, 2021

import segyio succeeds.

Not sure why does the test run import segyio._segyio,

@jokva
Copy link

jokva commented Aug 16, 2021

The segyio_c tests specifically targets the C++ code in the extension, so it has to import it. Since loading it is expensive and makes (some) tests slightly harder to develop, it is not imported until it is requested. Starting fresh I'd not make the same mistake again, but this is expected behaviour as-of now.

@yurivict
Copy link
Author

After setup.py build_ext --inplace tests pass.

But this command isn't run during the package build. Does this mean that some functionality is missing?

@jokva
Copy link

jokva commented Aug 16, 2021

No, not really, just that it's the more ergonomic approach. The problem is that setup.py build by default won't move the python extension (_segyio.so) into the source tree, and the build- and package scripts run the tests they do against the source tree. If you do setup.py install it will make sure to bring the _segyio.so file too, and the tests would pass again.

By doing it this way, some things are still functional even without building (or moving) the .so, and there was not too much incentive to change it, since anyone coming across it is likely a developer (or packager) and would want to build with --inplace or pip install -e . anyway.

@yurivict
Copy link
Author

Ok, thanks!

@jokva
Copy link

jokva commented Aug 16, 2021

No problem!

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