Publishing ADAMSNRC to PyPI
This guide explains how to publish the ADAMSNRC package to the Python Package Index (PyPI).
Prerequisites
Setup
1. Install Publishing Tools
pip install build twine
2. Configure PyPI Credentials
Create a ~/.pypirc file:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
password = pypi-your-api-token-here
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-your-test-api-token-here
Publishing Process
1. Update Version
Before publishing, update the version in:
setup.pypyproject.tomladamsnrc/__init__.pyCHANGELOG.md
2. Build the Package
# Clean previous builds
rm -rf build/ dist/ *.egg-info/
# Build the package
python -m build
This creates:
dist/adamsnrc-X.X.X.tar.gz(source distribution)dist/adamsnrc-X.X.X-py3-none-any.whl(wheel distribution)
3. Test on TestPyPI (Recommended)
# Upload to TestPyPI
twine upload --repository testpypi dist/*
# Test installation from TestPyPI
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ adamsnrc
4. Publish to PyPI
# Upload to PyPI
twine upload dist/*
5. Verify Installation
# Install from PyPI
pip install adamsnrc
# Test the package
python -c "import adamsnrc; print(adamsnrc.__version__)"
GitHub Actions Publishing
The repository includes GitHub Actions workflows for automated publishing:
CI Workflow (.github/workflows/ci.yml)
Runs on push to main/develop and pull requests
Tests on multiple Python versions
Runs linting and type checking
Builds the package
Publish Workflow (.github/workflows/publish.yml)
Runs when a GitHub release is published
Automatically builds and publishes to PyPI
Uses
PYPI_API_TOKENsecret
Setup GitHub Secrets
Go to your repository settings
Navigate to Secrets and variables → Actions
Add
PYPI_API_TOKENwith your PyPI API token
Version Management
Semantic Versioning
Follow semantic versioning:
MAJOR: Breaking changes
MINOR: New features (backward compatible)
PATCH: Bug fixes (backward compatible)
Release Process
Update version in all files
Update CHANGELOG.md with new changes
Commit changes with conventional commit message
Create GitHub release with tag (e.g.,
v2.0.0)GitHub Actions automatically publishes to PyPI
Example Release
# Update version to 2.1.0
sed -i 's/version = "2.0.0"/version = "2.1.0"/' pyproject.toml
sed -i 's/version="2.0.0"/version="2.1.0"/' setup.py
sed -i 's/__version__ = "2.0.0"/__version__ = "2.1.0"/' adamsnrc/__init__.py
# Commit and tag
git add .
git commit -m "feat: release version 2.1.0"
git tag v2.1.0
git push origin main --tags
# Create GitHub release (manually or via GitHub CLI)
gh release create v2.1.0 --title "Version 2.1.0" --notes "New features and improvements"
Package Information
PyPI Page
Once published, the package will be available at: https://pypi.org/project/adamsnrc/
Installation
pip install adamsnrc
Usage
from adamsnrc import content_search, SearchResult
# Search for documents
result = content_search(
properties_search=[("DocumentType", "ends", "NUREG")],
single_content_search="steam generator"
)
print(f"Found {result.count} documents")
CLI Usage
# Install with CLI
pip install adamsnrc
# Use CLI
adamsnrc search --type content --doc-type "NUREG" --text "steam generator"
Troubleshooting
Common Issues
Authentication Error
Verify API token is correct
Check
~/.pypircconfiguration
Package Already Exists
Version must be unique
Update version number
Build Errors
Check all required files are present
Verify
MANIFEST.inincludes necessary files
Import Errors After Installation
Check package structure
Verify
__init__.pyexports are correct
Support
For issues with publishing:
Check PyPI Help
Review Python Packaging User Guide
Open an issue in the repository
Security
API Token Security
Never commit API tokens to version control
Use environment variables or
~/.pypircRotate tokens regularly
Package Verification
Verify package contents before upload
Test installation in clean environment
Check package metadata
Maintenance
Regular Tasks
Monitor package downloads and issues
Update dependencies as needed
Maintain documentation
Respond to user feedback
Deprecation
Follow deprecation policy
Provide migration guides
Maintain backward compatibility when possible