This guide explains how to publish new versions of streamlit-float to PyPI.
- Setup Authentication: Create API token at https://pypi.org/manage/account/token/
- Add token to
.envfile:export PYPI_API=your_api_token_here - Load environment variables:
source .env - Remove old build files:
rm -rf dist/ build/ streamlit_float.egg-info/
- Update version in
setup.py:version="0.4.1", # Increment this
- Build distribution files:
python setup.py sdist bdist_wheel
- Upload to PyPI:
twine upload --username __token__ --password $PYPI_API dist/*
- PyPI Account: Make sure you have an account at https://pypi.org/
- API Token: Create an API token at https://pypi.org/manage/account/token/
- Go to PyPI account settings
- Create a new API token
- Scope it to the
streamlit-floatproject (recommended) or your entire account - Copy the token (starts with
pypi-)
pip install twine buildOption A: Environment Variables (Recommended)
Create/update .env file in the project root:
export PYPI_API=your_api_token_hereThen load it:
source .envOption B: Create ~/.pypirc
[distutils]
index-servers = pypi
[pypi]
username = __token__
password = your_api_token_hereUpdate the version number in setup.py:
setup(
name="streamlit-float",
version="0.4.1", # Update this
# ...
)rm -rf dist/ build/ *.egg-info/python setup.py sdist bdist_wheelThis creates files in the dist/ directory:
streamlit_float-X.X.X.tar.gz(source distribution)streamlit_float-X.X.X-py3-none-any.whl(wheel distribution)
Test on TestPyPI first:
twine upload --repository testpypi dist/*# If using environment variables:
twine upload --username __token__ --password $PYPI_API dist/*
# If using ~/.pypirc:
twine upload dist/*
# If entering credentials manually:
twine upload --username __token__ dist/*
# (will prompt for password - enter your API token)- Check the package page: https://pypi.org/project/streamlit-float/
- Test installation:
pip install streamlit-float==X.X.X
Error: HTTPError: 403 Forbidden or Invalid or non-existent authentication information
Solutions:
- Make sure your API token is correct and not expired
- Use
__token__as username (literally, not your PyPI username) - Ensure the token has the right scope (project or account)
Error: unrecognized arguments or Missing section from ~/.pypirc
Wrong:
twine upload --repository https://upload.pypi.org/legacy/ streamlit-floatCorrect:
twine upload dist/*
# OR
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*Error: Files not found or no distributions found
Solution: Make sure you're uploading from dist/* not the package name:
# Wrong
twine upload streamlit-float
# Correct
twine upload dist/*Error: File already exists
Solutions:
- Increment the version number in
setup.py - Use
--skip-existingflag (not recommended for production)
Make sure your .env file uses the correct format:
Wrong:
PYPI_API = pypi-your-token-hereCorrect:
export PYPI_API=pypi-your-token-here- Never commit
.envfiles - they contain sensitive API tokens - Add
.envto your.gitignorefile - Rotate API tokens regularly
- Use project-scoped tokens when possible
- Consider using CI/CD for automated publishing
Complete publishing workflow:
# 1. Update version in setup.py
# 2. Clean and build
rm -rf dist/ build/ *.egg-info/
python setup.py sdist bdist_wheel
# 3. Load credentials
source .env
# 4. Upload
twine upload --username __token__ --password $PYPI_API dist/*
# 5. Verify at https://pypi.org/project/streamlit-float/If you encounter issues:
- Use
--verboseflag with twine for detailed error information - Check that all required files are in
dist/directory - Verify your API token is correct and has proper permissions
- Ensure version number in
setup.pyis incremented from the last release