Metadata-Version: 2.4
Name: configure-pypi-with-twine
Version: 0.0.1
Summary: Configure Twine credentials for publishing to PyPI.
Author: Kaizten Analytics
License-Expression: LicenseRef-Proprietary
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: twine

# 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:

```bash
python3 -m pip install twine
```

## Building

### Testing

Run the unit tests from the project root:

```bash
python3 -m unittest discover -s tests -v
```

### Package artifact

Build and validate the package artifacts:

```bash
./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:

```bash
./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):
```sh
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:

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

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

```bash
./configure-pypi-with-twine.py
```

When installed as a package, use the console command:

```bash
configure-pypi-with-twine
```
