The repository was a single file: no description of what it does, no licence and no stated limitations. The README documents the interface, the exit codes and the temporary-venv behaviour, and quotes real output from a run over seven pyenv interpreters (3.8.20 through 3.12.11).
165 lines
6.3 KiB
Markdown
165 lines
6.3 KiB
Markdown
# pyenv-check-reqs
|
|
|
|
Resolve a `requirements.txt` against **every Python version installed with
|
|
[pyenv](https://github.com/pyenv/pyenv)**, so you find out which interpreters your
|
|
pin set actually supports — before your users do.
|
|
|
|
It answers one question: *"if I `pip install -r requirements.txt` on Python 3.8,
|
|
3.9, … does a consistent set of versions exist?"*
|
|
|
|
It uses [`pip-tools`](https://github.com/jazzband/pip-tools) (`python -m piptools
|
|
compile`) as the resolver, one run per interpreter, and prints a summary of which
|
|
versions resolved and which did not. The exit status is CI-friendly.
|
|
|
|
```
|
|
$ pyenv-check-reqs --file requirements.txt
|
|
pyenv-check-reqs 1.0.0
|
|
Requirements file : requirements.txt
|
|
Versions to test : 7 (3.8.20 3.9.23 3.10.18 3.11.13 3.12.3 3.12.5 3.12.11)
|
|
|
|
==> 3.8.20
|
|
pip-tools not found in 3.8.20, building a temporary venv
|
|
resolved (pip-tools from a temporary venv)
|
|
|
|
==> 3.9.23
|
|
pip-tools not found in 3.9.23, building a temporary venv
|
|
resolved (pip-tools from a temporary venv)
|
|
...
|
|
--- Summary ---
|
|
Requirements file : requirements.txt
|
|
Versions tested : 3.8.20 3.9.23 3.10.18 3.11.13 3.12.3 3.12.5 3.12.11
|
|
|
|
Successfully resolved dependencies for:
|
|
- 3.8.20
|
|
- 3.9.23
|
|
- 3.10.18
|
|
- 3.11.13
|
|
- 3.12.3
|
|
- 3.12.5
|
|
- 3.12.11
|
|
|
|
Failed to resolve dependencies for:
|
|
None
|
|
```
|
|
|
|
Real output of `bash src/pyenv-check-reqs --file requirements.txt` on a Debian 13
|
|
box with pyenv 2.6.7 (`requests>=2.31`, `flask>=3.0`). With `flask>=3.1` the same
|
|
run reports `3.8.20 (resolution failed)` and exits `1`:
|
|
|
|
```
|
|
Successfully resolved dependencies for:
|
|
- 3.11.13
|
|
|
|
Failed to resolve dependencies for:
|
|
- 3.8.20 (resolution failed)
|
|
```
|
|
|
|
## Requirements
|
|
|
|
| | |
|
|
|---|---|
|
|
| Shell | `bash` 4.4+ (Linux and macOS) |
|
|
| Runtime | [`pyenv`](https://github.com/pyenv/pyenv) on `PATH`, with at least one interpreter installed (`pyenv install 3.12`) |
|
|
| Resolver | `pip-tools` — **optional**: if a given interpreter does not have it, `pyenv-check-reqs` installs it into a throwaway venv |
|
|
| Network | only needed when `pip-tools` has to be fetched (or set `PIP_INDEX_URL` to a mirror) |
|
|
| Tools | `sort`, `sed`, `grep`, `mktemp` — coreutils, present everywhere |
|
|
|
|
`pyenv` does **not** have to be initialised (`pyenv init -`) in your shell, and
|
|
`pyenv-virtualenv` is not required: the script calls `pyenv exec` directly.
|
|
|
|
## Installation
|
|
|
|
From the AUR (once the package is accepted):
|
|
|
|
```bash
|
|
yay -S pyenv-check-reqs # or paru -S pyenv-check-reqs
|
|
```
|
|
|
|
Manually, from a clone:
|
|
|
|
```bash
|
|
git clone https://github.com/ags-neto/pyenv-check-reqs.git
|
|
sudo install -Dm755 pyenv-check-reqs/src/pyenv-check-reqs /usr/local/bin/pyenv-check-reqs
|
|
```
|
|
|
|
Or just run it in place: `bash src/pyenv-check-reqs --file requirements.txt`.
|
|
|
|
## Usage
|
|
|
|
```
|
|
pyenv-check-reqs [options] [requirements-file]
|
|
|
|
-f, --file PATH requirements file to compile (default: requirements.txt)
|
|
--versions SPEC comma-separated list of versions and/or ranges to test
|
|
-q, --quiet print only the summary and the failures
|
|
-v, --verbose print every command and the full output of the tools
|
|
-V, --version print the version and exit
|
|
-h, --help print the help and exit
|
|
```
|
|
|
|
By default **every base interpreter that `pyenv versions --bare` reports** is
|
|
tested — there is no hardcoded version range to keep in sync with reality.
|
|
Virtualenvs (`3.12.11/envs/foo`) and aliases are skipped.
|
|
|
|
```bash
|
|
pyenv-check-reqs # requirements.txt, all interpreters
|
|
pyenv-check-reqs -f requirements-dev.txt # another file
|
|
pyenv-check-reqs --versions 3.8-3.14 # only this range
|
|
pyenv-check-reqs --versions 3.10,3.11,3.12.3 # a mixed list
|
|
pyenv-check-reqs --quiet # CI: summary only
|
|
```
|
|
|
|
### Exit status
|
|
|
|
| Code | Meaning |
|
|
|---|---|
|
|
| `0` | every selected version resolved |
|
|
| `1` | at least one selected version failed to resolve |
|
|
| `2` | usage error: unknown option, missing/unreadable file, `--versions` with no match, `pyenv` missing or unusable |
|
|
|
|
`2` also covers prerequisites that stop the check from starting at all (no
|
|
`pyenv`, no interpreter installed, nothing matching `--versions`), so a CI job can
|
|
tell "your pins are broken" (`1`) apart from "your runner is broken" (`2`).
|
|
|
|
## How it works (and what it writes)
|
|
|
|
1. `pyenv versions --bare` is filtered down to base versions (`X.Y.Z`).
|
|
2. For each version, `PYENV_VERSION=<v> pyenv exec python -m piptools compile …`
|
|
runs in a **subshell**, so your shell's `PYENV_VERSION` is never touched.
|
|
3. If that interpreter has no `pip-tools`, a temporary venv is created with
|
|
`mktemp -d`, `pip install --quiet pip-tools` runs inside it, and the whole
|
|
scratch directory is removed on exit (`EXIT INT TERM HUP` trap). Your pyenv
|
|
installations are never modified.
|
|
4. Output files and logs live in a single `$TMPDIR/pyenv-check-reqs.XXXXXXXX`
|
|
directory that always disappears. Resolution output is redirected to
|
|
`/dev/null` unless `--verbose` is given; on failure the last lines are shown.
|
|
|
|
If `pip-tools` cannot be installed, the script says so, adds a hint when the
|
|
failure looks like a network/DNS problem, and marks that version as failed
|
|
instead of dying silently.
|
|
|
|
## Limitations
|
|
|
|
- It checks **resolution**, not runtime compatibility: a requirement set that
|
|
resolves on 3.8 can still fail at import time.
|
|
- Results depend on the wheels/sdists available on the index *at that moment*;
|
|
the same file may resolve differently next week, and nothing is cached between
|
|
runs.
|
|
- Versions are tested **sequentially** (one venv, one resolver run each); a
|
|
machine with ten interpreters takes minutes, not seconds.
|
|
- Only pip-style requirements files are supported (no `pyproject.toml`,
|
|
`setup.py` or `poetry.lock`).
|
|
- Interpreter *patch* versions are all tested independently when several are
|
|
installed (e.g. 3.12.3 and 3.12.11), which is deliberate but multiplies the
|
|
runtime.
|
|
- It does not install missing interpreters with `pyenv install`; `--versions`
|
|
only filters what is already there.
|
|
- Needs network access the first time a given interpreter is missing
|
|
`pip-tools` (or a reachable `PIP_INDEX_URL`/local wheel cache).
|
|
- Developed and tested on Linux (Debian 13, Ubuntu 22.04). macOS should work —
|
|
`sort -V` on BSD is the one thing to watch — but it is untested.
|
|
|
|
## License
|
|
|
|
MIT — see [LICENSE](LICENSE). Copyright (c) 2026 Andre Neto (ags-neto).
|