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
twinemodule to be installed. - The token is read from
PYPI_API_TOKENfirst. - If
PYPI_API_TOKENis empty, the script prompts for the token. - A new
~/.pypircis created with permissions0600. - Existing
~/.pypircfiles 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
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| configure_pypi_with_twine-0.0.1.tar.gz | 5.0 kB | Without provenance | Details for configure_pypi_with_twine-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| configure_pypi_with_twine-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for configure_pypi_with_twine-0.0.1-py3-none-any.whl |
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
|
Security for configure-pypi-with-twine 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.