Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pypi upload without a .pypirc?

This thing drives me nuts. Isn't it possible to simply do something like below?

python setup.py sdist upload --username me --password 1234

Or be promped to enter a password with:

python setup.py sdist upload --username me

Being forced to use my password in clear text in a configuration file goes against everything I ever learned about security. Also not being able to manually enter a username and a password is user unfriendly.

Are Python folks from an other universe? Is there a reason they try to make our lives hard?

like image 247
Pithikos Avatar asked Mar 30 '15 16:03

Pithikos


People also ask

What is a pypirc file used for?

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. The format (originally defined by the distutils package) is:

How to upload packages to a PyPI server as a proxy?

If you are using a custom PyPI server as a proxy and want to upload some packages there, it’s not easy. For each package, you need to download its source and upload it using setup.py script: You could also download the packages directly into the PyPI’s index directory. If there’s more than one package, you could use a requirements file.

How to publish a package on PyPI?

In order to publish a package on PyPI you have to create an account. You can do so by visiting this link. It’s completely free and to sign up you just need to provide your e-mail address, a username and password. Finally, we’ll now use twine in order to upload the created source distribution on PyPI.

How do I download multiple PyPI packages at once?

For each package, you need to download its source and upload it using setup.py script: You could also download the packages directly into the PyPI’s index directory. If there’s more than one package, you could use a requirements file. But it’s still too much. You should be able to do it with one command.


1 Answers

You can use Twine instead of setup.py for uploading. This has a number of other advantages. In particular, you can test the files before you upload them. It is invoked like this:

twine upload --username me --password hunter2 dist/whatever.whl

Please note that putting a password on the command line is dangerous. It will likely be recorded in ~/.bash_history, or your shell's equivalent.

like image 64
Kevin Avatar answered Oct 05 '22 07:10

Kevin