Metadata-Version: 2.4
Name: pyrattler-recipe-autogen
Version: 0.1.1
Summary: Generate Rattler-Build recipe.yaml from pyproject.toml
Project-URL: homepage, https://github.com/millsks/pyrattler-recipe-autogen
Project-URL: repository, https://github.com/millsks/pyrattler-recipe-autogen.git
Project-URL: documentation, https://github.com/millsks/pyrattler-recipe-autogen.git#README
Project-URL: issues, https://github.com/millsks/pyrattler-recipe-autogen/issues
Author: millsks
License: MIT License
        
        Copyright (c) 2025 Kevin Mills
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: System :: Software Distribution
Requires-Python: >=3.9
Requires-Dist: pyyaml
Requires-Dist: tomli; python_version < '3.11'
Requires-Dist: types-pyyaml
Description-Content-Type: text/markdown

# 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)

```bash
pip install pyrattler-recipe-autogen
```

### From Source

```bash
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:

```bash
# 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:

```python
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](https://github.com/ofek/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.0` → `0.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:

```bash
pixi run version
```

## Development

### Prerequisites

- [Pixi](https://prefix.dev/docs/pixi/overview) - Modern package management for Python

### Setup Development Environment

```bash
# 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](https://pre-commit.com/) 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

```bash
# 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:

```bash
# 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](https://git-cliff.org/) to automatically generate changelogs based on conventional commits:

```bash
# 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](https://keepachangelog.com/) format and uses [Conventional Commits](https://www.conventionalcommits.org/) 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:

```toml
[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:

   ```bash
   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.
