Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twine is asking for my password each time : how to use the .pypirc

I have pip installed pypirc and set up a ~/.pypirc file with the requisite password. Why is twine asking for a password each time python setup.py is invoked?

  $twine upload --repository-url https://test.pypi.org/legacy/ dist/*
  Enter your username:

Here is the form of the .pypirc

[distutils] # this tells distutils what package indexes you can push to
index-servers =
  pypi
  pypitest

[pypi]
repository: https://pypi.python.org/pypi
username: myuser 
password: mypwd 

[pypitest]
repository: https://testpypi.python.org/pypi
username: myuser 
password: mypwd 

Update Not including the --repository-url gives:

UploadToDeprecatedPyPIDetected: You're trying to upload to the legacy PyPI site 'https://pypi.python.org/pypi'. Uploading to those sites is deprecated.
 The new sites are pypi.org and test.pypi.org. Try using https://upload.pypi.org/legacy/ (or https://test.pypi.org/legacy/) to upload your packages instead. These are the default URLs for Twine now.
 More at https://packaging.python.org/guides/migrating-to-pypi-org/ .
like image 431
WestCoastProjects Avatar asked Sep 14 '19 11:09

WestCoastProjects


People also ask

What is .pypirc file?

pypirc file. A . pypirc file allows you to define the configuration for package indexes (referred to here as “repositories”), so that you don't have to enter the URL, username, or password whenever you upload a package with twine or flit.

Where do I put .pypirc file?

pypirc location on windows. Your . pypirc file on windows should be in your $HOME directory.


2 Answers

twine upload dist/*

or

twine upload -r pypi dist/*

or

twine upload -r pypitest dist/*

As far as I understand twine --repository-url <url> doesn't even consult ~/.pypirc. With -r <name> it lookups ~/.pypirc for the URL, user name and password. If you omit -r <name>, twine uses the first repo from ~/.pypirc.

like image 191
phd Avatar answered Oct 07 '22 19:10

phd


Method 1:

python -m twine upload  dist/* -u%username% -p%password%

you can

set username="token"

set password="pypi-AgEIc..."

OR

set username=pypi name

set password=pypi password

like image 30
wen he Avatar answered Oct 07 '22 18:10

wen he