.pypirc is a configuration file that stores information about Python packages repositories. It should be located in your home directory. The format for this file is as follows:
[distutils]
index-servers =
pypi
other
[pypi]
repository: <repository-url>
username: <username>
password: <password>
[other]
repository: https://example.com/pypi
username: <username>
password: <password>
The distutils section should have the index-servers variable that lists all sections describing all the available repositories and credentials for them. There are only the following three variables that can be modified for each repository section:
- repository: This is the URL of the package repository (it defaults to https://pypi.org/).
- username: This is the username for authentication in the given repository.
- password: This is the user password for authentication in the given repository (in plain text).
Note that storing your repository password in plain text may not be the wisest security choice. You can always leave it blank and you should be prompted for it whenever it is necessary.
The .pypirc file should be respected by every packaging tool built for Python. While this may not be true for every packaging-related utility out there, it is supported by the most important ones, such as pip, twine, distutils, and setuptools.
Let's take a look at the comparison between source packages and built packages.