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.1.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.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyrattler_recipe_autogen-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c304a461d07616f1ee79606167ae5e670fd8227cc2cda0beadfb3491723259f7
MD5 9542d0fcf9b5bf0335df1cae5b2706ff
BLAKE2b-256 397e6867ff19214b0ad9e265b722e04050dfed24e1b75159d21b531785966bf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrattler_recipe_autogen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b88c98653d6c8fa94a2c0b881b17d268394c92bf30c032eaba332105f79e86c
MD5 67fa582e7e61fe8756c5b772d6cad6e2
BLAKE2b-256 f337305fd98115bd5e3397283e94c2728baa79f29a8652406b7f3f328f52ded3

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