A utility script for easily switching between local development and published sources for Python packages in your pyproject.toml
.
- Automatically toggles between local development paths and GitHub sources
- Preserves TOML file comments and structure
- Automatically clones repositories when switching to local development
- Supports branch tracking
- Falls back to PyPI metadata if direct GitHub repository is not found
- Integrates with GitHub CLI for username detection
pip install -r requirements.txt
uv run --script script.py activemodel --published
To toggle a module named "activemodel":
This will:
- Check if the package exists in your
PYTHON_DEVELOPMENT_TOGGLE
directory - If switching to local and the repository doesn't exist, clone it automatically (attempts to determine the repo URL from pypi information)
- Update your
pyproject.toml
with the appropriate source configuration - Preserve any existing branch information when toggling
MODULE_NAME
: The name of the Python module to toggle--local
: Force using local development path--published
: Force using published source
PYTHON_DEVELOPMENT_TOGGLE
: Directory for local development repositories (default: "pypi")