Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'home-page' with importlib_metadata 8.0.0 #1125

Closed
1 task done
FeodorFitsner opened this issue Jun 25, 2024 · 16 comments
Closed
1 task done

KeyError: 'home-page' with importlib_metadata 8.0.0 #1125

FeodorFitsner opened this issue Jun 25, 2024 · 16 comments
Labels

Comments

@FeodorFitsner
Copy link

Is there an existing issue for this?

  • I have searched the existing issues (open and closed), and could not find an existing issue

What keywords did you use to search existing issues?

No response

What operating system are you using?

Linux

If you selected 'Other', describe your Operating System here

No response

What version of Python are you running?

Python 3.10.13

How did you install twine? Did you use your operating system's package manager or pip or something else?

pip install twine

What version of twine do you have installed (include the complete output)

5.1.0

Which package repository are you using?

pypi.org

Please describe the issue that you are experiencing

importlib_metadata has just released 8.0.0 and CI jobs calling twine upload started failing with the following error:

Traceback (most recent call last):
  File "/home/appveyor/venv3.10.13/bin/twine", line 5, in <module>
    from twine.__main__ import main
  File "/home/appveyor/venv3.10.13/lib/python3.10/site-packages/twine/__init__.py", line 40, in <module>
    __uri__ = metadata["home-page"]
  File "/home/appveyor/venv3.10.13/lib/python3.10/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'home-page'

Please list the steps required to reproduce this behaviour

pip install --upgrade setuptools wheel twine poetry tomlkit virtualenv

Anything else you'd like to mention?

No response

@gesslerpd
Copy link

gesslerpd commented Jun 25, 2024

See #1124

@jykr
Copy link

jykr commented Jun 25, 2024

Would be helpful to have twine 5.1.0 yanked from pypi to prevent CI's relying on twine being broken, until bug gets fixed

@henryiii
Copy link
Contributor

henryiii commented Jun 25, 2024

Why does 5.0 work? Was the bug added to 5.1 just before importlib-metadata 8 was released? I was about to reply that it didn't have anything to do with 5.1 but checked it and it seems 5.0 works with importlib-metadata 8 (I assume).

I don't see the __init__.py file even being touched: 5.0.0...5.1.0. But the environment clearly does have importlib-metadata 8.0 and it works for me.

@henryiii
Copy link
Contributor

