pypa / twine

Utilities for interacting with PyPI
https://twine.readthedocs.io/
Apache License 2.0
1.59k stars 305 forks source link

Issue with Travis CI and twine upload #1113

Closed lemoustachiste closed 3 months ago

lemoustachiste commented 3 months ago

Is there an existing issue for this?

What keywords did you use to search existing issues?

twine travis keyring (backend)

What operating system(s) are you using?

Linux

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

No response

What version of Python are you running?

3.10.14

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

pip install semantic-release twine 

and subsequently trying to fix twine version to 5.0.0, no change so I assume the issue is not directly with twine.

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

5.1.0

It's in Travis CI so not too straighforward to gather more information (but doable).

Which package repository are you using?

https://upload.pypi.org/legacy/

Please describe the issue that you are experiencing

When getting to twine upload step, my CI build stalls because of the following error:

Enter your API token: [33mWARNING  Error getting password from keyring                                    

         Traceback (most recent call last):                                     

           File                                                                 

         "/home/travis/virtualenv/python3.10.14/lib/python3.10/site-packages/twi

         ne/auth.py", line 81, in get_password_from_keyring                     

             return cast(str, keyring.get_password(system, username))           

           File                                                                 

         "/home/travis/virtualenv/python3.10.14/lib/python3.10/site-packages/key

         ring/core.py", line 56, in get_password                                

             return get_keyring().get_password(service_name, username)          

           File                                                                 

         "/home/travis/virtualenv/python3.10.14/lib/python3.10/site-packages/key

         ring/backends/fail.py", line 28, in get_password                       

             raise NoKeyringError(msg)                                          

         keyring.errors.NoKeyringError: No recommended backend was available.   

         Install a recommended 3rd party backend package; or, install the       

         keyrings.alt package if you want to use the non-recommended backends.  

         See https://pypi.org/project/keyring for details.  

Until know my twine username and password were set as ENV variables, but I guess there has been a change in configuration but I don't know how to address the change. Could you point me to any sort of documentation or the right direction?

Thanks

Please list the steps required to reproduce this behaviour

This is what's being run: https://github.com/blockchain-certificates/cert-schema/blob/master/release_package.sh

Please include the PKG-INFO file contents from the artifact you're attempting to upload

https://pypi.org/project/cert-schema/

A redacted version of your .pypirc file

no pypirc in the project

Anything else you'd like to mention?

I'm sorry my main strength is not Python world

sigmavirus24 commented 3 months ago

Username and password are no longer supported by PyPI. Please configure a token for your project and set that appropriately by reading our documentation and updating your Travis CI configuration.

lemoustachiste commented 3 months ago

Thanks for your answer.

I was pretty sure I had already set the token way of enabling upload, nonetheless I went ahead and created a new token for that specific package.

As per the documentation (https://twine.readthedocs.io/en/stable/index.html#twine-upload) I'm setting the environment variables (https://app.travis-ci.com/github/blockchain-certificates/cert-schema/builds/270618825#L180) TWINE_USERNAME to token and the TWINE_PASSWORD to the token value.

However the issue remains (https://app.travis-ci.com/github/blockchain-certificates/cert-schema/builds/270618825#L830).

My last automated release was in March this year so the only thing I thought had changed is that keyring is now on version 25.x. However fixing the version to 24.3.1 (https://app.travis-ci.com/github/blockchain-certificates/cert-schema/builds/270618825#L273) does not seem to solve the issue.

I don't want to create unnecessary noise on this repo if it's not the culprit, so in your opinion is the problem with Twine, Travis or Keyring (or the three of them)?

Thanks again

PS: I've manually published to the newer version as I need to move forward on other front but I still would like to fix the automated release issue.

lemoustachiste commented 3 weeks ago

I'm still facing this issue, this time with another package, still in Travis CI.

I have followed the docs that is directly linked from Pypi: https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives

I have looked again at the twine doc for upload which states (https://twine.readthedocs.io/en/stable/#twine-upload):

  -u USERNAME, --username USERNAME
                        The username to authenticate to the repository
                        (package index) as. (Can also be set via
                        TWINE_USERNAME environment variable.)
  -p PASSWORD, --password PASSWORD
                        The password to authenticate to the repository
                        (package index) with. (Can also be set via
                        TWINE_PASSWORD environment variable.)

With the conjunction of the 2 docs, I have created a TWINE_USERNAME of __token__ and copied the pypi recreated for the scope of the new project in the TWINE_PASSWORD.

I've tried to disable keyring as indicated here: https://twine.readthedocs.io/en/latest/index.html#disabling-keyring, but now the build just stalls asking me to enter the token.

I don't mind reading the docs, but in this case they don't help and I'm quite stuck...