Skip to main content

Configure PyPI with Twine

configure-pypi-with-twine.py creates a ~/.pypirc file configured for PyPI token authentication with Twine.

The script is conservative: if ~/.pypirc already exists, it leaves the file unchanged.

Behavior

  • The script requires the Python twine module to be installed.
  • The token is read from PYPI_API_TOKEN first.
  • If PYPI_API_TOKEN is empty, the script prompts for the token.
  • A new ~/.pypirc is created with permissions 0600.
  • Existing ~/.pypirc files are never overwritten.

Requirements

  • Python 3.10 or newer
  • Twine
  • A PyPI API token

Install Twine when needed:

python3 -m pip install twine

Building

Testing

Run the unit tests from the project root:

python3 -m unittest discover -s tests -v

Package artifact

Build and validate the package artifacts:

./build-package.sh

This creates the wheel and source distribution under dist/ and checks the package metadata with Twine.

Publish artifact

Publish the generated artifacts to PyPI:

./publish-pypi.sh

The publish script checks that Twine is available, creates a local .venv for Twine when needed, verifies that dist/ contains generated artifacts, and then uploads them. If PyPI returns HTTP 400 because the package version was already published, the script reports that clearly; increment the version in pyproject.toml, rebuild, and publish again.

Install artifact

The software can be installed as follows (using a virtual environment):

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install kaizten-configure-pypi-with-twine

Usage

Configure Twine with a token from the environment:

PYPI_API_TOKEN=pypi-token ./configure-pypi-with-twine.py

Or run the script and enter the token securely when prompted:

./configure-pypi-with-twine.py

When installed as a package, use the console command:

configure-pypi-with-twine

Release files for configure-pypi-with-twine 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for configure-pypi-with-twine 0.0.1
File Size Uploaded
configure_pypi_with_twine-0.0.1.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for configure-pypi-with-twine 0.0.1
File Interpreter ABI Platform
configure_pypi_with_twine-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / configure_pypi_with_twine-0.0.1.tar.gz

Download URL configure_pypi_with_twine-0.0.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ac9f2483bf161bdebdaf3e3fd789c4d0edd8e85b94a4bb6f2a37a018e8641a37
BLAKE2b-256 checksum
How to use checksums
867539cc986ca508b4f498f1c2bdac2a9a82737408e19a0d6ca84518ba08a9a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / configure_pypi_with_twine-0.0.1-py3-none-any.whl

Download URL configure_pypi_with_twine-0.0.1-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
898322661eccce9d3856c08b46f432f8bc670f24659a2900dac1da20403e9209
BLAKE2b-256 checksum
How to use checksums
1fe61183ed70b9c702923d62a272920be1794de1631769c69e607140f74ea74e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page