Ahh, I see it; it's due to the modernization of the build system, and the new build system doesn't set home-page (it's triggering on twine itself!), but it happened to pass due to importlib-metadata returning None here instead of erroring before 8.0.

So yes, yanking 5.1 while waiting for 5.1.1 would be a temporary fix. You can also set !=5.1.0 in your CI's, like pipx run 'twine!=5.1.0'.

@jaraco
Copy link
Member

jaraco commented Jun 25, 2024

This issue isn't due to a release of twine but due to a release of importlib-metadata 8. See #977 where the deprecation warning was detected and reported.

copybara-service bot pushed a commit to google/vizier that referenced this issue Jun 25, 2024
copybara-service bot pushed a commit to google/vizier that referenced this issue Jun 25, 2024
copybara-service bot pushed a commit to google/vizier that referenced this issue Jun 25, 2024
copybara-service bot pushed a commit to google/vizier that referenced this issue Jun 25, 2024
@arcivanov
Copy link

Just bumped into this as well!

@Clivern
Copy link

Clivern commented Jun 25, 2024

Same here!

copybara-service bot pushed a commit to google/vizier that referenced this issue Jun 25, 2024
@arcivanov
Copy link

Please yank the offending version - this is breaking all sorts of builds due to twine check crashing.

@teej
Copy link

teej commented Jun 25, 2024

Just ran into this. For those looking for a quick fix, I changed my twine dependency to twine!=5.1.0, rebuilt my dev venv, and that worked for me.

Thanks @henryiii

@tipabu
Copy link

tipabu commented Jun 25, 2024

This issue isn't due to a release of twine but due to a release of importlib-metadata 8.

I have to push back on this -- from a fresh py312 venv:

$ pip install 'twine<5.1'
Collecting twine<5.1
  Using cached twine-5.0.0-py3-none-any.whl.metadata (3.3 kB)
...
Successfully installed Pygments-2.18.0 SecretStorage-3.3.3 certifi-2024.6.2 cffi-1.16.0 charset-normalizer-3.3.2 cryptography-42.0.8 docutils-0.21.2 idna-3.7 importlib-metadata-8.0.0 jaraco.classes-3.4.0 jaraco.context-5.3.0 jaraco.functools-4.0.1 jeepney-0.8.0 keyring-25.2.1 markdown-it-py-3.0.0 mdurl-0.1.2 more-itertools-10.3.0 nh3-0.2.17 pkginfo-1.11.1 pycparser-2.22 readme-renderer-43.0 requests-2.32.3 requests-toolbelt-1.0.0 rfc3986-2.0.0 rich-13.7.1 twine-5.0.0 urllib3-2.2.2 zipp-3.19.2
$ twine -h
usage: twine [-h] [--version] [--no-color] {check,upload,register}
...

i.e. even with importlib-metadata-8.0.0, twine would still work, because the 5.0.0 package included the home-page metadata twine itself is looking for. But if I upgrade it:

$ pip install -U 'twine'
Requirement already satisfied: twine in ./venv/lib/python3.12/site-packages (5.0.0)
Collecting twine
  Using cached twine-5.1.0-py3-none-any.whl.metadata (3.4 kB)
Requirement already satisfied: pkginfo>=1.8.1 in ./venv/lib/python3.12/site-packages (from twine) (1.11.1)
Requirement already satisfied: readme-renderer>=35.0 in ./venv/lib/python3.12/site-packages (from twine) (43.0)
Requirement already satisfied: requests>=2.20 in ./venv/lib/python3.12/site-packages (from twine) (2.32.3)
Requirement already satisfied: requests-toolbelt!=0.9.0,>=0.8.0 in ./venv/lib/python3.12/site-packages (from twine) (1.0.0)
Requirement already satisfied: urllib3>=1.26.0 in ./venv/lib/python3.12/site-packages (from twine) (2.2.2)
Requirement already satisfied: importlib-metadata>=3.6 in ./venv/lib/python3.12/site-packages (from twine) (8.0.0)
Requirement already satisfied: keyring>=15.1 in ./venv/lib/python3.12/site-packages (from twine) (25.2.1)
Requirement already satisfied: rfc3986>=1.4.0 in ./venv/lib/python3.12/site-packages (from twine) (2.0.0)
Requirement already satisfied: rich>=12.0.0 in ./venv/lib/python3.12/site-packages (from twine) (13.7.1)
Requirement already satisfied: zipp>=0.5 in ./venv/lib/python3.12/site-packages (from importlib-metadata>=3.6->twine) (3.19.2)
Requirement already satisfied: jaraco.classes in ./venv/lib/python3.12/site-packages (from keyring>=15.1->twine) (3.4.0)
Requirement already satisfied: jaraco.functools in ./venv/lib/python3.12/site-packages (from keyring>=15.1->twine) (4.0.1)
Requirement already satisfied: jaraco.context in ./venv/lib/python3.12/site-packages (from keyring>=15.1->twine) (5.3.0)
Requirement already satisfied: SecretStorage>=3.2 in ./venv/lib/python3.12/site-packages (from keyring>=15.1->twine) (3.3.3)
Requirement already satisfied: jeepney>=0.4.2 in ./venv/lib/python3.12/site-packages (from keyring>=15.1->twine) (0.8.0)
Requirement already satisfied: nh3>=0.2.14 in ./venv/lib/python3.12/site-packages (from readme-renderer>=35.0->twine) (0.2.17)
Requirement already satisfied: docutils>=0.13.1 in ./venv/lib/python3.12/site-packages (from readme-renderer>=35.0->twine) (0.21.2)
Requirement already satisfied: Pygments>=2.5.1 in ./venv/lib/python3.12/site-packages (from readme-renderer>=35.0->twine) (2.18.0)
Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.12/site-packages (from requests>=2.20->twine) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.12/site-packages (from requests>=2.20->twine) (3.7)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.12/site-packages (from requests>=2.20->twine) (2024.6.2)
Requirement already satisfied: markdown-it-py>=2.2.0 in ./venv/lib/python3.12/site-packages (from rich>=12.0.0->twine) (3.0.0)
Requirement already satisfied: mdurl~=0.1 in ./venv/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich>=12.0.0->twine) (0.1.2)
Requirement already satisfied: cryptography>=2.0 in ./venv/lib/python3.12/site-packages (from SecretStorage>=3.2->keyring>=15.1->twine) (42.0.8)
Requirement already satisfied: more-itertools in ./venv/lib/python3.12/site-packages (from jaraco.classes->keyring>=15.1->twine) (10.3.0)
Requirement already satisfied: cffi>=1.12 in ./venv/lib/python3.12/site-packages (from cryptography>=2.0->SecretStorage>=3.2->keyring>=15.1->twine) (1.16.0)
Requirement already satisfied: pycparser in ./venv/lib/python3.12/site-packages (from cffi>=1.12->cryptography>=2.0->SecretStorage>=3.2->keyring>=15.1->twine) (2.22)
Using cached twine-5.1.0-py3-none-any.whl (38 kB)
Installing collected packages: twine
  Attempting uninstall: twine
    Found existing installation: twine 5.0.0
    Uninstalling twine-5.0.0:
      Successfully uninstalled twine-5.0.0
