PyPi .pypirc file location on Windows

This blog post describes where you should put your PyPi .pypirc file on windows and what it typically wants to include.

Uses of the PyPi .pypirc file

The main use of the pypi.rc file is to store your PyPi settings used to upload new Python packages.

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.

PyPi .pypirc location on windows

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

On windows this is typically your user folder under C:\Users\. For example my current home folder for the user Chewett is C:\Users\Chewett\

This means that my .pypirc file should live at C:\Users\Chewett\.pypirc.

Typical PyPi .pypirc file contents

Typically the PyPi file will include information for the pypi and testpypi server. If you have a token for each of these your file will look something like this

[distutils]
index-servers =
    pypi
    testpypi

[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = <PyPI token>

[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = <PyPI token>

Here the settings for pypi and testpypi are configured and you can place your token. This file will be read when uploading to pypi and means you wont need to paste in your token or password each time.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.