canibuild
Find the dependencies in your lockfile that will fail to build from source, before you
run pip install, uv sync or poetry install. For each one, canibuild tells you why
and gives you the one-line fix for your tool.
setuptools 82 removed pkg_resources. Every sdist whose setup.py still imports it now
fails in a fresh isolated build with ModuleNotFoundError: No module named 'pkg_resources',
and pinning setuptools in your own environment doesn't help, because the build gets its
own, newest setuptools. canibuild reads your lockfile, works out which packages have no
wheel for your Python and platform, opens their sdists without running them, and reports
what will break.
$ pip install canibuild
$ canibuild uv.lock
Example
This is the uv.lock of a public project (geosp/mcp-bible
at 904dc66), whose uv sync broke on flatdict 4.0.1:
$ canibuild check uv.lock --python 3.12 --platform linux-x86_64
canibuild: uv.lock for CPython 3.12 on linux-x86_64
81 packages checked, 1 build from source, 1 will fail, 0 may fail
SEVERITY PACKAGE VERSION RULE PROBLEM
ERROR flatdict 4.0.1 pkg-resources setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
flatdict 4.0.1: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
at setup.py:1: import pkg_resources
fix (any): Upgrade flatdict to 4.1.0, the first newer release with a wheel for this target
uv lock --upgrade-package 'flatdict>=4.1.0'
fix (uv): Constrain setuptools in flatdict's build (pyproject.toml)
[tool.uv.extra-build-dependencies]
flatdict = ["setuptools<82"]
fix (uv): Or constrain it for every build (pyproject.toml)
[tool.uv]
build-constraint-dependencies = ["setuptools<82"]
Not checked: 1 (mcp-weather: git source, not checked)
The run took under a second with a warm cache. It exits with status 1, so it can gate CI.
For a requirements.txt that pins openai-whisper==20231117, which has no wheels at all:
$ canibuild requirements.txt --python 3.12 --platform linux-x86_64
...
openai-whisper 20231117: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
at setup.py:5: import pkg_resources
fix (any): Upgrade openai-whisper to 20250625, the first newer release whose sdist has none of these problems
openai-whisper>=20250625 # in requirements
fix (uv pip): Pass a build constraints file
echo 'setuptools<82' > build-constraints.txt
uv pip install -b build-constraints.txt -r requirements.txt
fix (pip): Pass a build constraints file (pip 25.3+)
echo 'setuptools<82' > build-constraints.txt
pip install --build-constraint build-constraints.txt -r requirements.txt
fix (pip): pip older than 25.3: use PIP_CONSTRAINT (ignored for builds since pip 26.2)
echo 'setuptools<82' > build-constraints.txt
PIP_CONSTRAINT=build-constraints.txt pip install -r requirements.txt
Builds from source with no known problem: deepspeed 0.20.2 (compiles native code), langid 1.1.6, textgrid 1.6.1
What it checks
canibuild only looks at packages that will be built from source: those with no wheel
matching the target interpreter and platform. For each of them it downloads the sdist
(cached), reads pyproject.toml, setup.py, setup.cfg and the local modules setup.py
imports, and parses them with ast. It never runs code from a package.
| Rule | Fails when |
|---|---|
pkg-resources |
setup.py (or a local module it imports) imports pkg_resources and the build would get setuptools 82 or newer |
build-tool-needs-pkg-resources |
setup_requires or build-system.requires pins setuptools-scm older than 6.3 or pbr older than 7.0, which import pkg_resources themselves |
setuptools-easy-install, setuptools-test-command, setuptools-dep-util, setuptools-use-2to3 |
setup.py uses a setuptools API that was removed (in 80.3, 72, 70 and 58) and the build gets a newer setuptools |
numpy-distutils |
setup.py imports numpy.distutils, which doesn't exist on Python 3.12+ or with NumPy 2 |
distutils |
setup.py imports distutils on Python 3.12+ and setuptools isn't in the build |
missing-build-requires |
setup.py imports a module at top level (such as torch or numpy) that the sdist doesn't declare in build-system.requires, so the isolated build can't import it |
no-installable-file |
there is no wheel for the target and no sdist |
An import inside a try: ... except ImportError is ignored. An import inside a function
is reported as a warning, since it fails only if that code runs during the build.
Packages that build from source with no known problem are listed as such, with a note
when they compile native code.
The setuptools version a build would get is worked out from the sdist's own
build-system.requires (or pip's and uv's default of setuptools>=40.8.0 when it has
none) and the setuptools releases on PyPI, so a package that already caps
setuptools<82 isn't flagged.
Fixes
Every finding comes with fixes for the tool that matches your lockfile (uv.lock gets
uv, pylock.toml and requirements files get pip and uv pip). Pass --tool to choose
(uv, uv-pip, pip, poetry or all).
| Tool | Fix for a build that needs setuptools<82 |
|---|---|
| uv | [tool.uv.extra-build-dependencies] pkg = ["setuptools<82"], or [tool.uv] build-constraint-dependencies = ["setuptools<82"] |
| uv pip | uv pip install -b build-constraints.txt ... |
| pip 25.3+ | pip install --build-constraint build-constraints.txt ... (or PIP_BUILD_CONSTRAINT) |
| pip older than 25.3 | PIP_CONSTRAINT=build-constraints.txt pip install ... (pip 26.2 stopped applying this to builds) |
| Poetry 2.3+ | [tool.poetry.build-constraints] pkg = { setuptools = "<82" }, then poetry lock |
Each of these was checked against flatdict==4.0.1 with uv 0.13, pip 26.3 and 25.1, and
Poetry 2.5: the install fails without the fix and succeeds with it. When a newer release
of the package has a wheel for your target, or an sdist without the problem, canibuild
suggests upgrading to the oldest such release first.
Note that uv's own hint for this error suggests adding pkg_resources to
extra-build-dependencies. That can't work: pkg_resources isn't a package on PyPI.
Tested on real lockfiles
canibuild was run on 13 lockfiles from public repositories (5 uv.lock, 8 requirements
files). Then every sdist those lockfiles would build was actually built, in a fresh
environment with uv pip install --no-deps, to see which builds really fail.
- 26 packages would build from source (23 distinct package versions).
- 10 of them really fail:
flatdict4.0.1 (2 lockfiles),openai-whisper20231117 (2) and 20240930 (2),salib1.3.12 andmmcv2.2.0 importpkg_resources;flash-attn2.8.3.post2 importstorchwithout declaring it;faiss-cpu1.7.4 has no wheel for Python 3.12 and no sdist. - canibuild reported all 10 with the right cause, and none of the 16 that built fine.
- With the suggested
setuptools<82build constraint, all five distinctpkg_resourcesfailures build.jproperties2.1.2 built from source (itssetup_requirespins setuptools-scm 3.x) is caught bybuild-tool-needs-pkg-resources, fails for real, and builds with the same constraint.
The lockfiles, their commits and the per-package results are in
docs/validation.md.
Usage
canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
[--fail-on error|warning|never] [--tool TOOL] [--jobs N]
[--cache-dir DIR] [--no-cache] [-v]
LOCKFILE:uv.lock,pylock.toml(orpylock.NAME.toml), or a requirements file. Requirements files may include other files with-r. Unpinned requirements are checked at the newest release that matches and supports the target Python.--python: the target Python, such as3.12. Defaults to the running interpreter, or to the oldest version auv.lockorpylock.tomlallows when the running one is outside itsrequires-python.--platform:linux-x86_64,linux-aarch64,musllinux-x86_64,musllinux-aarch64,macos-arm64,macos-x86_64,windows-amd64,windows-arm64,windows-x86, or a raw platform tag such asmanylinux_2_28_x86_64. Defaults to the current machine.--format json: machine-readable output with every finding and fix.--fail-on: exit with 1 on errors (the default), on warnings too, or never. Usage errors and unreadable lockfiles exit with 2.
Downloaded sdists are cached in the user cache directory (~/.cache/canibuild on Linux,
or $CANIBUILD_CACHE_DIR).
Limits
- Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
other indexes (such as
torch==2.1.2+cu121), are listed as not checked. - The checks are static. A
setup.pythat fails for a reason not in the table above, or that needs a compiler or system library you don't have, isn't caught. - Requirements files are not resolved: only the packages they list are checked, not their
dependencies. Use a lockfile (
uv.lock,pylock.toml, orpip-compileoutput) for the full tree.
License
MIT
Metadata
Release files for canibuild 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| canibuild-0.1.0.tar.gz | 45.6 kB | Without provenance | Details for canibuild-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| canibuild-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for canibuild-0.1.0-py3-none-any.whl |
Total release size: 81.2 kB
Release files / canibuild-0.1.0.tar.gz
| Download URL | canibuild-0.1.0.tar.gz |
|---|---|
| Size | 45.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1bd3787efd00a6f429aba3c7744d9bcf618d6731bc82694af1d6b78a0594d7c
|
|
BLAKE2b-256 checksum How to use checksums |
99bbdad27bb564ffb3804d738a6037f6c9ee7de20e6769333ce37c8db491edac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Release files / canibuild-0.1.0-py3-none-any.whl
| Download URL | canibuild-0.1.0-py3-none-any.whl |
|---|---|
| Size | 35.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10113140de5379d4667d47d11aafb93fce3803d7200e090de8cb69eac5192e42
|
|
BLAKE2b-256 checksum How to use checksums |
5753c2945764d0388a2205648ede6c1b63b166eec18d87265fec8e2a5588a6a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.16
|
Security for canibuild 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.