This guide explains how to publish the EdgeX Python SDK to PyPI without using personal accounts.
- Go to PyPI Registration
- Create an account using the organization email (e.g.,
info@edgex.exchange) - Verify the email address
- Enable 2FA for security
For security, use API tokens instead of passwords:
- Log into the organization PyPI account
- Go to Account Settings → API tokens
- Create a new API token:
- Name:
edgex-python-sdk-upload - Scope: Limit to specific project (after first upload)
- Name:
- Copy and securely store the token (starts with
pypi-)
Add the following secrets to your GitHub repository:
- Go to GitHub repository → Settings → Secrets and variables → Actions
- Add these secrets:
PYPI_API_TOKEN: Your PyPI API tokenTEST_PYPI_API_TOKEN: Your Test PyPI API token (optional, for testing)
This method automatically publishes when you create a GitHub release:
-
Create a release:
git tag v0.1.0 git push origin v0.1.0
-
Create GitHub release:
- Go to GitHub → Releases → Create a new release
- Choose the tag you just created
- Add release notes
- Publish the release
-
GitHub Actions will automatically:
- Build the package
- Run quality checks
- Upload to PyPI
If you prefer manual control:
-
Install build tools:
pip install build twine
-
Build the package:
python scripts/build_and_test_package.py
-
Upload to Test PyPI first (recommended):
twine upload --repository testpypi dist/* -
Test installation from Test PyPI:
pip install --index-url https://test.pypi.org/simple/ edgex-python-sdk
-
Upload to PyPI:
twine upload dist/*
-
Build and test locally:
python scripts/build_and_test_package.py
-
Install locally:
pip install dist/edgex_python_sdk-*.whl -
Test basic functionality:
import edgex_sdk print(edgex_sdk.__version__)
Always test on Test PyPI before publishing to the main PyPI:
-
Upload to Test PyPI:
twine upload --repository testpypi dist/* -
Install from Test PyPI:
pip install --index-url https://test.pypi.org/simple/ edgex-python-sdk
Update version numbers in these files before publishing:
setup.py- line withversion="x.x.x"pyproject.toml- line withversion = "x.x.x"edgex_sdk/__init__.py- add__version__ = "x.x.x"
- Use API tokens, not passwords
- Enable 2FA on PyPI account
- Limit token scope to specific projects
- Store tokens securely in GitHub Secrets
- Rotate tokens regularly
- Never commit tokens to version control
-
Package name already exists:
- Choose a different name in
setup.pyandpyproject.toml
- Choose a different name in
-
Version already exists:
- Increment version number
- You cannot overwrite existing versions on PyPI
-
Authentication failed:
- Check API token is correct
- Ensure token has proper permissions
-
Build fails:
- Run
python scripts/build_and_test_package.pylocally - Check for missing dependencies or syntax errors
- Run
- PyPI Help: https://pypi.org/help/
- Packaging Guide: https://packaging.python.org/
- GitHub Actions: https://docs.github.com/en/actions
After successful publishing:
-
Test installation:
pip install edgex-python-sdk
-
Update documentation if needed
-
Announce the release to users
-
Monitor for issues and user feedback