Pin all dependencies in pyproject.toml to their currently installed versions
Project description
pin-versions
A CLI tool and pre-commit hook that pins all unpinned dependencies in pyproject.toml to their currently installed versions.
Why pin versions?
Unpinned dependencies (e.g. requests instead of requests==2.31.0) mean your project silently picks up whatever version happens to be newest at install time. This causes real problems:
- Broken builds -- a new release of a dependency can introduce breaking changes or bugs that suddenly fail your CI or production deploys, even though your code hasn't changed.
- "Works on my machine" -- different team members install at different times and get different versions, leading to bugs that are impossible to reproduce.
- Non-reproducible deployments -- deploying the same commit twice can produce different behavior if a dependency was updated between deploys.
- Silent security risk -- without knowing exactly what you're running, auditing your dependency tree for vulnerabilities is guesswork.
Pinning gives you control: upgrades happen when you choose, not when a package author publishes.
Why some dependencies are left unpinned
pin-versions resolves versions by checking what is currently installed in your virtual environment. A dependency will remain unpinned if:
- It isn't installed -- the package appears in
pyproject.tomlbut is not present in the target virtual environment (e.g. an optional dependency you haven't installed locally). - The package name doesn't match -- the name in
pyproject.tomldiffers from the distribution name (underscores vs hyphens, etc.) and can't be matched to an installed package. - PyPI lookup fails (when using
--pin-latest) -- if the network request to PyPI errors out, the package is left as-is rather than guessing.
In all of these cases, pin-versions reports the unpinned packages so you can address them. You can use --pin-latest to automatically fetch the latest version from PyPI for any package that isn't installed locally.
Installation
pip install pin-versions
Or with uv:
uv add pin-versions
Usage
Run in a project directory with a pyproject.toml and a virtual environment:
pin-versions
This pins dependencies in [project].dependencies, [project.optional-dependencies], and [dependency-groups].
Options
| Flag | Description |
|---|---|
--operator, -o |
Version pin operator (default: ==). Supports >=, ~=, etc. |
--pyproject, -p |
Path to pyproject.toml (default: ./pyproject.toml) |
--venv |
Path to the virtual environment (default: .venv) |
--pin-latest |
Pin uninstalled packages to their latest version on PyPI |
--dry-run |
Preview changes without modifying the file |
Pre-commit hook
Add to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/kjaymiller/pin-versions
rev: v0.1.0
hooks:
- id: pin-versions
Contributing
- Fork the repo and clone it locally.
- Create a virtual environment and install the project in editable mode:
uv venv && uv pip install -e ".[dev]"
- Create a branch for your changes:
git checkout -b my-feature
- Make your changes and ensure they work by running:
pin-versions --dry-run - Open a pull request against
main.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pin_versions-2026.3.3.tar.gz.
File metadata
- Download URL: pin_versions-2026.3.3.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62a04355e967292e58ffe58df5865135e78db961e65c586480a230389efa7c73
|
|
| MD5 |
ea9491a295cbede0d82c0a0f0213e1ac
|
|
| BLAKE2b-256 |
51e14c92b2550f33a5fdd0a02bfb184b0f2f7d90963fde5fd95241693a46c21a
|
Provenance
The following attestation bundles were made for pin_versions-2026.3.3.tar.gz:
Publisher:
publish.yml on kjaymiller/pin-versions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pin_versions-2026.3.3.tar.gz -
Subject digest:
62a04355e967292e58ffe58df5865135e78db961e65c586480a230389efa7c73 - Sigstore transparency entry: 1154841088
- Sigstore integration time:
-
Permalink:
kjaymiller/pin-versions@15428e151933a71470da4bc14f58c3765484950d -
Branch / Tag:
refs/tags/2026.3.3 - Owner: https://github.com/kjaymiller
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15428e151933a71470da4bc14f58c3765484950d -
Trigger Event:
release
-
Statement type:
File details
Details for the file pin_versions-2026.3.3-py3-none-any.whl.
File metadata
- Download URL: pin_versions-2026.3.3-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d9894e85f3b3200e29d9038ab7f215229086dc20873541a3e1bb1c3854468f
|
|
| MD5 |
cf7ed3f6a51885c99ab1ce76ac03e573
|
|
| BLAKE2b-256 |
d93a84bfc795921ac0daa01706057cc1eafd01ce6fa8990d3116dd1f8bb4bc1c
|
Provenance
The following attestation bundles were made for pin_versions-2026.3.3-py3-none-any.whl:
Publisher:
publish.yml on kjaymiller/pin-versions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pin_versions-2026.3.3-py3-none-any.whl -
Subject digest:
71d9894e85f3b3200e29d9038ab7f215229086dc20873541a3e1bb1c3854468f - Sigstore transparency entry: 1154841104
- Sigstore integration time:
-
Permalink:
kjaymiller/pin-versions@15428e151933a71470da4bc14f58c3765484950d -
Branch / Tag:
refs/tags/2026.3.3 - Owner: https://github.com/kjaymiller
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@15428e151933a71470da4bc14f58c3765484950d -
Trigger Event:
release
-
Statement type: