-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Run interpreter discovery under -I
mode
#2552
Conversation
24d6de5
to
061cc54
Compare
I don't understand why this broke the Windows shims. |
061cc54
to
ca4ed17
Compare
I guess the |
ca4ed17
to
afc489e
Compare
-I
mode
I also manually verified that the Pyenv shims continue to work:
|
afc489e
to
d2cb1db
Compare
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.
Interesting. Why -c
(and previously -m
) instead of just python <path>
?
We need to be able to resolve relative imports (so we can't use |
Summary
If you have a file
typing.py
in the current working directory,python -m
doesn't work in some Python versions:This did not cause problems for us on Python 3.11 or later, because we set
PYTHONSAFEPATH
, which avoids adding the current working directory tosys.path
. However, on earlier versions, we were failing with the above. (It's important that we run interpreter discovery in the current working directory, since doing otherwise breaks pyenv shims.)The fix implemented here uses
-I
to run Python in isolated mode, which is even stricter. The downside of isolated mode is that we currently rely on settingPYTHONPATH
to find the "fake module" that we create on disk, and-I
meansPYTHONPATH
is totally ignored. So, instead, we run a script directly, and that script injects the path we care about intoPYTHONSAFEPATH
.Closes #2547.