This guide walks you through deploying the excloud Python package to PyPI so users can install it with pip install excloud.
You'll need accounts on both Test PyPI and production PyPI:
- Test PyPI: https://test.pypi.org/account/register/
- Production PyPI: https://pypi.org/account/register/
Instead of using passwords, create API tokens for secure authentication:
- Go to https://test.pypi.org/manage/account/token/
- Create a new token with scope "Entire account"
- Save the token securely
- Go to https://pypi.org/manage/account/token/
- Create a new token with scope "Entire account"
- Save the token securely
Create a ~/.pypirc file with your credentials:
[distutils]
index-servers =
pypi
testpypi
[pypi]
username = __token__
password = pypi-your-production-api-token-here
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = pypi-your-test-api-token-hereWe've provided a deployment script that automates the entire process:
# Deploy to Test PyPI (recommended first)
python scripts/deploy.py --target test --clean
# Test the installation
pip install -i https://test.pypi.org/simple/ excloud
python -c "from excloud import Client; print('Success!')"# Deploy to production PyPI
python scripts/deploy.py --target prod --clean# Deploy to both Test PyPI and production PyPI
python scripts/deploy.py --target both --cleanIf you prefer to do it manually or need more control:
rm -rf dist/ build/ *.egg-info/
find . -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true
find . -name '*.pyc' -delete 2>/dev/null || truepip install build twinepython -m buildThis creates two files in the dist/ directory:
excloud-0.1.0-py3-none-any.whl(wheel distribution)excloud-0.1.0.tar.gz(source distribution)
python -m twine check dist/*pip install -e .
python -c "from excloud import Client; print('Import successful!')"python -m twine upload --repository testpypi dist/*# Create a new virtual environment for testing
python -m venv test_env
source test_env/bin/activate # On Windows: test_env\Scripts\activate
# Install from Test PyPI
pip install -i https://test.pypi.org/simple/ excloud
# Test the installation
python -c "from excloud import Client; print('Test PyPI installation successful!')"
# Clean up
deactivate
rm -rf test_envpython -m twine upload dist/*After deploying to production PyPI, verify that users can install the package:
# Test in a fresh environment
python -m venv verify_env
source verify_env/bin/activate
# Install from PyPI
pip install excloud
# Test the expected usage
python -c "
from excloud import Client
client = Client(api_key='test_key')
print('✅ Package installed and working correctly!')
print(f'✅ Client class available: {Client}')
"
# Clean up
deactivate
rm -rf verify_env- Update the main README.md with installation instructions
- Update any documentation that references installation
- Consider creating a changelog entry
Before each release, update the version in pyproject.toml:
[project]
name = "excloud"
version = "0.1.1" # Update thisFollow semantic versioning (semver):
0.1.0- Initial release0.1.1- Patch release (bug fixes)0.2.0- Minor release (new features, backward compatible)1.0.0- Major release (breaking changes)
Tag releases in git:
git tag v0.1.0
git push origin v0.1.0Error: HTTP Error 403: The user 'username' isn't allowed to upload to project 'excloud'
Solution: Make sure you're using the correct API token and have the right permissions.
Error: File already exists
Solution: You cannot overwrite existing versions on PyPI. Increment the version number.
ImportError: No module named 'excloud'
Solutions:
- Check that the package structure is correct
- Verify
__init__.pyexports are correct - Ensure dependencies are properly specified
ModuleNotFoundError: No module named 'requests'
Solution: Check that dependencies are listed in pyproject.toml:
dependencies = ["requests>=2.25.0", "websockets>=11.0"]To see what's included in your package:
# For wheel files
python -m zipfile -l dist/excloud-0.1.0-py3-none-any.whl
# For source distribution
tar -tzf dist/excloud-0.1.0.tar.gz# Test with Python 3.8
python3.8 -m venv test_py38
source test_py38/bin/activate
pip install excloud
python -c "from excloud import Client; print('Python 3.8 OK')"
deactivate
# Test with Python 3.11
python3.11 -m venv test_py311
source test_py311/bin/activate
pip install excloud
python -c "from excloud import Client; print('Python 3.11 OK')"
deactivate- Never commit API tokens to version control
- Use API tokens instead of passwords
- Limit token scope to what's necessary
- Rotate tokens regularly
- Use Test PyPI first before production
After deployment, monitor:
- Download statistics on PyPI
- User feedback and issues
- Compatibility with new Python versions
- Security vulnerabilities in dependencies
Your package is now ready for deployment! The key steps are:
- ✅ Package structure is correct (
excloud/directory with__init__.py) - ✅ Configuration files are set up (
pyproject.toml,setup.py) - ✅ Import works as expected:
from excloud import Client - ✅ Build and deployment scripts are ready
- ✅ Documentation is complete
Users will be able to install your package with:
pip install excloudAnd use it with:
from excloud import Client
client = Client(api_key="your_api_key")
# ... rest of your code