This guide explains how to package and publish ai-lab-testing to PyPI.
IMPORTANT: This package is currently published as alpha quality software:
- Not ready for professional or production use
- API may change without notice
- Features may be incomplete or unstable
- Bugs are expected
- Use at your own risk
The package is published to PyPI for:
- Early testing and feedback
- Development and experimentation
- Community contribution
Do not use in production environments or critical systems.
Create accounts on both platforms:
Note: You can use the same email/password for both, but they are separate accounts.
Generate API tokens (recommended over passwords):
Test PyPI:
- Go to https://test.pypi.org/manage/account/token/
- Click "Add API token"
- Name it (e.g., "ai-lab-testing-testpypi")
- Scope: "Entire account" (or "Project: ai-lab-testing" if you prefer)
- Copy the token (starts with
pypi-)
Production PyPI:
- Go to https://pypi.org/manage/account/token/
- Click "Add API token"
- Name it (e.g., "ai-lab-testing-pypi")
- Scope: "Entire account" (or "Project: ai-lab-testing" if you prefer)
- Copy the token (starts with
pypi-)
Security: Store tokens securely. Never commit them to git.
Install required Python packages:
python3.10 -m pip install --upgrade build twineBefore first publish, verify the package name is available:
- Check https://pypi.org/project/ai-lab-testing/ (should not exist or be yours)
- Check https://test.pypi.org/project/ai-lab-testing/ (should not exist or be yours)
Create ~/.pypirc file:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
password = pypi-<your-production-token>
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-<your-test-token>Security Note: Never commit .pypirc to git. Add it to .gitignore.
make cleanmake buildThis creates:
dist/lab_testing-<version>-py3-none-any.whl(wheel)dist/lab_testing-<version>.tar.gz(source distribution)
make check-distThis validates the package files.
make publish-testThen test installation:
python3.10 -m pip install --index-url https://test.pypi.org/simple/ ai-lab-testingOnce tested, publish to production:
make publish-
Update version in
lab_testing/version.py:__version__ = "0.1.1"
-
Update version in
pyproject.toml:version = "0.1.1"
-
Update
CHANGELOG.mdwith release notes -
Commit and tag:
git add lab_testing/version.py pyproject.toml CHANGELOG.md git commit -m "Release version 0.1.1" git tag -a v0.1.1 -m "Release version 0.1.1" git push origin main --tags
-
Build and publish:
make clean build publish
After publishing, users can install:
# From PyPI
python3.10 -m pip install ai-lab-testing
# With dev dependencies
python3.10 -m pip install "ai-lab-testing[dev]"- Check if version already exists on PyPI
- Increment version number
- Verify
.pypircfile exists and has correct tokens - Check token permissions on PyPI
- Ensure all dependencies are listed in
pyproject.toml - Check
MANIFEST.inincludes all necessary files - Run
make cleanbefore rebuilding
The project includes automated publishing via GitHub Actions. See .github/workflows/build.yml.
-
Add PyPI API Token to GitHub Secrets:
- Go to repository Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
PYPI_API_TOKEN - Value: Your PyPI API token (starts with
pypi-) - Click "Add secret"
-
How It Works:
- Publishing is triggered when you create a GitHub Release
- The workflow builds the package and publishes to PyPI
- Uses trusted publishing (no password needed if configured)
-
Manual Publishing (Alternative):
If you prefer manual publishing or need to publish to Test PyPI:
# Build the package
make build
# Upload to Test PyPI
twine upload --repository testpypi dist/*
# Or upload to production PyPI
twine upload dist/*PyPI supports trusted publishing via GitHub Actions. This is more secure than API tokens:
- Go to https://pypi.org/manage/account/publishing/
- Click "Add pending publisher"
- Select "GitHub" as the provider
- Enter:
- Owner:
DynamicDevices - Repository name:
ai-lab-testing - Workflow filename:
.github/workflows/build.yml
- Owner:
- Click "Add"
This allows the GitHub Action to publish without storing tokens in secrets.