Metadata-Version: 2.4
Name: pep723-to-wheel
Version: 0.1.1
Summary: PoC for pep-723 script to wheel and back
Project-URL: Homepage, https://github.com/jooh/pep723-to-wheel
Project-URL: Repository, https://github.com/jooh/pep723-to-wheel
Project-URL: Issues, https://github.com/jooh/pep723-to-wheel/issues
License: MIT License
        
        Copyright (c) 2026 Johan Carlin
        
        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: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: pydantic>=2.5
Requires-Dist: tomli-w>=1.1.0
Requires-Dist: typer>=0.21.1
Description-Content-Type: text/markdown

# pep723-to-wheel

[![CI](https://github.com/jooh/pep723-to-wheel/actions/workflows/ci.yml/badge.svg)](https://github.com/jooh/pep723-to-wheel/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/pep723-to-wheel.svg)](https://pypi.org/project/pep723-to-wheel/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![codecov](https://codecov.io/gh/jooh/pep723-to-wheel/branch/main/graph/badge.svg?token=PS0IS5TVBV)](https://codecov.io/gh/jooh/pep723-to-wheel)

A small utility for converting [PEP 723](https://peps.python.org/pep-0723/) inline dependency scripts into wheels and reconstructing scripts from wheels. Especially useful for taking [reproducible Marimo notebooks](https://marimo.io/blog/sandboxed-notebooks) to production environments.

## CLI

Build a wheel from a script that has a PEP 723 inline block:

```bash
pep723-to-wheel build path/to/script.py --output-dir dist
```

Set an explicit wheel version (defaults to calendar versioning using the script mtime as the patch segment):

```bash
pep723-to-wheel build path/to/script.py --version 2024.12.25
```

Reconstruct a script from a wheel or package name:

```bash
pep723-to-wheel import path/to/package.whl --output reconstructed.py
pep723-to-wheel import requests --output reconstructed.py
```

## Library

```python
from pathlib import Path
from pep723_to_wheel import build_script_to_wheel, import_wheel_to_script

result = build_script_to_wheel(Path("script.py"))
print(result.wheel_path)

import_result = import_wheel_to_script("requests", Path("reconstructed.py"))
print(import_result.script_path)
```

## Development

```bash
make test
make typecheck
make ruff
```

## Release process

Releases are automated on pushes to `main` by the CD workflow in `.github/workflows/cd.yml`.

1. The workflow determines the latest `v*` Git tag and runs `.github/workflows/cd_version.py` to
   resolve the next version. If the latest tag matches the current major/minor, it bumps the patch
   to one higher than the max of the current patch and the tag patch.
2. If `pyproject.toml` changes, the workflow commits the version bump back to `main`.
3. It tags the release as `v<version>`, builds the wheel with `uv build --wheel`, publishes to
   PyPI, and creates a GitHub release with the wheel attached.

To trigger a release, merge or push changes to `main` and ensure `PYPI_API_TOKEN` is configured in
the repository secrets.
