This document explains how to publish the llms-py package to PyPI.
-
API Tokens: Generate API tokens for both PyPI and TestPyPI:
-
Install Dependencies:
pip install build twine
-
Configure twine (optional but recommended): 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
# Test the package works
python test_package.py
# Test building
python publish.py --build# Upload to TestPyPI
python publish.py --testThen test installation from TestPyPI:
# 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 TestPyPI
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ llms-py
# Test the installation
llms --help
llms --init
# Clean up
deactivate
rm -rf test_envOnce you've verified everything works on TestPyPI:
# Upload to PyPI
python publish.py --prod# Test installation from PyPI
pip install llms-py
llms --helpTo publish a new version:
- Update the version in
setup.pyandpyproject.toml - Update the version in
llms.py(VERSION variable) - Update the changelog/release notes
- Follow the publishing steps above
The package includes:
llms.py- Main module with CLI functionalitysetup.py- Legacy setup script (for compatibility)pyproject.toml- Modern Python packaging configurationMANIFEST.in- Specifies additional files to includerequirements.txt- DependenciesREADME.md- Package documentationLICENSE- BSD-3-Clause license
The package creates a console script entry point:
- Command:
llms - Function:
llms:main
This allows users to run llms-py directly from the command line after installation.
- Python module:
llms.py - Configuration:
llms.json - Documentation:
README.md - License:
LICENSE - Dependencies:
requirements.txt
-
Package name already exists: The name "llms-py" should be available, but if not, you'll need to choose a different name.
-
Authentication errors: Make sure your API tokens are correct and have the right permissions.
-
Build errors: Check that all required files are present and the package structure is correct.
-
Import errors: Ensure the main function is properly defined and accessible.
# Check package contents
python -m tarfile -l dist/llms-py-*.tar.gz
# Validate package
python -m twine check dist/*
# Test installation in isolated environment
python -m venv test_install
source test_install/bin/activate
pip install dist/llms-py-*.whl
llms --help
deactivate
rm -rf test_install- Never commit API tokens to version control
- Use environment variables or secure configuration files for tokens
- Consider using GitHub Actions or other CI/CD for automated publishing
- Always test on TestPyPI before publishing to PyPI