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

twine upload to testpypi hangs #847

Closed
shuklak13 opened this issue Dec 30, 2021 · 10 comments
Closed

twine upload to testpypi hangs #847

shuklak13 opened this issue Dec 30, 2021 · 10 comments
Labels
support Users asking for help using twine

Comments

@shuklak13
Copy link

Your Environment

  1. Your operating system: Debian

  2. Version of python you are running: 3.9

  3. How did you install twine? pip

  4. Version of twine you have installed (include complete output of): twine version 3.4.1 (importlib_metadata: 4.5.0, pkginfo: 1.7.0, requests: 2.25.1, requests-toolbelt: 0.9.1, tqdm: 4.61.1)

  5. Which package repository are you targeting? https://test.pypi.org/project/model_card_toolkit

If you're having issues uploading a specific package, you must include a copy of the following:

  • The package's PKG-INFO file
  • A redacted version of your .pypirc file (REMOVE ALL USERNAMES & PASSWORDS BEFORE UPLOADING)

PKG-INFO: https://gist.github.com/shuklak13/0150db1afcbd11e531e3f365b4e3a662
.pypirc: I did not find a .pypirc in my environment or my project.

The Issue

When executing python3 -m twine upload --repository testpypi dist/*, the message Uploading distributions to https://test.pypi.org/legacy/ will display. The terminal then hangs, and does not display any further prompts. I manually killed it after one hour.

Steps to Reproduce

This issue occurs when I run the following commands:

  1. python3 setup.py sdist bdist_wheel
  2. python3 -m twine upload --repository testpypi dist/*
@sigmavirus24
Copy link
Member

The terminal then hangs, and does not display any further prompts. I manually killed it after one hour.

What is the traceback when you killed it? That could give us a clue. I have a suspicion but I don't want to poison the well :D

@bhrutledge
Copy link
Contributor

@shuklak13 Can you also re-try the upload with the --verbose option, and copy & paste the output into a comment?

IE: python3 -m twine upload --verbose --repository testpypi dist/*

@shuklak13
Copy link
Author

Thanks for the suggestions. Here is the terminal output from python3 -m twine upload --verbose --repository testpypi dist/*:

Using configuration from /usr/local/home/karanshukla/.pypirc
Uploading distributions to https://test.pypi.org/legacy/
  dist/model_card_toolkit-1.1.1.dev0-py3-none-any.whl (65.5 KB)
  dist/model-card-toolkit-1.1.1.dev0.tar.gz (48.3 KB)

And here is the traceback:

^CTraceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/__main__.py", line 53, in <module>
    sys.exit(main())
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/__main__.py", line 28, in main
    result = cli.dispatch(sys.argv[1:])
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/cli.py", line 71, in dispatch
    return main(args.args)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/commands/upload.py", line 154, in main
    return upload(upload_settings, parsed_args.dists)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/commands/upload.py", line 91, in upload
    repository = upload_settings.create_repository()
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/settings.py", line 345, in create_repository
    self.username,
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/settings.py", line 146, in username
    return cast(Optional[str], self.auth.username)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/auth.py", line 35, in username
    return utils.get_userpass_value(
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/utils.py", line 241, in get_userpass_value
    return prompt_strategy()
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/auth.py", line 79, in username_from_keyring_or_prompt
    username = self.get_username_from_keyring()
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/twine/auth.py", line 59, in get_username_from_keyring
    creds = keyring.get_credential(system, None)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/keyring/core.py", line 72, in get_credential
    return get_keyring().get_credential(service_name, username)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/keyring/backends/SecretService.py", line 119, in get_credential
    collection = self.get_preferred_collection()
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/keyring/backends/SecretService.py", line 65, in get_preferred_collection
    collection.unlock()
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/secretstorage/collection.py", line 67, in unlock
    return unlock_objects(self.connection, [self.collection_path])
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/secretstorage/util.py", line 153, in unlock_objects
    dismissed, (signature, unlocked) = exec_prompt(connection, prompt)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/secretstorage/util.py", line 139, in exec_prompt
    dismissed, result = connection.recv_until_filtered(signals).body
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/jeepney/io/blocking.py", line 181, in recv_until_filtered
    self.recv_messages(timeout=deadline_to_timeout(deadline))
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/jeepney/io/blocking.py", line 116, in recv_messages
    msg = self.receive(timeout=timeout)
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/jeepney/io/blocking.py", line 101, in receive
    b = self._read_some_data(timeout=deadline_to_timeout(deadline))
  File "/usr/local/home/karanshukla/.local/lib/python3.9/site-packages/jeepney/io/blocking.py", line 105, in _read_some_data
    for key, ev in self.selector.select(timeout):
  File "/usr/lib/python3.9/selectors.py", line 469, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt

@bhrutledge
Copy link
Contributor

Thanks! At first glance, it seems like is stuck getting credentials via keyring. Can you provide any details on if/how you have that configured? Here's the relevant twine docs: https://twine.readthedocs.io/en/stable/#keyring-support.

It also looks like --verbose could be more helpful by indicating that where it's reading credentials from, before blocking.

cc: @jaraco

@shuklak13
Copy link
Author

I wasn't familiar with keyring. In the past, uploading to twine from the terminal prompted me for username and password, so I guess my keyring was configured by someone else.

To debug, I tried running keyring get https://upload.pypi.org/legacy/ <my-username> but the terminal hung, and killing the execution returned the same traceback as above (starting with "SecretService.py", line 65, in get_preferred_collection). So I can confirm that my keyring is failing.

Here's my understanding of what is happening:

  1. twine calls keyring to manage username/password
  2. keyring handles username/password via the secretstorage module's Collection object. Specifically, it calls Collection.unlock().
  3. For some reason,secretstorage's Collection.unlock() is blocking.

I've opened up this issue in the secretstorage repo.

@bhrutledge
Copy link
Contributor

@shuklak13 Did you try disabling keyring? https://twine.readthedocs.io/en/stable/#disabling-keyring

@bhrutledge bhrutledge added the support Users asking for help using twine label Dec 30, 2021
@shuklak13
Copy link
Author

Thank you Brian! Disabling keyring reverted twine to the previous behavior, and I was able to successfully upload to testpypi.

@bhrutledge
Copy link
Contributor

@shuklak13 That's great. Out of curiosity, your original description states:

.pypirc: I did not find a .pypirc in my environment or my project.

However, the output of upload --verbose shows:

Using configuration from /usr/local/home/karanshukla/.pypirc

Can you share the contents of that file (w/ password redacted, of course)?

@shuklak13
Copy link
Author

That's strange - I don't see a /usr/local/home/karanshukla/.pypirc in my file system. I'm not sure why that message occurs.

@bhrutledge
Copy link
Contributor

That is strange; the log message should only show up if the file was read successfully:

twine/twine/utils.py

Lines 60 to 67 in d82cd00

try:
with open(realpath) as f:
parser.read_file(f)
logger.info(f"Using configuration from {realpath}")
except FileNotFoundError:
# User probably set --config-file, but the file can't be read
if path != DEFAULT_CONFIG_FILE:
raise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Users asking for help using twine
Projects
None yet
Development

No branches or pull requests

3 participants