This guide walks you through the process of publishing the ConnectIT library to the Python Package Index (PyPI).
-
Create PyPI Account
- Go to https://pypi.org/account/register/
- Create an account and verify your email
-
Create TestPyPI Account (recommended for testing)
- Go to https://test.pypi.org/account/register/
- Create an account for testing uploads
-
Install Required Tools
pip install --upgrade pip pip install --upgrade build twine
Ensure your package is ready:
- ✅
pyproject.tomlis properly configured - ✅
LICENSEfile exists - ✅
README.mdis comprehensive - ✅
MANIFEST.inincludes all necessary files - ✅ Version number is correct in
pyproject.toml
# Remove old build artifacts
rm -rf dist/
rm -rf build/
rm -rf *.egg-info/# Build source distribution and wheel
python -m buildThis creates:
dist/connectit-0.1.0.tar.gz(source distribution)dist/connectit-0.1.0-py3-none-any.whl(wheel)
# Upload to TestPyPI first
python -m twine upload --repository testpypi dist/*You'll be prompted for:
- Username: Your TestPyPI username
- Password: Your TestPyPI password (or API token)
# Test install from TestPyPI
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ connectitOnce testing is successful:
# Upload to production PyPI
python -m twine upload dist/*You'll be prompted for:
- Username: Your PyPI username
- Password: Your PyPI password (or API token)
For better security, use API tokens instead of passwords:
-
Generate API Token
- Go to PyPI Account Settings → API tokens
- Create a new token with appropriate scope
- Copy the token (starts with
pypi-)
-
Configure Credentials Create
~/.pypirc:[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-testpypi-token-here
-
Update version in
pyproject.toml:version = "0.1.1" # Increment version
-
Follow Semantic Versioning:
0.1.0→0.1.1(patch: bug fixes)0.1.0→0.2.0(minor: new features)0.1.0→1.0.0(major: breaking changes)
# Clean, build, and upload new version
rm -rf dist/ build/ *.egg-info/
python -m build
python -m twine upload dist/*Once published, users can install ConnectIT:
# Basic installation
pip install connectit
# With optional dependencies
pip install connectit[hf] # Hugging Face support
pip install connectit[torch] # PyTorch support
pip install connectit[all] # All optional dependencies-
"File already exists" error
- You cannot upload the same version twice
- Increment the version number in
pyproject.toml
-
Missing files in package
- Check
MANIFEST.inincludes all necessary files - Verify with
python -m build --sdistand inspect the.tar.gz
- Check
-
Import errors after installation
- Ensure
__init__.pyfiles exist in all packages - Check that dependencies are correctly specified
- Ensure
-
Authentication errors
- Verify your PyPI credentials
- Consider using API tokens instead of passwords
# List contents of built package
tar -tzf dist/connectit-0.1.0.tar.gz-
Test Installation
pip install connectit python -c "import connectit; print('Success!')" -
Update Documentation
- Add installation instructions to README
- Update version badges if using any
-
Tag Release (if using Git)
git tag v0.1.0 git push origin v0.1.0
⚠️ Never commit API tokens to version control⚠️ Use API tokens instead of passwords when possible⚠️ Test on TestPyPI before production uploads⚠️ Keep your PyPI account secure with 2FA
For commercial licensing or questions about ConnectIT: 📧 loaiabdalslam@gmail.com