Skip to content

Conversation

shaanmajid
Copy link

@shaanmajid shaanmajid commented Sep 23, 2025

Adds --all-variants flag to uv python list to show debug Python builds that are normally hidden.

Functional Requirements Met:

  • Default behavior: Only default variants shown (hides debug/freethreaded)
  • --all-variants flag: Shows all variants including debug, freethreaded, freethreaded+debug
  • Explicit requests: 3.13+debug works without needing the flag
  • Flag compatibility: Works with --all-versions, --only-downloads, etc.

Key Behavior:

# Default - only shows default variant
uv python list 3.13  # → cpython-3.13.7-platform

# Show all variants for specific version  
uv python list 3.13 --all-variants  # → default, debug, freethreaded, freethreaded+debug

# Explicit variant request (works without flag)
uv python list 3.13+debug  # → cpython-3.13.7+debug-platform

Fixes #15983

Comment on lines 77 to 79
// When --all-variants is used with a specific request, use Any to get all variants
// The filtering logic will ensure only matching downloads are shown
PythonDownloadRequest::from_request(&PythonRequest::Any)
Copy link
Member

@zanieb zanieb Sep 23, 2025

Choose a reason for hiding this comment

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

This looks wrong — we shouldn't drop the original request from the user. Though I see you filter using it later, then we'll need to duplicate a bunch of logic that happens in discovery. We'll also do a bunch of work querying interpreters that do not match the request. I'm not quite sure how best to achieve what you're trying to do here though.

Copy link
Author

@shaanmajid shaanmajid Sep 24, 2025

Choose a reason for hiding this comment

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

yeah that was pretty troll mb :/

Reworked the implementation based on your feedback

@zanieb
Copy link
Member

zanieb commented Sep 23, 2025

I think this issue may be harder than it looks. Maybe it'd be a good place to start just adjusting the downloads we show based on an --all-variants flag?

@shaanmajid shaanmajid force-pushed the add-all-variants-flag branch 2 times, most recently from 72a0645 to 2921685 Compare September 23, 2025 15:03
@zanieb
Copy link
Member

zanieb commented Sep 23, 2025

Oh it looks like you are only changing the download listing logic here, so perhaps disregard that part (though we'll need to figure out how to show all variants we discover too at some point)

@zanieb
Copy link
Member

zanieb commented Sep 23, 2025

Maybe you need to add something like

/// Whether to allow pre-releases or not. If not set, defaults to true if [`Self::version`] is
/// not None, and false otherwise.
pub(crate) prereleases: Option<bool>,

for variants?

@shaanmajid shaanmajid force-pushed the add-all-variants-flag branch 5 times, most recently from 6cc18a0 to 70b7741 Compare September 24, 2025 21:25
@shaanmajid shaanmajid requested a review from zanieb September 24, 2025 21:35
@shaanmajid
Copy link
Author

Testing was a bit annoying ; I didn't realize debug variants were not supported on Windows at first. Last minute split up a lot of test-cases based off target, but lmk if you think it's worth organizing this better

@shaanmajid shaanmajid force-pushed the add-all-variants-flag branch from 70b7741 to 740f872 Compare September 24, 2025 21:41
@shaanmajid
Copy link
Author

Hey @zanieb, just wanted to check whether there’s anything else you’d like me to do on this PR. Happy to rebase or tweak if needed :)

match self {
Self::Version(version) => version.variant(),
Self::ImplementationVersion(_, version) => version.variant(),
_ => None,
Copy link
Member

Choose a reason for hiding this comment

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

We generally prefer to list all the variants so if we add a new one we're forced to revisit this and see if it needs to be updated.

Copy link
Author

Choose a reason for hiding this comment

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

Updated to use explicit listing.

/// not None, and false otherwise.
pub(crate) prereleases: Option<bool>,

/// Whether to allow all variants, or to filter by the requested variant.
Copy link
Member

Choose a reason for hiding this comment

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

What does "to filter by the requested variant" mean here?

Copy link
Member

Choose a reason for hiding this comment

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

You mean like, one in the VersionRequest?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, that was the intent. Sorry, the conflicting terminology / overload between Python's "variants" and Rust variants is a bit unfortunate here haha. Updated the comment a bit to further elaborate.

if variant != key.variant {
return false;
// Only filter by variant if `all_variants` is not requested
if self.all_variants.is_none() {
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused that this is an Option if we're not using the inner boolean value?

Copy link
Author

@shaanmajid shaanmajid Oct 8, 2025

Choose a reason for hiding this comment

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

Fixed to use an explicit boolean

Comment on lines 58 to 63
#[diagnostic(
code(uv::python::list::conflicting_arguments),
help(
"Use `--all-variants` to show all variants for a Python version, or specify an exact variant like `3.10+debug`, but not both."
)
)]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should use this — we're moving away from miette. You can see other hint formatting to see how we're handling this for now.

Copy link
Author

Choose a reason for hiding this comment

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

Switched to use standard hint formatting

} else {
// If the user request cannot be mapped to a download request, we won't show any downloads
PythonDownloadRequest::from_request(request.as_ref().unwrap_or(&PythonRequest::Any))
.map(|request| request.with_all_variants(all_variants))
Copy link
Member

@zanieb zanieb Oct 7, 2025

Choose a reason for hiding this comment

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

Comment on lines 139 to 144
all_variants
|| request
.as_ref()
.and_then(uv_python::PythonRequest::variant)
.unwrap_or(uv_python::PythonVariant::Default)
== *download.key().variant()
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused that we're changing the filtering here and at https://github.com/astral-sh/uv/pull/16002/files#r2411618419

Why do we need both?

Copy link
Author

@shaanmajid shaanmajid Oct 8, 2025

Choose a reason for hiding this comment

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

Updated and consolidated.

@shaanmajid shaanmajid force-pushed the add-all-variants-flag branch 4 times, most recently from 560a5a0 to b602f77 Compare October 8, 2025 22:17
Python list now supports explicit variant requests (e.g. `3.10+debug`, `3.13t`)
to show specific debug or free-threaded builds.

A new `--all-variants` flag lists every available variant for a version
(e.g. `uv python list 3.10 --all-variants`). By default, only standard
builds are shown, matching previous behavior.

The `--all-variants` flag can't be combined with explicit variant requests
(e.g. `uv python list 3.10+debug --all-variants`) to avoid ambiguity.

Fixes astral-sh#15983
Adds comprehensive test coverage for variant functionality in python
list.
Add example usage for --all-variants flag showing how to list
debug and freethreaded Python builds alongside other uv python list
options.
@shaanmajid shaanmajid force-pushed the add-all-variants-flag branch from b602f77 to aa9842b Compare October 8, 2025 22:46
@shaanmajid shaanmajid changed the title feat: add --all-variants flag to uv python list Add support for explicit variants and --all-variants flag with uv python list Oct 8, 2025
@shaanmajid
Copy link
Author

@zanieb Wanted to quickly double-check about pre-existing behavior with the display of freethreaded variants.

Currently:

  • uv python list (i.e. no explicit request) shows both default and free-threaded variants (i.e. all non-debug variants)
  • uv python list 3.13 (i.e. explicit request) shows only the default variant

This seems intentional and aligns with treating freethreaded as non-experimental in Python 3.14+ and uv 0.9+ (per #16142). Just wanted to confirm this is the intended behavior, since this PR makes the variant filtering more explicit.

@shaanmajid shaanmajid requested a review from zanieb October 8, 2025 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --all-variants option to show debug builds in uv python list
2 participants