Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not store password in .pypirc?

Tags:

python

pypi

I'm trying to set up a private Pypi cloud using CloudPypi. And I really don't want store my password in .pypirc. I want to be prompt to type in my password every time I upload a package.

In Python document about .pypirc, it says:

password, that will be used to authenticate. If omitted the user will be prompt to type it when needed.

But how do you "omit" the password here? I tried leaving the password line blank, tried do "password : " or "password : password". None of these works.

like image 206
F Zhu Avatar asked Apr 13 '16 21:04

F Zhu


People also ask

What is a pypirc file and where can I find it?

Primarily it is used to store your private token to be used when uploading packages. This means you can easily keep it in one secure place and don’t need to keep retrieving it or typing your password in. Your .pypirc file on windows should be in your $HOME directory.

How to protect passwords in Python?

An alternative way to protecting passwords in Python is hashing. This can be useful if you’re dealing with storing many passwords, such as credentials to a web application (e.g. Flask or Django ).

How do I find the username and password of a PyPI server?

[global] index = https://username:[email protected]/pypi index-url = https://username:[email protected]/simple cert = /etc/ssl/certs/ca-certificates.crt For each url you'll need each time to specify the same username and password. Username and password become visible in the logs, cause they are part of the url.

How do I retrieve the password of a service in Python?

To retrieve the password, we just need to use the get_password method with the “servicename” value and username. Once we’ve set the password, it remains stored by our operating system – so if you start a new Python session, you’ll be able to retrieve it just the same.


1 Answers

You omit the entire line completely:

[distutils]
index-servers =
    pypi

[pypi]
repository: <repository-url>
username: <username>

This has been tested on Python 3.6.2 and pip 9.0.1

like image 165
Dominic K Avatar answered Nov 01 '22 10:11

Dominic K