Overview
pyrig uses theuv_build backend for packaging Python projects. This modern build system integrates seamlessly with uv and provides:
- Fast builds: Rust-based backend for speed
- Console script integration: Automatic CLI entry points
- Standard compliance: PEP 517/518 compatible
- Simple configuration: Minimal
pyproject.tomlsetup - uv ecosystem: Works with the entire uv toolchain
Understanding uv_build
What is uv_build?
uv_build is a PEP 517-compliant build backend that:
- Builds wheels and source distributions (sdists)
- Integrates with
pyproject.toml - Handles console script generation automatically
- Works with uv’s dependency management
How pyrig Uses It
Every pyrig project includes this inpyproject.toml:
- Declares
uv_buildas the build backend - Specifies your project’s module name
- Sets the module root (usually empty string for root-level packages)
Packaging a Standard Project
Step 1: Verify pyproject.toml
Ensure yourpyproject.toml has the required sections:
Step 2: Build the Package
Useuv build to create distributions:
- Wheel (
.whl): Binary distribution for fast installation - Source distribution (
.tar.gz): Source code archive
Step 3: Test the Package
Test locally before publishing:Step 4: Publish to PyPI
Publish usinguv publish:
Packaging a pyrig Extension
Extension packages (like personal pyrig packages) have special considerations.Example: Personal pyrig Package
Createmy-pyrig/pyproject.toml:
Package Structure
Your extension package should include:Important: _init_.py Files
Every directory must have__init__.py for proper package discovery:
Console Scripts
Console scripts are CLI entry points automatically created during installation.Defining Scripts
Inpyproject.toml:
my-toolcommand → callsmy_project.rig.cli.cli.main()my-utilcommand → callsmy_project.utils.run()
Entry Point Function
The entry point must be a callable:pyrig’s CLI Pattern
pyrig projects use a standard CLI structure:my_project/rig/cli/subcommands/:
Advanced Configuration
Module Root Configuration
If your package is not at the repository root:Include/Exclude Files
Control what’s included in the distribution:Version Management
pyrig projects can use dynamic versioning:Dependency Management
Specifying Dependencies
Dependency Chain
When packaging extensions, dependencies cascade:my-project automatically installs the entire chain!
Optional Dependencies
Building for Distribution
Local Development Build
For testing during development:Production Build
For distribution:Automated Builds
In CI/CD (GitHub Actions):Publishing Strategies
Test PyPI First
Always test on Test PyPI before production:Version Strategy
Use semantic versioning:- Major (1.0.0 → 2.0.0): Breaking changes
- Minor (1.0.0 → 1.1.0): New features, backward compatible
- Patch (1.0.0 → 1.0.1): Bug fixes
Private Package Indexes
For internal packages:pyproject.toml:
Overriding Build Backend
You can override the build backend in your extensions:Using Poetry
Using Setuptools
Using Hatch
Common Issues and Solutions
Issue: Module Not Found
module-name matches your package directory:
Issue: Console Script Not Working
Issue: Missing Files in Distribution
Solution: Include them explicitly:Issue: Import Errors After Install
Solution: Ensure all directories have__init__.py:
Next Steps
- Extending pyrig - Create your extension package
- Creating Custom Tools - Add custom tools
- Publishing Guide - Detailed publishing workflow
- uv Documentation - Learn more about uv
Best Practices
- Version carefully: Use semantic versioning
- Test locally: Install from wheel before publishing
- Use Test PyPI: Verify everything works before production
- Include LICENSE: Always include license file
- Write good README: Help users get started
- Document dependencies: Explain what your package needs
- Tag releases: Use git tags for version tracking
- Automate: Use CI/CD for consistent builds
- Keep it simple: Minimal configuration is best
- Follow conventions: Study pyrig’s own
pyproject.toml