-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix the detection of the system environment with custom installer #4433
Conversation
0aec865
to
af920c5
Compare
poetry/utils/env.py
Outdated
python_executables = sorted( | ||
[ | ||
p.name | ||
for p in self._bin_dir.glob("python*") | ||
if re.match(r"python(?:\d+(?:\.\d+)?)?(?:\.exe)?$", p.name) | ||
] | ||
) | ||
self._executable = python_executables[0].rstrip(".exe") |
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.
If I understand the code correct, it should work if there is only one python interpreter in the environment. But what happens if we have a python2, python3.6, python3.7? python2 will be selected. But we cannot be sure that this is the intended interpreter.
Can we make the following assumptions?:
- in a venv there will be only on interpreter
- in the system env there can be multiple interpreter
If so, we could look for python executables of the format pythonX.Y
. If we receive exactly one, take it. If we get multiple, take the one with the same version as poetry is running.
BTW: rstrip()
doesn't strip .exe
from the end of the string. It removes any of the given character from the end until it hits a character not listed. A trap I run into regularly 😄
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.
I updated the code to look for the executable of the child environment (if given). Otherwise the previous logic is used.
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.
Note that I intend to rewrite the environment management at some point but it will be after the release of the 1.2 version.
be7ec1d
to
7ca2060
Compare
b20808d
to
041e10f
Compare
How would I test this for myself ? |
963cfeb
to
37b6c37
Compare
37b6c37
to
96bc4ee
Compare
hey @sdispater it looks like this is merged into master ? I used the latest |
Hey @datacubed, the fin swimmer |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
After several attempts at fixing this, I think this is the best approach: differentiate the custom Poetry virtual environment – by putting a special file – from standard ones so that there is no confusion about what Poetry needs to do when detecting the system environment.
Resolves #4427
Resolves #4414
Resolves #4369
Resolves #4254
Pull Request Check List