Skip to main content

Generate Rattler-Build recipe.yaml from pyproject.toml

Project description

pyrattler-recipe-autogen

Automatically generates recipe.yaml files for rattler-build directly from your Python project's pyproject.toml, eliminating the need for manual recipe creation.

Installation

Requirements

  • Python 3.9 or later

From PyPI (when published)

pip install pyrattler-recipe-autogen

From Source

git clone https://github.com/millsks/pyrattler-recipe-autogen.git
cd pyrattler-recipe-autogen
pip install -e .

Usage

Command Line Interface

After installation, you can use the pyrattler-recipe-autogen command:

# Generate recipe.yaml from pyproject.toml in current directory
pyrattler-recipe-autogen

# Specify input and output files
pyrattler-recipe-autogen -i path/to/pyproject.toml -o path/to/recipe.yaml

# Overwrite existing recipe file
pyrattler-recipe-autogen --overwrite

Programmatic Usage

You can also use the package programmatically:

from pathlib import Path
from pyrattler_recipe_autogen import generate_recipe

# Generate recipe from pyproject.toml
generate_recipe(
    pyproject_path=Path("pyproject.toml"),
    output_path=Path("recipe.yaml"),
    overwrite=False
)

Features

Automatic Project Data Extraction: Pulls canonical project data from [project] section • Dynamic Version Resolution: Handles dynamic version resolution from build backends (setuptools_scm, hatchling, poetry) • Pixi Integration: Uses Pixi tables for requirement mapping when [tool.pixi] is present • Flexible Configuration: Reads extra/override keys from [tool.conda.recipe.*] sections • License Detection: Automatically detects license types from license files • Python Version Handling: Extracts Python version constraints from requires-python

Versioning

This project uses hatch-vcs for automatic version management based on Git tags. The version is dynamically determined from Git tags and commits:

  • Tagged releases use the tag version (e.g., v0.1.00.1.0)
  • Development builds include commit information (e.g., 0.1.0.dev5+g1234567)
  • Dirty working directories append .dirty to the version

To check the current version:

pixi run version

Development

Prerequisites

  • Pixi - Modern package management for Python

Setup Development Environment

# Clone the repository
git clone https://github.com/millsks/pyrattler-recipe-autogen.git
cd pyrattler-recipe-autogen

# Install dependencies (includes editable install of the project)
pixi install

# Set up development environment (install pre-commit hooks)
pixi run dev-setup

Pre-commit Hooks

This project uses pre-commit to ensure code quality and consistency. The hooks run automatically on every commit and include:

  • Code Formatting: Ruff formatting and linting
  • Type Checking: MyPy static type analysis
  • Security Scanning: Bandit security linter
  • File Validation: YAML, TOML, JSON syntax checking
  • Git Best Practices: Large file detection, merge conflict detection
  • Commit Messages: Conventional commit format validation
  • Documentation: Markdown linting and formatting
  • GitHub Actions: Workflow file validation
# Install hooks (done automatically by dev-setup)
pixi run pre-commit-install

# Run all hooks manually
pixi run pre-commit-run

# Run specific hook
pixi run pre-commit run ruff --all-files

Development Tasks

Pixi provides convenient commands for development tasks:

# The project is automatically installed in editable mode when you run pixi install

# Run tests
pixi run test

# Run tests with coverage
pixi run test-cov

# Format code with ruff
pixi run format

# Run linting
pixi run lint

# Run type checking
pixi run typecheck

# Run all checks (lint + typecheck)
pixi run check

# Build package
pixi run build

# Clean build artifacts
pixi run clean

# Check current version
pixi run version

# Run the full CI pipeline (format + check + test-cov)
pixi run ci

# Generate changelog
pixi run changelog

# Preview unreleased changes
pixi run changelog-unreleased

# Preview latest version changes
pixi run changelog-latest

# Preview what the next release would look like
pixi run release-preview

Changelog Generation

This project uses git-cliff to automatically generate changelogs based on conventional commits:

# Generate complete changelog
pixi run changelog

# See unreleased changes
pixi run changelog-unreleased

# Preview the next release
pixi run release-preview

The changelog follows Keep a Changelog format and uses Conventional Commits for automated categorization.


### Using Different Environments

Pixi supports multiple environments for different purposes:

```bash
# Use the default development environment
pixi shell

# Use the test-only environment
pixi shell -e test

# Use the lint-only environment
pixi shell -e lint

# Run tasks in specific environments
pixi run -e test test
pixi run -e lint lint

Package Structure

The project follows a src layout:

pyrattler-recipe-autogen/
├── src/
│   └── pyrattler_recipe_autogen/
│       ├── __init__.py          # Package initialization and exports
│       ├── core.py              # Core business logic
│       └── cli.py               # Command line interface
├── tests/                       # Test suite
├── pyproject.toml              # Package configuration
├── generate_conda_recipe.py    # Legacy wrapper script
└── dev.py                      # Development utility script

Configuration

The tool reads configuration from your pyproject.toml file and supports additional conda-specific configuration under [tool.conda.recipe.*] sections:

[tool.conda.recipe.extra_context]
# Additional context variables

[tool.conda.recipe.about]
# Override about section fields

[tool.conda.recipe.build]
# Override build configuration

[tool.conda.recipe.source]
# Override source configuration

[tool.conda.recipe.test]
# Test configuration

[tool.conda.recipe.extra]
# Extra recipe sections

Releases and Contributing

Versioning and Releases

This project uses hatch-vcs for automatic version management based on git tags:

  • Development versions: Generated automatically as 0.1.devN (where N is the number of commits since the last tag)
  • Release versions: Created by pushing git tags in the format v1.0.0

Creating a Release

  1. Create and push a git tag:

    git tag v1.0.0
    git push origin v1.0.0
    
  2. Create a GitHub release from the tag, which will automatically:

    • Build the package
    • Run all tests and checks
    • Publish to PyPI
    • Update the changelog

Test Publishing

For testing the publishing process, use the manual workflow dispatch in GitHub Actions, which publishes to Test PyPI with development versions.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests: pixi run test
  5. Run checks: pixi run check
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrattler_recipe_autogen-0.1.2.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrattler_recipe_autogen-0.1.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file pyrattler_recipe_autogen-0.1.2.tar.gz.

File metadata

  • Download URL: pyrattler_recipe_autogen-0.1.2.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyrattler_recipe_autogen-0.1.2.tar.gz
Algorithm Hash digest
SHA256 77dee2ddf6d6840112a397b4f90477fe2e62b7a9e61b865093edb833b9b5570b
MD5 11ba9b279d6ab311520de3be08b6eb0e
BLAKE2b-256 58ea583dd360f1b674d873253b1689559bc524bca0f587b8edba98832384dbfb

See more details on using hashes here.

File details

Details for the file pyrattler_recipe_autogen-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyrattler_recipe_autogen-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 639a927c129cb956c712b026201871c11cd95f6fbb76ed17fce3a9cdcee1502c
MD5 913fcaa222aeec5db99edac95a0fecf1
BLAKE2b-256 6b8c54d33f65d74c263bd8ec5b9f26e9f97a992c152cb68d73d8164a526a1990

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page