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
Tests using virtual environments: pass the copy of existing env to the subprocesses #3133
Conversation
@befeleme thank you very much for working on this. There are somethings I don't understand: in the tests the venvs are supposed to have their own installation of setuptools, and testing a complete independent installation of When looking here:
and in jaraco.envs, the environment object seems to do the right thing to find the correct executable inside the virtual env... When looking at: setuptools/setuptools/tests/fixtures.py Line 100 in 6193a69
setuptools/setuptools/tests/fixtures.py Line 109 in 6193a69
and here, and here, I cannot understand how Can you elaborate a bit more on how have you reached the conclusion that missing env vars are the root cause of this problem? |
33a59a1
to
88dbd47
Compare
Firstly, thank you for taking time to look at this PR. Let me elaborate on what happens with the current 60.9.3 when I run the test suite in the build environment for Fedora. We set PYTHONPATH for the test run in the build environment to Problem 1
Test tries to import setuptools and it succeeds, and my understanding is that the installed-by-fedora-build package is indeed on PYTHONPATH and that's where 'DID NOT RAISE...' failure comes from. Problem 2
the situation looks a bit different.
But if
I suspect that copy of the environment that takes place here duplicates "our" PYTHONPATH and causes essentially the same problem with visibility as in the first issue. I hope this shows where we're being hit and why this approach was taken to fix it (I'm sorry for the wall of text, though!) |
Thank you very much @befeleme for the explanation. Nice to see that we are starting to get to the bottom of the problems :) Please correct me here if I am wrong, If I understand it correctly this problem will always happen if someone, instead of running the tests via I always think that making tests more isolated is a good thing, so removing items from the environment variables that are not explicitly set should be fine! However, I would avoid removing items from the |
@befeleme there are somethings that are still not obvious to me, could you try to help me understand?
Assuming that implicit
It is also not clear to me how having Footnotes
|
Yes, this is what happens.
Yes, this is possible. I've run the test suite on a modified patch, when I only touch environment which hasn't been explicitly set by test and the tests pass. Which puzzled me at first, but then given the venv is created and installs package in a context unsetting Regarding the second problem, I think @hroncok's clarification better explains the point I've missed. I'll send the updated (and better explained) patch soon. Thank you for the well-pointed questions! |
Thank you very much @befeleme! Sorry for disturbing you with a lot of questions. |
88dbd47
to
a3e2395
Compare
I have just sent the updated patch. The comments are quite verbose but I hope for a good clarity of the explanation (and I've never managed to keep it short, eh).
No, it's great! This discussion helped me understand the issue much deeper. :) |
a3e2395
to
fb27bec
Compare
The last force-push invalidated the approved workflow. @abravalheri, could you please rerun it? I'm ready with the updates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @befeleme, that is a very great work, and followed by an in depth-investigation!
@Mergifyio rebase |
✅ Branch has been successfully rebased |
af1463a
to
c281740
Compare
@Mergifyio rebase |
This enhances environment isolation, as in special cases, like downstream distro packaging, PYTHONPATH can be set to point to a specific setuptools codebase. When it leaks, it shadows the virtual environment's paths and produces wrong test results.
✅ Branch has been successfully rebased |
c281740
to
634dd7e
Compare
Summary of changes
In specifically set environment like the build environment in Fedora, we noticed some of the tests running subprocesses were failing. Typically they didn't see the correct paths, leading to multiple
ModuleNotFoundError: No module named setuptools
and failed meta-tests intest_virtualenv
(DID NOT RAISE...
).The changes: passing the copy of the environment minus PYTHONPATH for the subprocesses made the test suite pass during our builds.
Pull Request Checklist
changelog.d/
.(See documentation for details)