-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: --try-first-with
was overriding an absolute --python
path
#2921
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: --try-first-with
was overriding an absolute --python
path
#2921
Conversation
When you use `--python` with an absolute path, it should be a strict requirement. However, I noticed that if you also used `--try-first-with`, an interpreter from `--try-first-with` could be selected even if it didn't match the absolute path from `--python`. To fix this, I adjusted the logic in the `satisfies` method of the `PythonInfo` class. Now, if a `PythonSpec` contains an absolute path, any candidate interpreter whose executable path doesn't exactly match is immediately rejected. I've also added a regression test to make sure this doesn't happen again. Finally, I updated the documentation to clarify how `--python` and `--try-first-with` are intended to work together. Essentially, `--python` sets the rule, and `--try-first-with` provides hints that are only used if they follow that rule. Closes pypa#2659, closes pypa#2725 Signed-off-by: Emre Şafak <[email protected]>
…te `--python` path. When you use `--python` with an absolute path, it should be a strict requirement. However, I noticed that if you also used `--try-first-with`, an interpreter from `--try-first-with` could be selected even if it didn't match the absolute path from `--python`. To fix this, I've adjusted the logic in the `propose_interpreters` function. Now, if a `PythonSpec` contains an absolute path, only that path will be considered. I've also added a regression test to make sure this doesn't happen again. Finally, I've updated the documentation to clarify how `--python` and `--try-first-with` are intended to work together. Essentially, `--python` sets the rule, and `--try-first-with` provides hints that are only used if they follow that rule.
When `--python` is used with an absolute path, it should be treated as a strict requirement. Currently, if `--try-first-with` is also used, an interpreter from `--try-first-with` could be selected even if it didn't match the absolute path from `--python`. This commit corrects the logic in the `propose_interpreters` function. If a `PythonSpec` contains an absolute path, only that path is considered. A regression test has been added to verify this fix. The test is now platform-aware and creates real virtual environments to ensure it works correctly on all operating systems. Additionally, the documentation has been updated to clarify the intended interaction between `--python` and `--try-first-with`, explaining that `--python` sets the rule and `--try-first-with` provides hints that are only used if they satisfy that rule.
Signed-off-by: Emre Şafak <[email protected]>
Signed-off-by: Emre Şafak <[email protected]>
It won't auto merge since a test was canceled, but that one passed before I edited some unrelated files so I'm confident it is ok. |
I’d like to know, if you only provide |
That's correct. |
When you use
--python
with an absolute path, it should be a strict requirement. However, I noticed that if you also used--try-first-with
, an interpreter from--try-first-with
could be selected even if it didn't match the absolute path from--python
.To fix this, I adjusted the logic in the
satisfies
method of thePythonInfo
class. Now, if aPythonSpec
contains an absolute path, any candidate interpreter whose executable path doesn't exactly match is immediately rejected.I've also added a regression test to make sure this doesn't happen again.
Finally, I updated the documentation to clarify how
--python
and--try-first-with
are intended to work together. Essentially,--python
sets the rule, and--try-first-with
provides hints that are only used if they follow that rule.Closes #2659, closes #2725
tox -e fix
)docs/changelog
folder