(Firstly, please do let me know if this is the right place to post this. Thank you!)
So for a bit of background, I maintain a python package that also provides additional optional dependencies for developers who would like some extra features.
The basic python package (without the optional dependencies) is supported on python versions 3.10-3.14. The package is a simple statistical model mainly using the standard library.
Now, the optional dependency allows developers to optimize this model and it depends on torch which is not supported on python 3.14 yet. So my situation currently is that the basic package is supported for python versions 3.10-3.14 while the optional dependencies are only supported on python versions 3.10-3.13.
And unfortunately there doesn’t seem to be a way to specify a python version constraint in the pyproject.toml for the optional dependency.
Are there any plans in the future to allow for the specification of compatible python versions with optional dependencies? Something along the lines of
# pyproject.toml
# (...)
# base dependencies
dependencies = ["typing-extensions"]
requires-python = ">=3.10"
[project.optional-dependencies]
optimizer = ["torch", "pandas"]
requires-python = ">=3.10,<3.14" # <- we can't currently do something like this
# (...)
I guess what I’m looking for would be for a developer using python 3.14 to encounter a helpful error message when attempting to install the python3.14-incompatible optional dependencies.
I’d like to block python 3.14 users from installing a specific set of optional dependencies instead of them attempting to install it on their own and getting a hard-to-understand error message.
What do users (or yourself) see when they currently select the optional dependencies on Python 3.14?
They see something like this
(venv) âžś py-fsrs git:(main) python --version
Python 3.14.0
(venv) âžś py-fsrs git:(main) pip install -e ".[optimizer]"
Obtaining file:///Users/joshuahamilton/open-source/py-fsrs
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done
INFO: pip is looking at multiple versions of fsrs[optimizer] to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement torch; extra == "optimizer" (from fsrs[optimizer]) (from versions: none)
ERROR: No matching distribution found for torch; extra == "optimizer"
The error fundamentally comes from torch, not the optional dependency [optimizer]. I’d like for there to be an error similar to if you tried to install a regular old package with an incompatible python version.
This proposal seems like it would introduce more problems than it solves though, at least in the motivating example. What happens once torch supports Python 3.14? The restriction would still be there and unnecessarily obstruct things.
The error messages should be improved. Introducing more complexity would probably make that more difficult and less likely to actually happen.
Upper limits on python versions are a bad idea for 99% of projects; this usecase is one of them. See 100s of messages of previous discussions. (There is a reason e.g. uv just ignores them completely)
Your users just need to learn to read these kinds of error messages and/or pip needs to improve the error messages.
This part torch; extra == "optimizer" comes directly from the distribution metadata, but as you say showing it in this context is misleading, as the extra is referring to the fact that torch is an extra from fsrs not for torch.
I think at the very least pip should remove this from the installation message so it would be:
ERROR: No matching distribution found for torch
I’ve written up a pip issue, please be aware pip is currently an all volunteer project and so requires someone to submit a sufficiently high quality PR to fix. I am working on some Resolution Error messages at the moment but I am unlikely to have time to submit a PR for this.
This proposal seems like it would introduce more problems than it solves
Hmm could I get some examples of the problems it would create?
What happens once torch supports Python 3.14?
Once torch supports python 3.14, I (the maintainer) would loosen the < 3.14 restriction. I don’t actually think this sounds that bad? It’s the maintainers job to juggle dependencies like this, no?
I think at the very least pip should remove this from the installation message so it would be:
ERROR: No matching distribution found for torch
I’m no python package genius, but I think a clearer message might be
ERROR: Optional dependency group [optimizer] not supported in Python 3.14
I’d prefer for the error to reference the optional dependency group rather than one of that group’s packages (in this case torch).
I’ve written up a pip issue, please be aware pip is currently an all volunteer project and so requires someone to submit a sufficiently high quality PR to fix.
This is appreciated
And do let me know if you have other questions/arguments, etc.
Currently there is no infrastructure in pip to determine why a distribution could not be found, and the current design of the distribution collector and resolver means it’s not easy to add. So that would be a big feature request.
My understanding is one of the maintainers does have a long term goal of improving the situation and describing why a distribution couldn’t be found. But I’m a strong believer in fixing small things, and at least removing the confusing part of the message, even if doesn’t achieve the long term goal.