{
    "content": "<h1>Understanding the .pypirc Configuration File<\/h1><p>The <strong>.pypirc<\/strong> file is a configuration file used by <a href=\"..\/python\/\">Python<\/a> packaging tools to store information about <a href=\"..\/package-index\/\">Package Index<\/a> repositories, primarily the <a href=\"..\/pypi\/\">Python Package Index (PyPI)<\/a>. It allows developers to automate the authentication process when uploading packages using tools like <a href=\"..\/twine\/\">Twine<\/a> or <a href=\"..\/flit\/\">Flit<\/a>.<\/p><h2>File Structure and Location<\/h2><p>Typically located in the user's home directory (<code>~\/.pypirc<\/code> on Unix-like systems or <code>%USERPROFILE%\\.pypirc<\/code> on Windows), the file follows the <a href=\"..\/ini-format\/\">INI format<\/a>. It is divided into sections, starting with a <code>[distutils]<\/code> header that lists the defined repository names.<\/p><p>A standard configuration includes a <code>repository<\/code> URL, a <code>username<\/code>, and a <code>password<\/code>. For enhanced security, the <a href=\"..\/pypi\/\">PyPI<\/a> maintainers strongly recommend using <a href=\"..\/api-tokens\/\">API Tokens<\/a> instead of account passwords. When using a token, the username should be set to <code>__token__<\/code> and the password to the token value itself, including the <code>pypi-<\/code> prefix.<\/p><h2>Example Configuration<\/h2><p>A basic <code>.pypirc<\/code> might look like this:<\/p><pre>[distutils]\nindex-servers =\n    pypi\n    testpypi\n\n[pypi]\nrepository = https:\/\/upload.pypi.org\/legacy\/\nusername = __token__\npassword = pypi-AgEIcHlwaS5vcmc...<\/pre><h2>Security Considerations<\/h2><p>Because the <code>.pypirc<\/code> file contains sensitive credentials, it is crucial to set appropriate file permissions. On Linux and macOS, it is recommended to restrict access to the file using <code>chmod 600 ~\/.pypirc<\/code>. More information on secure distribution can be found in the official <a href=\"https:\/\/packaging.python.org\/en\/latest\/specifications\/pypirc\/\">Python Packaging User Guide<\/a>.<\/p><h3>Related Topics<\/h3><ul><li><a href=\"..\/twine\/\">twine<\/a><\/li><li><a href=\"..\/pypi\/\">pypi<\/a><\/li><li><a href=\"..\/setuptools\/\">setuptools<\/a><\/li><li><a href=\"..\/api-tokens\/\">api-tokens<\/a><\/li><\/ul>",
    "tags": [
        "pypirc",
        "python",
        "pypi",
        "packaging",
        "configuration",
        "twine",
        "deployment",
        "authentication",
        "devops",
        "pip"
    ]
}