uv: `setuptools` fails with "Invalid dash-separated key" or "Invalid uppercase key"
setuptools v78 no longer accepts options containing uppercase or dash characters in setup.cfg. This means if your package uses this feature, or if any of your dependencies need to be built from source (and are using the invalid syntax) then an error will be raised.
This can be worked around in the uv CLI by excluding new versions:
$ uv sync --exclude-newer 2025-03-24
This fix can be persisted in the pyproject.toml as:
[tool.uv]
exclude-newer = "2025-03-24T00:00:00Z"
Note this will prevent upgrading other packages.
If you are using uv pip, you can set a build constraint instead:
echo "setuptools<78" | uv pip install -b - <package>
This fix can be persisted in the pyproject.toml as:
[tool.uv]
build-constraint-dependencies = ["setuptools<78"]
There is an unrelated uv bug that does not propagate build-constraint-dependencies in uv sync (https://github.com/astral-sh/uv/issues/12441). We will be releasing a fix for that soon.
I’ve asked for the change to be reverted upstream at https://github.com/pypa/setuptools/pull/4870#issuecomment-2748731521
We’re also adding a dedicated warning for this error case in https://github.com/astral-sh/uv/pull/12438
See also
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 25
- Comments: 15 (4 by maintainers)
Unfortunately
exclude-newerwill refuse to install packages that have no upload date specified, which of course, happens to include popular public packages 🤦It has been a Python packaging standard to seperate out build dependencies from runtime dependencies for years now, generally it has solved a lot more problems than it has created, all modern packaging tools I am aware of support it.
It was defined in https://peps.python.org/pep-0517/ and discussion about problems it has and solutions to those problems should be discussed over at https://discuss.python.org/c/packaging/14
Hi everyone, 20 minutes ago setuptools added a new package that postpones this change:
https://setuptools.pypa.io/en/stable/history.html
Anyway, it would be better if uv used the same setuptools in the env when installed
Also hitting the limitation with
exclude-newer. It would be great to have a flag to ignore this constraint for packages that don’t publish version data.Yes, getting the same one for torch==2.3.0