python / importlib_metadata

Library to access metadata for Python packages
https://importlib-metadata.readthedocs.io
Apache License 2.0
122 stars 79 forks source link

importlib metadata 8.0 causes unusual errors in startup for twine, others(?) #492

Closed zzzeek closed 4 weeks ago

zzzeek commented 1 month ago

Using any python interpreter, here I use podman to run the "python" docker container to get a clean environment, install "twine". Then run from the command line. it fails. downgrade importlib-metadata<8.0, works again.

$ podman run -it  python bash
# pip install twine
# twine
Traceback (most recent call last):
  File "/usr/local/bin/twine", line 5, in <module>
    from twine.__main__ import main
  File "/usr/local/lib/python3.12/site-packages/twine/__init__.py", line 40, in <module>
    __uri__ = metadata["home-page"]
              ~~~~~~~~^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'home-page'

downgrade importlib-metadata:

# pip install "importlib_metadata<8.0"
Collecting importlib_metadata<8.0

error goes away:

# twine
usage: twine [-h] [--version] [--no-color] {upload,register,check}
twine: error: the following arguments are required: command, args
otaviocv commented 1 month ago

Just observed this issue.

alex commented 1 month ago

Looks like this is because of https://github.com/python/importlib_metadata/pull/491

It seems like this was intentional and I guess twine should be updated for it.

dhalbert commented 1 month ago

I am also here due to the incompatibility with twine. I'm a little confused about the versioning. https://pypi.org/project/importlib-metadata/ has 8.0.0, but the last github release showing here at this writing is 7.2.1. There is an 8.0.0 tag, though. I got here too late to see whether 8.0.0 ever existed as a github release, or whether it was deleted. But the pypi 8.0.0 isn't yanked.

FFY00 commented 1 month ago

twine==5.1.0 seems to be yanked, so to reproduce the install command needs to be changed to pip install twine==5.1.0.

I was able to confirm the deprecation warnings were being issued, so it seems this should be fixed in twine.

$ PYTHONWARNINGS=always twine
/usr/local/lib/python3.12/site-packages/twine/__init__.py:40: DeprecationWarning: Implicit None on return values is deprecated and will raise KeyErrors.
  __uri__ = metadata["home-page"]
/usr/local/lib/python3.12/site-packages/twine/__init__.py:42: DeprecationWarning: Implicit None on return values is deprecated and will raise KeyErrors.
  __author__ = metadata["author"]
usage: twine [-h] [--version] [--no-color] {upload,check,register}
twine: error: the following arguments are required: command, args

I am also here due to the incompatibility with twine. I'm a little confused about the versioning. pypi.org/project/importlib-metadata has 8.0.0, but the last github release showing here at this writing is 7.2.1. There is an 8.0.0 tag, though. I got here too late to see whether 8.0.0 ever existed as a github release, or whether it was deleted. But the pypi 8.0.0 isn't yanked.

8.0.0 isn't listed on the readme yet because it hasn't be synchronized with the Python upstream, so there's no equivalent importlib.metadata version yet (it'll be 3.14, but not sure if will be synchronized with 8.0.0 or a newer release).

dhalbert commented 4 weeks ago

twine yanked 5.1.0 and released 5.1.1 to fix this problem. Ref: https://github.com/pypa/twine/issues/1125

jaraco commented 4 weeks ago

Sorry for the disruption. Yes, the automated release of 8.0.0 failed due to the incompatibility with twine, which I was able to get fixed. I would have fixed it faster, but the twine review/release process is slow and requires two people and I was the only person actively working on it, and there was already outstanding breakage from unrelated issues blocking CI and automated releases. I was able to work around the release limitation coincidentally because there was already a 5.1.1 release drafted that I was able to amend.

I considered yanking importlib_metadata 8 also, but since the breakage was by design and the issue could be worked around by yanking a single version of the affected project, I chose that route instead.

The reason the github release is missing for the 8.0 tag is because the automated release process failed and I manually uploaded the release. I've created the github release now for consistency:

 importlib_metadata main @ git-id
f3901686ab
 importlib_metadata main @ .tox/release/bin/python -m jaraco.develop.create-github-release