Skip to content
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: detect gil #2762

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions crates/pypi_modifiers/src/pypi_tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ pub fn get_pypi_tags(
let platform = get_platform_tags(platform, system_requirements)?;
let python_version = get_python_version(python_record)?;
let implementation_name = get_implementation_name(python_record)?;
create_tags(platform, python_version, implementation_name)
let gil_disabled = gil_disabled(python_record)?;
create_tags(platform, python_version, implementation_name, gil_disabled)
}

/// Create a uv platform tag for the specified platform
Expand Down Expand Up @@ -159,10 +160,20 @@ fn get_implementation_name(python_record: &PackageRecord) -> miette::Result<&'st
}
}

/// Return whether the specified record has gil disabled (by being a free-threaded python interpreter)
/// by looking into the build string of the record.
fn gil_disabled(python_record: &PackageRecord) -> miette::Result<bool> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we can depend on that t I've asked in the conda-forge zulip: https://conda-forge.zulipchat.com/#narrow/channel/457337-general/topic/Python.20freethreading.20from.20record/near/490528853

Also, I think you can skip the result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. Let's wait for the resolution from their side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

based on discussion with @wolfv - it seems right way to do things, we just need to additional check if it's from conda-forge

Copy link
Contributor

Choose a reason for hiding this comment

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

Didnt follow the discussion with wolf but isnt isurufs answer on zulip the rught approach for the tags?

Then python_abi is the correct way. You don't have to check that it ends with t. Just use the entirety of cp313t

match &python_record.build.ends_with("t") {
true => Ok(true),
false => Ok(false),
}
}

fn create_tags(
platform: uv_platform_tags::Platform,
python_version: (u8, u8),
implementation_name: &str,
gil_disabled: bool,
) -> miette::Result<Tags> {
// Build the wheel tags based on the interpreter, the target platform, and the python version.
let tags = Tags::from_env(
Expand All @@ -172,8 +183,7 @@ fn create_tags(
// TODO: This might not be entirely correct..
python_version,
true,
// Should revisit this when this lands: https://github.com/conda-forge/python-feedstock/pull/679
false,
gil_disabled,
)
.into_diagnostic()
.context("failed to determine the python wheel tags for the target platform")?;
Expand Down
Loading