<#21893 pants 2.24.0 KeyErrors on twine publish> I...
# github-notifications
c
#21893 pants 2.24.0 KeyErrors on twine publish Issue created by cburroughs If one tried to publish with twine using 2.24.0, an error along these lines will occur:
Copy code
18:57:04.45 [INFO] Packaged foo-2025.1.30.18.53-py3-none-any.whl
18:57:04.46 [INFO] Starting: Building twine.pex from <resource://pants.backend.python.subsystems/twine.lock>
18:57:04.89 [INFO] Canceled: Building twine.pex from <resource://pants.backend.python.subsystems/twine.lock>
Traceback (most recent call last):
  File "/builds//helios/pants.d/tmp/pants-sandbox-sUKvnU/./.cache/pex_root/venvs/a7cb03317ac112121d5d13ceacd93b5881ed00f9/3bd8dd039b6717ea08ba315fc4068d8debf47674/pex", line 327, in <module>
    module = importlib.import_module(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/builds//.cache/pants/named_caches/pex_root/venvs/s/c44d1bae/venv/lib/python3.11/site-packages/twine/__init__.py", line 43, in <module>
    __license__ = metadata["license"]
                  ~~~~~~~~^^^^^^^^^^^
  File "/builds/.cache/pants/named_caches/pex_root/venvs/s/c44d1bae/venv/lib/python3.11/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'license'
✕ foo-2025.1.30.18.53-py3-none-any.whl failed for <https://gitlab.com/api/v4/projects/27822342345719/packages/pypi>.
This was induced by regenerating the twine lockfile, which picked up a version of
importlib-metadata
that is incompatible with the latest 4.x version of twine`. For further details see: • pypa/twine#977 • pypa/twine#1125 • astral-sh/rye#1180 pantsbuild/pants