Twine upload fails with “license-expression introduced in metadata version 2.4, not 2.3” for wheel uploaded to Nexus PyPI repo

Hello,

I ran into an issue while uploading a Python wheel to a Nexus Repository PyPI repository and I’m trying to understand whether others have seen the same thing and how you handled it.

Command used:

python3 -m twine upload -u "****" -p "****" --repository-url "http://****:8081/repository/pypi-proxy/" "packages/pypi-proxy/docker-7.1.0-py3-none-any.whl"

Output:

/usr/lib/python3/dist-packages/requests/__init__.py:87: RequestsDependencyWarning: urllib3 (2.6.3) or chardet (4.0.0) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Uploading distributions to http://****:8081/repository/pypi-proxy/
ERROR    InvalidDistribution: Invalid distribution metadata: license-expression introduced in metadata version 2.4, not 2.3

After checking the wheel metadata, I found this:

Metadata-Version: 2.3
License-Expression: Apache-2.0
License-File: LICENSE

My workaround:

curl -u ****:****   -F "pypi.asset=@packages/pypi-proxy/docker-7.1.0-py3-none-any.whl"   "http://****:8081/service/rest/v1/components?repository=pypi-proxy"

Has anyone seen this same problem with Nexus / Twine / PyPI uploads?
Is there any Nexus-side recommendation for handling upstream wheels that have inconsistent Python metadata?

Best regards,

Niko

The error message suggests that Twine believes your package metadata is declaring a particular manifest version, but using fields from a newer version.

1 Like

WORKAROUND:
It works with pinned versions “twine==5.0.0” “pkginfo==1.12.1.2”.