Skip to content

Conversation

@salahcoronya
Copy link

Otherwise, tests can fail because the name of the subdirectory occuldes with the one in the venv.

Gentoo has a feature were we can run the packages test suite before installing, but the above problem prevent it from working. Its possible to do some filename/pathname dances to get around it. This isn't the first package I've run into this issue, see tpm2-software/tpm2-pytss#356

Otherwise, tests can fail because the name of the subdirectory occuldes
with the one in the venv.

Signed-off-by: Christopher Byrne <salah.coronya@gmail.com>
@kislyuk
Copy link
Member

kislyuk commented Jan 5, 2026

I don't think this is the right approach to solving the problem at hand. The normal convention in Python package repositories is to put the package subdirectory at the top level, not under src/. I recommend finding a different solution.

Personally, in my other projects, I organize tests under a top level test/ subdirectory. Perhaps renaming tests/ to test/ would work in this case, but more generally, it's best to avoid changes that go against the established convention to accommodate a distro quirk like this.

@salahcoronya
Copy link
Author

The problem isn't the "tests" directory, the problem is the "pkcs11" directory. pytest adds the current directory to PYTHONPATH first. So the current directory's "pkcs11" subdirectory, which occludes "pkcs11" subdirectoryfurther in the PYTHONPATH that actually contains the needed files.

Both methods seem to be acceptable, but the "src" method has some advantages: https://packaging.python.org/en/latest/discussions/src-layout-vs-flat-layout/.

Note this isn't Gentoo specific. Anyone using "pip install -e ." with the source tree will hit the same problem. This seems to be a cleaner approach,

But I can work around in Gentoo easily enough by delete the subdirectoy just before the test.

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

Successfully merging this pull request may close these issues.

2 participants