Skip to content

Add parallel discovery of Python versions for uv python list#18684

Draft
zanieb wants to merge 4 commits intomainfrom
zb/find-all-python
Draft

Add parallel discovery of Python versions for uv python list#18684
zanieb wants to merge 4 commits intomainfrom
zb/find-all-python

Conversation

@zanieb
Copy link
Copy Markdown
Member

@zanieb zanieb commented Mar 23, 2026

No description provided.

@zanieb zanieb added the performance Potential performance improvement label Mar 23, 2026
true
}

/// In test mode, change the source to `Managed` if a version was marked as such via
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// In test mode, change the source to `Managed` if a version was marked as such via
/// In test mode, change the source to [`PythonSource::Managed`] if a version was marked as such via

Comment on lines +764 to +770
fn update_installation_source_for_tests(installation: &mut PythonInstallation) {
if std::env::var(uv_static::EnvVars::UV_INTERNAL__TEST_PYTHON_MANAGED).is_ok()
&& installation.interpreter.is_managed()
{
installation.source = PythonSource::Managed;
}
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use #[must_use] add a with_source method that returns Self so we don't need a mut here?

}

/// Check whether an installation satisfies the standard post-query discovery filters.
fn satisfies_discovery_filters(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn satisfies_discovery_filters(
fn installation_satisfies_discovery_filters(

Comment on lines +740 to +742
if !interpreter_satisfies_environment_preference(
installation.source,
&installation.interpreter,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can interpreter_satisfies_environment_preference be installation_satisfies_environment_preference and not take the decomposed values?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it could also be EnvironmentPreference.allows_installation(...)?

Comment on lines +747 to +755
let request = version.clone().into_request_for_source(installation.source);
if !request.matches_interpreter(&installation.interpreter) {
debug!(
"Skipping interpreter at `{}` from {}: does not satisfy request `{request}`",
installation.interpreter.sys_executable().user_display(),
installation.source,
);
return false;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we abstract this with VersionRequest.matches_installation?

@zanieb zanieb added the build:skip-release Disable building release binaries for a pull request label Mar 24, 2026
}

/// Collect queried Python installations from executables, dropping non-critical discovery
/// errors.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a comment linking to [iter_..]


/// Find Python installations that satisfy the standard discovery filters, querying
/// interpreters concurrently.
fn find_matching_python_installations(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn find_matching_python_installations(
fn find_all_matching_python_installations(


/// Create a [`PythonInstallation`] from a Python interpreter path.
fn python_installation_from_executable(
fn python_installation_from_provided_executable(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems useless, we should just inline usage

Comment on lines +1330 to +1336
if !preference.allows_source(PythonSource::ProvidedPath) {
return Err(Error::SourceNotAllowed(
request.clone(),
PythonSource::ProvidedPath,
preference,
));
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be moved to preference.check_allows_request_source -> Result<(), Err)? so we can reuse it outside the match instead now that it's repeated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:skip-release Disable building release binaries for a pull request performance Potential performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant