src: move package under src directory#356
Merged
williamcroberts merged 2 commits intotpm2-software:masterfrom May 18, 2022
Merged
src: move package under src directory#356williamcroberts merged 2 commits intotpm2-software:masterfrom
williamcroberts merged 2 commits intotpm2-software:masterfrom
Conversation
Issue tpm2-software#341 reports that building a wheel and running the tests fails. I was able to reproduce this behavior with the following commands: python3 -Bm build -w --no-isolation python3 -m installer --destdir=installation dist/*.whl export PYTHONPATH="/home/wcrobert/tmp/installation/usr/lib/python3.8/site-packages" pytest test/test_types.py Note: - Current Working Directory is the repo clone, so tpm2-pytss - The export command may need to be updated for your specific version of python. It fails with: ImportError while importing test module '/home/wcrobert/workspace/tpm2-pytss/test/test_types.py'. <snip> E ModuleNotFoundError: No module named 'tpm2_pytss._libtpm2_pytss' However, this issue is a red herring. This really has to do with the fact that the relative import in the test code tries to resolve to non-built package in that directory rather then the built one on PYTHONPATH. Proposed solutions to use full package names also don't work, becuase it has to resolve to the built package and it will still attempt to resolve the non-built package. The least finicky solution to fix this, was to match what bcrypt was doing and move it under a src directory so it forces the resolution to not occur on that directory and inplace (pip install -e .) installations still work as well. Fixes: tpm2-software#341 Signed-off-by: William Roberts <william.c.roberts@intel.com>
5affa33 to
43fc769
Compare
Codecov Report
@@ Coverage Diff @@
## master #356 +/- ##
=======================================
Coverage 92.93% 92.93%
=======================================
Files 17 17
Lines 6017 6017
Branches 939 939
=======================================
Hits 5592 5592
Misses 293 293
Partials 132 132
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
c87542a to
6013d07
Compare
Add it so it's found for import in the conf file for mocking. Signed-off-by: William Roberts <william.c.roberts@intel.com>
whooo
approved these changes
May 18, 2022
archlinux-github
pushed a commit
to archlinux/aur
that referenced
this pull request
Jul 31, 2022
…de=append This is no longer required since tpm2-software/tpm2-pytss#356
4 tasks
salahcoronya
added a commit
to salahcoronya/gentoo
that referenced
this pull request
Jan 4, 2026
A patch is applied to move the main python package directory under src, otherwise the tests fail because the source package containing the directory occuldes the one on the system, and the tests fail. See tpm2-software/tpm2-pytss#356 for another package that had the same problem and its explaination of the solution Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
gentoo-bot
pushed a commit
to gentoo/gentoo
that referenced
this pull request
Jan 5, 2026
A patch is applied to move the main python package directory under src, otherwise the tests fail because the source package containing the directory occuldes the one on the system, and the tests fail. See tpm2-software/tpm2-pytss#356 for another package that had the same problem and its explaination of the solution Signed-off-by: Christopher Byrne <salah.coronya@gmail.com> Part-of: #45252 Signed-off-by: Sam James <sam@gentoo.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #341 reports that building a wheel and running the tests fails. I
was able to reproduce this behavior with the following commands:
python3 -Bm build -w --no-isolation
python3 -m installer --destdir=installation dist/*.whl
export PYTHONPATH="/home/wcrobert/tmp/installation/usr/lib/python3.8/site-packages"
pytest test/test_types.py
Note:
of python.
It fails with:
ImportError while importing test module '/home/wcrobert/workspace/tpm2-pytss/test/test_types.py'.
E ModuleNotFoundError: No module named 'tpm2_pytss._libtpm2_pytss'
However, this issue is a red herring. This really has to do with the
fact that the relative import in the test code tries to resolve to
non-built package in that directory rather then the built one on
PYTHONPATH.
Proposed solutions to use full package names also don't work, becuase it
has to resolve to the built package and it will still attempt to resolve
the non-built package. The least finicky solution to fix this, was to
match what bcrypt was doing and move it under a src directory so it
forces the resolution to not occur on that directory and inplace (pip
install -e .) installations still work as well.
Fixes: #341
Signed-off-by: William Roberts william.c.roberts@intel.com