Overview
Theinit command transforms a basic Python project into a fully-configured, production-ready pyrig project through a comprehensive automated sequence. It orchestrates the entire project setup process, from version control initialization to running tests and creating the first commit.
What It Does
The initialization sequence executes the following steps in order:Usage
First-Time Project Setup
Expected Output
With Verbose Output
Quiet Mode
What You Get
After runninginit, your project will have:
- Configuration files:
pyproject.toml,.gitignore,.pre-commit-config.yaml, etc. - GitHub workflows: CI/CD pipelines in
.github/workflows/ - Test structure: Complete test skeleton mirroring your source code
- Git hooks: Pre-commit hooks for formatting and linting
- Working CLI: Automatically generated CLI for your project
- Initial commit: All files committed to version control
Behavior
Each step executes sequentially. If any step fails, the process stops immediately.
The process is fully logged. Use
-v flags for more detailed output.Individual steps are idempotent, but the full sequence is designed for initial setup. Safe to re-run, but typically used only once.
Error Handling
If any step fails, the command will:- Stop execution immediately
- Display an error message
- Exit with a non-zero status code
- No Git installed: Ensure Git is available in your PATH
- Missing dependencies: Install system-level dependencies if required
- Test failures: Fix any issues in generated test skeletons
When to Use
Use init when
- Setting up a brand new project
- Converting a basic Python project to pyrig
- You want a fully automated setup
Don't use init when
- Updating an existing pyrig project (use
mkrootinstead) - You only need to regenerate configs
- The project is already initialized
Related Commands
- mkroot - Update configuration files only
- mktests - Generate test skeletons only
- mkinits - Create
__init__.pyfiles only
Implementation
Theinit command delegates to Pyrigger.I.init_project(), which orchestrates the entire initialization sequence. See pyrig/rig/cli/commands/init_project.py:9.
Run
uv run pyrig init --help to see the command’s built-in help text.