Skip to content

Fork version selection based on wheel Python version tags#18587

Draft
charliermarsh wants to merge 6 commits intomainfrom
charlie/fork-wheels
Draft

Fork version selection based on wheel Python version tags#18587
charliermarsh wants to merge 6 commits intomainfrom
charlie/fork-wheels

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

@charliermarsh charliermarsh commented Mar 20, 2026

Summary

In #15069, the latest version of pywin32 doesn't include a Python 3.7 wheel. With this PR, we fork if a wheel-only distribution has a lower-bound below our requires-python bound so that each fork can choose a version with a compatible wheel.

Closes #15069.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 20, 2026

Merging this PR will not alter performance

❌ 1 regressed benchmark
✅ 4 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime resolve_warm_airflow 496.1 ms 514.3 ms -3.52%

Comparing charlie/fork-wheels (896ea11) with main (d5f1325)

Open in CodSpeed

@charliermarsh charliermarsh force-pushed the charlie/fork-wheels branch 4 times, most recently from 350f7ef to 8e8f698 Compare March 24, 2026 13:06
@charliermarsh charliermarsh added bug Something isn't working resolver Related to the package resolver labels Mar 24, 2026
@charliermarsh charliermarsh changed the title Re-compute supported Python range when forking Fork version selection based on wheel Python version tags Mar 25, 2026
@charliermarsh charliermarsh marked this pull request as ready for review March 25, 2026 00:44
@charliermarsh charliermarsh requested review from konstin and zanieb March 25, 2026 00:44
description = "State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow"
keywords = ["NLP", "vision", "speech", "deep", "learning", "transformer", "pytorch", "tensorflow", "jax", "BERT", "GPT-2", "Wav2Vec2", "ViT"]
requires-python = ">=3.9.0"
requires-python = ">=3.9.0,<3.12"
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 is a bit unfortunate, but tensorflow>=2.6,<2.16 legitimately doesn't have a wheel for Python 3.12...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this new upper bound required, or did you it for some other reason? Cause I wouldn't want to make it required when we otherwise recommend against upper bounds.

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's required, because the resolution below ends up forking on Python version during the course of solving, so we have a branch with >=3.12 that tries to include tensorflow>=2.6,<2.16, which doesn't have a valid wheel in that range, so it's a broken solution.

We could instead add this as a supported environments field rather than bounding requires-python. Or we could decide we don't want these semantics, and we could limit this behavior to the user-defined requires-python range (e.g., we need wheels at least for Python 3.9).

@charliermarsh charliermarsh force-pushed the charlie/fork-wheels branch 2 times, most recently from fd5df8a to 841e923 Compare March 25, 2026 03:02
torchvision==0.15.1 ; (python_full_version < '3.12' and platform_machine == 'aarch64' and platform_python_implementation == 'CPython' and sys_platform == 'linux') or sys_platform == 'darwin'
# via -r requirements.in
torchvision==0.15.1+rocm5.4.2 ; platform_machine == 'x86_64' and sys_platform != 'darwin'
torchvision==0.15.1+cu118 ; (python_full_version >= '3.12' and sys_platform == 'linux') or (platform_machine != 'aarch64' and sys_platform == 'linux') or (platform_python_implementation != 'CPython' and sys_platform == 'linux') or (sys_platform != 'darwin' and sys_platform != 'linux')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why did we switch accelerator here?

@zanieb
Copy link
Copy Markdown
Member

zanieb commented Mar 25, 2026

Is this related to #15932 ?

@charliermarsh
Copy link
Copy Markdown
Member Author

Yeah, I think it's a similar idea. I am wondering if we should change this PR to only enforce the minimum Python version, though, to avoid problems like the "Tensorflow doesn't have a 3.12 wheel" issue.

@konstin
Copy link
Copy Markdown
Member

konstin commented Mar 27, 2026

I filed mhammond/pywin32#2726 cause the combination of no source dist and no requires-python metadata is rare, most projects have requires-python these days, which is a lot lighter on the resolver complexity-wise.

@charliermarsh
Copy link
Copy Markdown
Member Author

I mean, I think we should still support some version of this? It's a bug, and requires-python is not the same thing.

@konstin
Copy link
Copy Markdown
Member

konstin commented Mar 27, 2026

How would requires-python and an inferred bound from Python version tags act different here? Maybe I'm missing what this PR is trying to do. Or do we do want to support it with an upper bound? This would then be a design decision about whether we want upper-bounds in requires-python in user packages when we ignore then for dependency packages.

@charliermarsh
Copy link
Copy Markdown
Member Author

It's plausible that you could publish a package that supports Python 3.8 and later (e.g., requires-python: >=3.8), but only publish wheels for Python 3.12 (as an example), and no sdist.

The goal of this PR is that we would not accept that version as a valid solution for Python 3.8 through Python 3.11 (unless the user's own project only supports Python 3.12 and later).

@konstin
Copy link
Copy Markdown
Member

konstin commented Mar 27, 2026

That's seem like an odd combination, how would the package be compatible with 3.8, when there's no option to install it before 3.12? To me, this sounds more like a mistake in the metadata annotations. I know we had this case with an ML package before (torch or tensorflow), but there it was a mistake on their side and they fixed the bound to match the published wheels in the next release.

@charliermarsh
Copy link
Copy Markdown
Member Author

I don't think it's an incorrect combination though. The code can support Python versions for which they don't publish wheels.

@charliermarsh
Copy link
Copy Markdown
Member Author

I don't understand why we wouldn't want to handle that case correctly?

@@ -1532,43 +1503,43 @@ wheels = [

[[package]]
name = "h5py"
version = "3.11.0"
version = "3.11.[X]"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That looks like a too broad redaction.

@konstin
Copy link
Copy Markdown
Member

konstin commented Mar 27, 2026

I agree that this is correct logic-wise, but I'm worried about the added complexity in the already complex logic around implied/requested platform support and forking. requires-python seems to solve this in a much simpler way with the code we already support.

I don't think it's an incorrect combination though. The code can support Python versions for which they don't publish wheels.

Do we have packages for which this is the case?

@charliermarsh
Copy link
Copy Markdown
Member Author

PyTorch 2.5.1: #14836

@charliermarsh
Copy link
Copy Markdown
Member Author

If we only care about enforcing the minimum requires-python for the user's project, I suspect we can simplify the change. Right now, this attempts to enforce it in every fork.

@charliermarsh
Copy link
Copy Markdown
Member Author

Okay, I pushed a commit that significantly simplifies things by only requiring that each chosen release has a wheel that's compatible with the minimum version in your requires-python.

@charliermarsh charliermarsh marked this pull request as draft March 27, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working resolver Related to the package resolver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv Can't find a correct candidate for package pywin32

3 participants