This guide explains how to publish the md2doc package to PyPI.
- PyPI Account: Create an account on PyPI
- TestPyPI Account: Create an account on TestPyPI for testing
- API Token: Generate an API token from your PyPI account settings
# Install build tools
uv pip install build twine
# Or install globally
pip install build twineYou have several options for authentication with uv publish:
Set environment variables for authentication:
# For PyPI
export UV_PUBLISH_TOKEN="your-pypi-token-here"
export UV_PUBLISH_URL="https://upload.pypi.org/legacy/"
# For TestPyPI
export UV_PUBLISH_TOKEN="your-testpypi-token-here"
export UV_PUBLISH_URL="https://test.pypi.org/legacy/"Pass credentials directly in the command:
# For PyPI
uv publish -t "your-pypi-token-here" --publish-url "https://upload.pypi.org/legacy/"
# For TestPyPI
uv publish -t "your-testpypi-token-here" --publish-url "https://test.pypi.org/legacy/"If you prefer using twine, create a ~/.pypirc file:
[distutils]
index-servers =
pypi
testpypi
[pypi]
repository = https://upload.pypi.org/legacy/
username = __token__
password = your-pypi-token-here
[testpypi]
repository = https://test.pypi.org/legacy/
username = __token__
password = your-testpypi-token-here# Make script executable (if not already)
chmod +x publish.sh
# Run the publish script
./publish.sh# Clean previous builds
rm -rf dist/ build/ *.egg-info/
# Build the package
uv build# Upload to TestPyPI using environment variables
export UV_PUBLISH_TOKEN="your-testpypi-token-here"
export UV_PUBLISH_URL="https://test.pypi.org/legacy/"
uv publish
# Or using command line arguments
uv publish -t "your-testpypi-token-here" --publish-url "https://test.pypi.org/legacy/"
# Test installation
uvx md2doc --index-url https://test.pypi.org/simple/# Upload to PyPI using environment variables
export UV_PUBLISH_TOKEN="your-pypi-token-here"
export UV_PUBLISH_URL="https://upload.pypi.org/legacy/"
uv publish
# Or using command line arguments
uv publish -t "your-pypi-token-here" --publish-url "https://upload.pypi.org/legacy/"To update the version:
-
Edit
pyproject.toml:[project] version = "0.1.1" # Increment version
-
Update
md2doc/__init__.py:__version__ = "0.1.1"
-
Build and publish:
./publish.sh
After publishing, verify the installation:
# Test installation
uvx md2doc
# Or install and test
uv pip install md2doc
python -c "import md2doc; print(md2doc.__version__)"- Authentication Error: Check your
~/.pypircfile and API tokens - Version Already Exists: Increment the version number in
pyproject.toml - Build Errors: Ensure all dependencies are correctly specified
# Test the package locally before publishing
uv pip install -e .
python test_package.py- Package Name: md2doc
- PyPI URL: https://pypi.org/project/md2doc/
- Install Command:
uvx md2doc - Entry Point:
md2doc.server:main
If you encounter issues during publishing:
- Check the PyPI documentation
- Verify your package structure with
python -m build --sdist --wheel - Test with TestPyPI first