Installation
pyrig works with any Python 3.12+ project. Follow these steps to add pyrig to a new or existing project.Create or navigate to your project
Start with an empty directory or navigate to an existing Python project:
Initialize with uv (recommended)
- New Project
- Existing Project
pyproject.toml file.Initialize your pyrig project
Run the initialization command:
What does pyrig init do?
What does pyrig init do?
The
init command runs a comprehensive setup sequence:- Initializes git repository (
git init) - Adds development dependencies (pytest, ruff, etc.)
- Syncs the virtual environment
- Creates all config files and project structure
- Generates test skeletons
- Installs pre-commit hooks
- Formats and lints all files
- Runs the test suite
- Creates initial git commit
The
init command is idempotent. You can run it again anytime to sync your project structure.Verify Installation
After installation completes, verify everything works:Your First pyrig Command
Let’s explore what pyrig created by running a few commands:View Generated Structure
Try the Automatic CLI
Your project now has a working CLI. Try these commands:Common Commands
Here are the most frequently used pyrig commands:pyrig init
pyrig init
Full project initializationTransforms a basic Python project into a fully-configured, production-ready pyrig project. Safe to run on existing projects — it’s idempotent.
pyrig mkroot
pyrig mkroot
Create or update all config filesDiscovers all
ConfigFile subclasses and validates them. Creates missing files, adds missing keys, but preserves your customizations.pyrig mktests
pyrig mktests
Generate test skeletonsCreates test files mirroring your source structure. Non-destructive — only adds new test skeletons.
pyrig mkinits
pyrig mkinits
Create missing init.py filesScans for namespace packages and creates minimal
__init__.py files.pyrig build
pyrig build
Build artifactsRuns all registered builders (PyInstaller executables, etc.).
Working Example
Let’s create a simple CLI tool to see pyrig in action.Create a command function
Edit
my_project/rig/cli/subcommands.py and add:my_project/rig/cli/subcommands.py
Next Steps
Understand the Architecture
Learn how pyrig’s config system, CLI discovery, and multi-package inheritance work
Explore the CLI
Deep dive into CLI commands and automatic command discovery
Config System
Create custom config files and override existing ones
Testing
Learn about autouse fixtures and test infrastructure
Verbosity Control
All pyrig commands support flexible logging:Troubleshooting
Command not found: pyrig
Command not found: pyrig
Make sure you’re running commands with Or activate your virtual environment:
uv run:Import errors during init
Import errors during init
Some pyrig commands require dev dependencies. Make sure they’re installed:
Permission errors with git hooks
Permission errors with git hooks
If pre-commit hooks fail to install:
Python version mismatch
Python version mismatch
pyrig requires Python 3.12+. Check your version:If needed, specify the Python version for uv: