Closed yurivict closed 1 year ago
How did you compile/install preshed
? python -m pytest
in the source directory will only work with an editable install.
Otherwise, you can cd
into another directory and run python -m pytest --pyargs preshed
to run the tests from the installed module.
python -m pytest --pyargs
works.
What's "editable install"?
Please search for "pip editable install".
I don't use pip at all. The package is installed into a stage directory, which is added to PYTHONPATH
: PYTHONPATH=/usr/ports/devel/py-preshed/work-py39/stage/usr/local/lib/python3.9/site-packages
For our packages that have compiled C/C++ extension modules (so not just pure python; for preshed you have to compile the cython modules) you can only run pytest
in a directory where the package has been installed, so I think it would work from /usr/ports/devel/py-preshed/work-py39/stage/usr/local/lib/python3.9/site-packages/preshed
in your example.
If you're in the original/unmodified source directory, python tries to import the local directory named preshed
instead of the installed preshed
module and it fails because this isn't a full install. If you do an editable install (with pip or another tool that supports this), then you would have the compiled modules within this directory and you can run pytest preshed/tests
.
We provide all our tests with our python packages so that you can run pytest --pyargs package_name
without needing to have the original source directory available.
Maybe it would help if you clarify how you're installing preshed
and why you're trying to run the tests from within the source directory? (I don't understand what you're actually trying to do in the end with your preshed install?)
I'll close this for now because I don't think there's a bug to address in preshed
. (You can certainly discuss the advantages of using a src/
layout instead.)
Python-3.9 FreeBSD 13.2