Skip invalid interpreters when searching for requested interpreter executable name#4308
Merged
Skip invalid interpreters when searching for requested interpreter executable name#4308
Conversation
e88ea0b to
eb8d5d1
Compare
zanieb
commented
Jun 13, 2024
Comment on lines
+364
to
+365
| // TODO(zanieb): Move filtering to callers | ||
| filter_by_system_python( |
Member
Author
There was a problem hiding this comment.
This refactor wasn't needed for this pull request but we'll do this in the next change to facilitate respecting the system python preferences when reading executable names.
zanieb
commented
Jun 13, 2024
Comment on lines
-485
to
516
|
|
||
| fn find_toolchain_with_executable_name( | ||
| name: &str, | ||
| cache: &Cache, | ||
| ) -> Result<ToolchainResult, Error> { | ||
| let Some(executable) = which(name).ok() else { | ||
| return Ok(ToolchainResult::Err( | ||
| ToolchainNotFound::ExecutableNotFoundInSearchPath(name.to_string()), | ||
| )); | ||
| }; | ||
| Ok(ToolchainResult::Ok(Toolchain { | ||
| source: ToolchainSource::SearchPath, | ||
| interpreter: Interpreter::query(executable, cache)?, | ||
| })) | ||
| /// Lazily iterate over all Python interpreters on the path with the given executable name. | ||
| fn python_interpreters_with_executable_name<'a>( | ||
| name: &'a str, | ||
| cache: &'a Cache, | ||
| ) -> impl Iterator<Item = Result<(ToolchainSource, Interpreter), Error>> + 'a { | ||
| python_interpreters_from_executables( | ||
| which_all(name) | ||
| .into_iter() | ||
| .flat_map(|inner| inner.map(|path| Ok((ToolchainSource::SearchPath, path)))), | ||
| cache, | ||
| ) | ||
| } |
BurntSushi
approved these changes
Jun 13, 2024
zanieb
added a commit
that referenced
this pull request
Aug 19, 2024
Executable name requests were being treated as explicit requests to install into system environments, but I don't think it should be as it's implicit what environment you'll end up in. Following #4308, we allow multiple executables to be found so we can filter here. Concretely, this means `--system` is required to install into a system environment discovered with e.g. `--python=python`. The flag is still not required for cases where we're not mutating environment.
zanieb
added a commit
that referenced
this pull request
Aug 19, 2024
Executable name requests were being treated as explicit requests to install into system environments, but I don't think it should be as it's implicit what environment you'll end up in. Following #4308, we allow multiple executables to be found so we can filter here. Concretely, this means `--system` is required to install into a system environment discovered with e.g. `--python=python`. The flag is still not required for cases where we're not mutating environment.
zanieb
added a commit
that referenced
this pull request
Aug 19, 2024
Executable name requests were being treated as explicit requests to install into system environments, but I don't think it should be as it's implicit what environment you'll end up in. Following #4308, we allow multiple executables to be found so we can filter here. Concretely, this means `--system` is required to install into a system environment discovered with e.g. `--python=python`. The flag is still not required for cases where we're not mutating environment.
zanieb
added a commit
that referenced
this pull request
Aug 20, 2024
Executable name requests were being treated as explicit requests to install into system environments, but I don't think it should be as it's implicit what environment you'll end up in. Following #4308, we allow multiple executables to be found so we can filter here. Concretely, this means `--system` is required to install into a system environment discovered with e.g. `--python=python`. The flag is still not required for cases where we're not mutating environment.
zanieb
added a commit
that referenced
this pull request
Aug 20, 2024
Executable name requests were being treated as explicit requests to install into system environments, but I don't think it should be as it's implicit what environment you'll end up in. Following #4308, we allow multiple executables to be found so we can filter here. Concretely, this means `--system` is required to install into a system environment discovered with e.g. `--python=python`. The flag is still not required for cases where we're not mutating environment.
zanieb
added a commit
that referenced
this pull request
Aug 20, 2024
Executable name requests were being treated as explicit requests to install into system environments, but I don't think it should be as it's implicit what environment you'll end up in. Following #4308, we allow multiple executables to be found so we can filter here. Concretely, this means `--system` is required to install into a system environment discovered with e.g. `--python=python`. The flag is still not required for cases where we're not mutating environment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, we took the first executable on the
PATHbut if it was not a usable interpreter we'd fail. Now, we'll continue searching in the path until we find an interpreter as we do with the standard executable names.