Successfully installed twine-5.1.0
$ twine -h
Traceback (most recent call last):
  File ".../venv/bin/twine", line 5, in <module>
    from twine.__main__ import main
  File ".../venv/lib/python3.12/site-packages/twine/__init__.py", line 40, in <module>
    __uri__ = metadata["home-page"]
              ~~~~~~~~^^^^^^^^^^^^^
  File ".../venv/lib/python3.12/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
    raise KeyError(item)
KeyError: 'home-page'

@henryiii
Copy link
Contributor

5.1.0 stated relying on the fact that metadata["home-page"] was returning None and producing a (hidden) deprecation warning. That's why installing 5.0.0 fixes it or installing importlib-metadata 7 fixes it.

nijel added a commit to WeblateOrg/weblate that referenced this issue Jun 26, 2024
This reverts commit 4505c9b.

It has been yanked because of pypa/twine#1125
@marcinmilewski1
Copy link

marcinmilewski1 commented Jun 26, 2024

I can confirm this issue is with twine==4.0.2 too. It can be fixed by forcing importlib-metadata==7.2.1 installation.

mergify bot pushed a commit to aws/jsii that referenced this issue Jun 26, 2024
Twine 5.1.0 has been yanked (removed) due to the issue described in pypa/twine#1125

This PR reverts the `requirements-dev.txt` file used by `jsii-pacmak` back to `twine~=5.0.0`.
@jaraco
Copy link
Member

jaraco commented Jun 26, 2024

Twine 5.1.1 was just released. I'm assuming this issue is addressed, but please don't hesitate to report if the issues aren't addressed.

@jaraco jaraco closed this as completed Jun 26, 2024
lhelwerd added a commit to grip-on-software/data-gathering that referenced this issue Jun 28, 2024
To avoid potential issue in pypa/twine#1125
mccalluc pushed a commit to opendp/opendp that referenced this issue Jul 11, 2024
Closes #1765: see
https://github.com/pypa/cibuildwheel/releases/tag/v2.19.2 (specifically
cibuildwheel 1917)
Closes #1766: see pypa/twine#1125
Closes #1758: whitelist .pyd. See
https://docs.python.org/3/faq/windows.html#is-a-pyd-file-the-same-as-a-dll


To verify, the dev build runs smoothly:
https://github.com/opendp/opendp/actions/runs/9881705627

I also pip-installed the above pre-release on a Windows computer and
verified that the package runs smoothly.
tomchristie added a commit to encode/httpx that referenced this issue Jul 23, 2024
Update `twine` to resolve build failures.

pypa/twine#1125
nicholaslourie added a commit to nicholaslourie/opda that referenced this issue Aug 1, 2024
Packaging opda with importlib_metadata 8.0.0 and twine 4.0.2 raises
an exception: "KeyError: 'license'". The exception results from a
change in importlib_metadata where requesting missing metadata used
to return None but now raises a KeyError. Upgrading twine to 5.1.1
resolves the issue.

For more information, see pypa/twine#977
which discusses the missing license metadata in twine 4.0.2, and
see pypa/twine#1125 for how the release
of importlib_metadata 8.0.0 triggered the issue.
lopuhin added a commit to zytedata/clear-html that referenced this issue Aug 18, 2024
marcelbarbulescu added a commit to marcelbarbulescu/otf-api that referenced this issue Sep 23, 2024
The locked version 5.1.0 for twine is a yanked version. Reason for being yanked: pypa/twine#1125
marcelbarbulescu added a commit to marcelbarbulescu/otf-api that referenced this issue Sep 23, 2024
The locked version 5.1.0 for twine is a yanked version. Reason for being yanked: pypa/twine#1125
edeno added a commit to LorenFrankLab/spyglass that referenced this issue Oct 23, 2024
CBroz1 pushed a commit to LorenFrankLab/spyglass that referenced this issue Oct 23, 2024
* Increase upper bound of python to include 3.12

* Add tests for different python versions

* Minor formatting

* Use quotes for version to avoid parsing errors

* Ensure build dependencies are installed

distutils was removed for python 3.12

* Add more build dependencies

* Try different resources

* Temp test on <3.12

* Remove importlib_metadata pin

Fixed in twine pypa/twine#1125

* Revert "Temp test on <3.12"

This reverts commit 5b27366.

* Change install order of build dependencies

* Remove numpy pin

* Update CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests