Package Publishing¶
This section describes how to build and publish the cccgpu package to PyPI and test PyPI.
Prerequisites¶
Setup¶
Configure PyPI credentials¶
Copy the example configuration and update with your credentials:
cp .pypirc.example ~/.pypirc
chmod 600 ~/.pypirc # Protect your credentials
Edit ~/.pypirc and add your API tokens:
Get test PyPI token from: https://test.pypi.org/manage/account/token/
Get PyPI token from: https://pypi.org/manage/account/token/
Or use the project-local .pypirc file which the scripts will automatically detect.
Make scripts executable¶
chmod +x scripts/pypi/00-build_package.sh
chmod +x scripts/pypi/10-upload_to_test_pypi.sh
Building the Package¶
The package uses scikit-build-core to build C++/CUDA extensions along with the Python package.
Build command¶
./scripts/pypi/00-build_package.sh
This script will:
Activate the
ccc-gpuconda environmentClean previous builds
Install/update build dependencies (
build,twine,setuptools,wheel,auditwheel)Build both source distribution (
.tar.gz) and wheel (.whl)Fix wheel platform tags for PyPI compatibility (convert
linux_x86_64tomanylinux_2_17_x86_64)Place built packages in
dist/directory
Manual build (if needed)¶
mamba activate ccc-gpu
python -m pip install --upgrade build auditwheel
python -m build
# Fix wheel tags if needed
auditwheel repair dist/*.whl --plat-tag manylinux_2_17_x86_64 --wheel-dir dist/
Publishing to Test PyPI¶
Test PyPI is a separate instance for testing package uploads without affecting the main index.
Upload to test PyPI¶
./scripts/pypi/10-upload_to_test_pypi.sh
This script will:
Activate the conda environment
Check package integrity with
twine checkUpload to test PyPI using project
.pypircif availableProvide installation instructions
Manual upload (if needed)¶
mamba activate ccc-gpu
python -m twine upload --repository testpypi dist/*
Installing from test PyPI¶
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
cccgpu
Note
The --extra-index-url is needed to install dependencies from the main PyPI.
Publishing to Production PyPI¶
Once tested, publish to the main PyPI:
mamba activate ccc-gpu
python -m twine upload dist/*
Installing from PyPI¶
pip install cccgpu
Version Management¶
Before building a new release:
Update version in
pyproject.toml:[project] version = "0.2.1" # Increment as needed
Tag the release:
git tag -a v0.2.1 -m "Release version 0.2.1" git push origin v0.2.1
Platform Tag Compatibility¶
The build system automatically handles platform tag conversion for PyPI compatibility:
Builds initially create wheels with
linux_x86_64tagsauditwheelconverts them tomanylinux_2_17_x86_64for PyPI acceptanceFallback renaming is available if
auditwheelfails
Troubleshooting¶
CUDA/GPU Dependencies¶
The package requires CUDA toolkit for building. Users installing from PyPI need:
CUDA toolkit installed
Compatible GPU
Appropriate CUDA version matching the build
Build Errors¶
If build fails with CUDA errors:
Ensure CUDA toolkit is installed and accessible
Check
CUDAToolkit_ROOTenvironment variableVerify GPU and CUDA compatibility
Authentication Issues¶
If upload fails with authentication errors:
Verify API tokens in
.pypirc(project-local or~/.pypirc)Use
__token__as username with API tokensEnsure tokens have upload permissions
Platform Tag Errors¶
If you get “unsupported platform tag” errors:
Ensure
auditwheelis installedThe build script should automatically fix platform tags
Check that the wheel has
manylinuxtag, notlinux
Package Already Exists¶
If version already exists:
Increment version in
pyproject.tomlRebuild the package
Upload the new version
Best Practices¶
Always test on test PyPI first before publishing to production
Use API tokens instead of passwords for security
Semantic versioning: Follow MAJOR.MINOR.PATCH convention
Check package: Run
twine check dist/*before uploadingClean builds: Remove old builds before creating new ones
Document changes: Update CHANGELOG for each release
Test installation: Verify package installs correctly after publishing
Use project .pypirc: Keep credentials in project directory for team access