Metadata-Version: 2.4
Name: compatbounds
Version: 1.0.1
Summary: Test a Python project against its lowest and highest allowed direct dependencies
Author: KOeker
License-Expression: MIT
Project-URL: Homepage, https://github.com/KOeker/compat-bounds
Project-URL: Issues, https://github.com/KOeker/compat-bounds/issues
Project-URL: Source, https://github.com/KOeker/compat-bounds
Keywords: dependencies,testing,uv,compatibility
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# CompatBounds

[![Version](https://img.shields.io/badge/version-1.0.1-blue.svg)](https://github.com/KOeker/compat-bounds/releases)
[![Total Downloads](https://img.shields.io/pepy/dt/compatbounds)](https://pypi.org/project/compatbounds/)
[![CI](https://github.com/KOeker/compat-bounds/actions/workflows/ci.yml/badge.svg)](https://github.com/KOeker/compat-bounds/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

A lightweight Python CLI for testing a project against the lowest and latest versions allowed by its **direct dependencies**. CompatBounds uses [uv](https://docs.astral.sh/uv/) for resolution and runs your test command in two isolated environments.

## ✨ Features

- **Both dependency bounds** – Test with uv's `lowest-direct` and `highest` resolution strategies
- **Real installed versions** – See which direct dependencies each environment actually contains
- **Project extras** – Include an optional dependency group such as `test`
- **Clean isolation** – Install and test a temporary project copy; remove both environments afterward
- **Useful exit codes** – Tell test failures apart from configuration and tool errors

## Installation

Install uv and CompatBounds with Python 3.11 or newer:

```bash
python -m pip install uv
python -m pip install compatbounds
```

For a local checkout, use `python -m pip install .`. You can also install the tagged source with `python -m pip install git+https://github.com/KOeker/compat-bounds.git@v1.0.1`.

## Quick Start

From the root of the Python project you want to test:

```bash
compatbounds check --extra test -- python -m pytest -q
```

The project must define a `[project]` table in `pyproject.toml`. The `test` extra must exist in `[project.optional-dependencies]`. Everything after `--` is the test command and its arguments.

## Full Examples

### Run tests without an extra

```bash
compatbounds check -- python -m unittest discover -s tests -v
```

### Check a project's test extra

```toml
[project]
name = "my-project"
version = "0.1.0"
dependencies = ["packaging>=24,<27"]

[project.optional-dependencies]
test = ["pytest>=8.4,<9"]
```

```bash
compatbounds check --extra test -- python -m pytest -q
```

The runnable version of this example is in [`examples/sample_project`](examples/sample_project). A successful run reports the installed `packaging` and `pytest` versions separately for `lowest-direct` and `highest`.

### Use the result in CI

```bash
compatbounds check --extra test -- python -m pytest -q
```

The process exits with **0** when both runs pass, **1** when a test run fails, and **2** for configuration, uv, installation, or command startup errors. If the first test run fails, CompatBounds still runs the second one.

## CLI Options

| Option | Description | Example |
|--------|-------------|---------|
| `check` | Run the command at both dependency bounds | `compatbounds check -- python -m unittest` |
| `--extra NAME` | Install one optional dependency extra | `--extra test` |
| `-- COMMAND...` | Pass a command and its arguments without a shell | `-- python -m pytest -q` |
| `--version` | Show the installed CompatBounds version | `compatbounds --version` |

`python` runs from each temporary environment. Other executables are found through that environment's `PATH`. CompatBounds reads the direct requirements from the project's metadata and reports requirements excluded by environment markers as inactive.

## How It Works

CompatBounds copies the project to a temporary directory, creates two virtual environments with the current Python interpreter, and installs the copy once with `uv pip install --resolution lowest-direct` and once with `--resolution highest`. It runs the test command from the temporary copy in each environment. The copy and environments are removed even when a check fails; the original project and its lockfiles are not written to by CompatBounds.

## Requirements

- Python 3.11 or newer
- [uv](https://docs.astral.sh/uv/getting-started/installation/) available on `PATH`
- A Python project with PEP 621 metadata in `pyproject.toml`

Version 1.0.1 uses the current interpreter only. Python version matrices and other package managers are outside its scope. uv may contact configured package indexes during installation.

## Development

```bash
python -m pip install -e .
python -m unittest discover -s tests -v
python -m build
```

## License

The MIT License (MIT). See the [License File](LICENSE).

## Support

Issues or suggestions? [Open an issue on GitHub](https://github.com/KOeker/compat-bounds/issues).
