Warning, /swf-testbed/docs/publishing_to_testpypi.md is written in an unsupported language. File is not indexed.
0001 # Publishing to TestPyPI
0002
0003 This document describes the **recommended and working procedure** for publishing your Python package to [TestPyPI](https://test.pypi.org/), a separate instance of the Python Package Index for testing purposes.
0004
0005 ## 1. Create a TestPyPI Account
0006 - Go to [https://test.pypi.org/account/register/](https://test.pypi.org/account/register/) and create an account.
0007 - Verify your email address.
0008
0009 ## 2. Configure `~/.pypirc` for API Token
0010 Add the following to your `~/.pypirc` file (create it if it doesn't exist):
0011
0012 ```ini
0013 [distutils]
0014 index-servers =
0015 testpypi
0016
0017 [testpypi]
0018 repository = https://test.pypi.org/legacy/
0019 username = __token__
0020 password = <your-testpypi-api-token>
0021 ```
0022 - **username must be `__token__`** (literally, two underscores on each side of `token`).
0023 - **password must be your TestPyPI API token** (not your password).
0024 - You can generate a token at [TestPyPI API tokens](https://test.pypi.org/manage/account/token/).
0025
0026 ## 3. Bump the Version
0027 - Each upload to TestPyPI must use a unique version number in your `pyproject.toml`:
0028 ```toml
0029 version = "<new-version>"
0030 ```
0031
0032 ## 4. Build the Package
0033 From the root of your package directory:
0034
0035 ```bash
0036 pip install --upgrade build
0037 python -m build
0038 ```
0039
0040 ## 5. Upload to TestPyPI
0041
0042 ```bash
0043 pip install --upgrade twine
0044 twine upload --repository testpypi dist/*
0045 ```
0046
0047 ## 6. Install from TestPyPI
0048 To test installation from TestPyPI:
0049
0050 ```bash
0051 pip install --index-url https://test.pypi.org/simple/ <your-package-name>
0052 ```
0053
0054 ## Notes
0055 - TestPyPI is for testing only. Packages may be deleted at any time.
0056 - Use a unique version number for each upload.
0057 - If you want to automate this with GitHub Actions, update your workflow to use the TestPyPI repository URL and credentials.