canibuild 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- canibuild-0.1.0/.github/workflows/tests.yml +43 -0
- canibuild-0.1.0/.gitignore +9 -0
- canibuild-0.1.0/CHANGELOG.md +16 -0
- canibuild-0.1.0/LICENSE +21 -0
- canibuild-0.1.0/PKG-INFO +207 -0
- canibuild-0.1.0/README.md +175 -0
- canibuild-0.1.0/docs/validation.md +78 -0
- canibuild-0.1.0/pyproject.toml +63 -0
- canibuild-0.1.0/src/canibuild/__init__.py +3 -0
- canibuild-0.1.0/src/canibuild/__main__.py +5 -0
- canibuild-0.1.0/src/canibuild/check.py +391 -0
- canibuild-0.1.0/src/canibuild/cli.py +163 -0
- canibuild-0.1.0/src/canibuild/fixes.py +163 -0
- canibuild-0.1.0/src/canibuild/lockfiles.py +576 -0
- canibuild-0.1.0/src/canibuild/model.py +102 -0
- canibuild-0.1.0/src/canibuild/py.typed +0 -0
- canibuild-0.1.0/src/canibuild/pypi.py +196 -0
- canibuild-0.1.0/src/canibuild/report.py +145 -0
- canibuild-0.1.0/src/canibuild/rules.py +858 -0
- canibuild-0.1.0/src/canibuild/sdist.py +199 -0
- canibuild-0.1.0/src/canibuild/target.py +282 -0
- canibuild-0.1.0/tests/conftest.py +39 -0
- canibuild-0.1.0/tests/fixtures/base.txt +4 -0
- canibuild-0.1.0/tests/fixtures/pylock.toml +53 -0
- canibuild-0.1.0/tests/fixtures/requirements.txt +16 -0
- canibuild-0.1.0/tests/fixtures/uv.lock +91 -0
- canibuild-0.1.0/tests/test_check.py +412 -0
- canibuild-0.1.0/tests/test_cli.py +231 -0
- canibuild-0.1.0/tests/test_fixes.py +136 -0
- canibuild-0.1.0/tests/test_lockfiles.py +255 -0
- canibuild-0.1.0/tests/test_pypi.py +135 -0
- canibuild-0.1.0/tests/test_report.py +45 -0
- canibuild-0.1.0/tests/test_rules.py +496 -0
- canibuild-0.1.0/tests/test_sdist.py +108 -0
- canibuild-0.1.0/tests/test_target.py +108 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [main]
|
|
5
|
+
pull_request:
|
|
6
|
+
jobs:
|
|
7
|
+
lint:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v4
|
|
11
|
+
- uses: actions/setup-python@v5
|
|
12
|
+
with:
|
|
13
|
+
python-version: "3.13"
|
|
14
|
+
- run: pip install -e ".[dev]"
|
|
15
|
+
- run: ruff format --check src tests
|
|
16
|
+
- run: ruff check src tests
|
|
17
|
+
- run: mypy
|
|
18
|
+
|
|
19
|
+
test:
|
|
20
|
+
runs-on: ${{ matrix.os }}
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
25
|
+
python-version: ["3.10", "3.13", "3.14"]
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
- run: pip install -e ".[dev]"
|
|
32
|
+
- run: pytest
|
|
33
|
+
|
|
34
|
+
package:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
- uses: actions/setup-python@v5
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.13"
|
|
41
|
+
- run: pip install build twine
|
|
42
|
+
- run: python -m build
|
|
43
|
+
- run: twine check dist/*
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-12-05)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- Reads `uv.lock`, `pylock.toml` and requirements files (with `-r` includes), keeping
|
|
8
|
+
only the packages the target Python and platform need.
|
|
9
|
+
- Finds the packages with no wheel for the target, inspects their sdists without running
|
|
10
|
+
them, and reports builds that will fail: `pkg_resources` with setuptools 82+, old
|
|
11
|
+
setuptools-scm and pbr pins, removed setuptools APIs, `numpy.distutils`, `distutils` on
|
|
12
|
+
Python 3.12+, undeclared build imports such as `torch`, and releases with nothing to
|
|
13
|
+
install.
|
|
14
|
+
- Gives fixes for uv, uv pip, pip and Poetry, and suggests the oldest newer release that
|
|
15
|
+
installs cleanly.
|
|
16
|
+
- Text and JSON output; exits with 1 when something will fail.
|
canibuild-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 driftwright
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
canibuild-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: canibuild
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Check a lockfile for dependencies that will fail to build from source, before you install.
|
|
5
|
+
Project-URL: Homepage, https://github.com/driftwright/canibuild
|
|
6
|
+
Project-URL: Issues, https://github.com/driftwright/canibuild/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/driftwright/canibuild/blob/main/CHANGELOG.md
|
|
8
|
+
Author: driftwright
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: lockfile,packaging,pip,pkg_resources,poetry,sdist,setuptools,uv
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
22
|
+
Classifier: Topic :: System :: Software Distribution
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: packaging>=24
|
|
26
|
+
Requires-Dist: tomli>=2; python_version < '3.11'
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff==0.17.6; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# canibuild
|
|
34
|
+
|
|
35
|
+
Find the dependencies in your lockfile that will fail to build from source, before you
|
|
36
|
+
run `pip install`, `uv sync` or `poetry install`. For each one, canibuild tells you why
|
|
37
|
+
and gives you the one-line fix for your tool.
|
|
38
|
+
|
|
39
|
+
setuptools 82 removed `pkg_resources`. Every sdist whose `setup.py` still imports it now
|
|
40
|
+
fails in a fresh isolated build with `ModuleNotFoundError: No module named 'pkg_resources'`,
|
|
41
|
+
and pinning setuptools in your own environment doesn't help, because the build gets its
|
|
42
|
+
own, newest setuptools. canibuild reads your lockfile, works out which packages have no
|
|
43
|
+
wheel for your Python and platform, opens their sdists without running them, and reports
|
|
44
|
+
what will break.
|
|
45
|
+
|
|
46
|
+
```console
|
|
47
|
+
$ pip install canibuild
|
|
48
|
+
$ canibuild uv.lock
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Example
|
|
52
|
+
|
|
53
|
+
This is the `uv.lock` of a public project ([geosp/mcp-bible](https://github.com/geosp/mcp-bible)
|
|
54
|
+
at `904dc66`), whose `uv sync` broke on `flatdict` 4.0.1:
|
|
55
|
+
|
|
56
|
+
```console
|
|
57
|
+
$ canibuild check uv.lock --python 3.12 --platform linux-x86_64
|
|
58
|
+
canibuild: uv.lock for CPython 3.12 on linux-x86_64
|
|
59
|
+
81 packages checked, 1 build from source, 1 will fail, 0 may fail
|
|
60
|
+
|
|
61
|
+
SEVERITY PACKAGE VERSION RULE PROBLEM
|
|
62
|
+
ERROR flatdict 4.0.1 pkg-resources setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
63
|
+
|
|
64
|
+
flatdict 4.0.1: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
65
|
+
at setup.py:1: import pkg_resources
|
|
66
|
+
fix (any): Upgrade flatdict to 4.1.0, the first newer release with a wheel for this target
|
|
67
|
+
uv lock --upgrade-package 'flatdict>=4.1.0'
|
|
68
|
+
fix (uv): Constrain setuptools in flatdict's build (pyproject.toml)
|
|
69
|
+
[tool.uv.extra-build-dependencies]
|
|
70
|
+
flatdict = ["setuptools<82"]
|
|
71
|
+
fix (uv): Or constrain it for every build (pyproject.toml)
|
|
72
|
+
[tool.uv]
|
|
73
|
+
build-constraint-dependencies = ["setuptools<82"]
|
|
74
|
+
|
|
75
|
+
Not checked: 1 (mcp-weather: git source, not checked)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The run took under a second with a warm cache. It exits with status 1, so it can gate CI.
|
|
79
|
+
|
|
80
|
+
For a `requirements.txt` that pins `openai-whisper==20231117`, which has no wheels at all:
|
|
81
|
+
|
|
82
|
+
```console
|
|
83
|
+
$ canibuild requirements.txt --python 3.12 --platform linux-x86_64
|
|
84
|
+
...
|
|
85
|
+
openai-whisper 20231117: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
86
|
+
at setup.py:5: import pkg_resources
|
|
87
|
+
fix (any): Upgrade openai-whisper to 20250625, the first newer release whose sdist has none of these problems
|
|
88
|
+
openai-whisper>=20250625 # in requirements
|
|
89
|
+
fix (uv pip): Pass a build constraints file
|
|
90
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
91
|
+
uv pip install -b build-constraints.txt -r requirements.txt
|
|
92
|
+
fix (pip): Pass a build constraints file (pip 25.3+)
|
|
93
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
94
|
+
pip install --build-constraint build-constraints.txt -r requirements.txt
|
|
95
|
+
fix (pip): pip older than 25.3: use PIP_CONSTRAINT (ignored for builds since pip 26.2)
|
|
96
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
97
|
+
PIP_CONSTRAINT=build-constraints.txt pip install -r requirements.txt
|
|
98
|
+
|
|
99
|
+
Builds from source with no known problem: deepspeed 0.20.2 (compiles native code), langid 1.1.6, textgrid 1.6.1
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## What it checks
|
|
103
|
+
|
|
104
|
+
canibuild only looks at packages that will be built from source: those with no wheel
|
|
105
|
+
matching the target interpreter and platform. For each of them it downloads the sdist
|
|
106
|
+
(cached), reads `pyproject.toml`, `setup.py`, `setup.cfg` and the local modules `setup.py`
|
|
107
|
+
imports, and parses them with `ast`. It never runs code from a package.
|
|
108
|
+
|
|
109
|
+
| Rule | Fails when |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `pkg-resources` | `setup.py` (or a local module it imports) imports `pkg_resources` and the build would get setuptools 82 or newer |
|
|
112
|
+
| `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 |
|
|
113
|
+
| `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 |
|
|
114
|
+
| `numpy-distutils` | `setup.py` imports `numpy.distutils`, which doesn't exist on Python 3.12+ or with NumPy 2 |
|
|
115
|
+
| `distutils` | `setup.py` imports `distutils` on Python 3.12+ and setuptools isn't in the build |
|
|
116
|
+
| `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 |
|
|
117
|
+
| `no-installable-file` | there is no wheel for the target and no sdist |
|
|
118
|
+
|
|
119
|
+
An import inside a `try: ... except ImportError` is ignored. An import inside a function
|
|
120
|
+
is reported as a warning, since it fails only if that code runs during the build.
|
|
121
|
+
Packages that build from source with no known problem are listed as such, with a note
|
|
122
|
+
when they compile native code.
|
|
123
|
+
|
|
124
|
+
The setuptools version a build would get is worked out from the sdist's own
|
|
125
|
+
`build-system.requires` (or pip's and uv's default of `setuptools>=40.8.0` when it has
|
|
126
|
+
none) and the setuptools releases on PyPI, so a package that already caps
|
|
127
|
+
`setuptools<82` isn't flagged.
|
|
128
|
+
|
|
129
|
+
## Fixes
|
|
130
|
+
|
|
131
|
+
Every finding comes with fixes for the tool that matches your lockfile (`uv.lock` gets
|
|
132
|
+
uv, `pylock.toml` and requirements files get pip and `uv pip`). Pass `--tool` to choose
|
|
133
|
+
(`uv`, `uv-pip`, `pip`, `poetry` or `all`).
|
|
134
|
+
|
|
135
|
+
| Tool | Fix for a build that needs `setuptools<82` |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| uv | `[tool.uv.extra-build-dependencies]` `pkg = ["setuptools<82"]`, or `[tool.uv] build-constraint-dependencies = ["setuptools<82"]` |
|
|
138
|
+
| uv pip | `uv pip install -b build-constraints.txt ...` |
|
|
139
|
+
| pip 25.3+ | `pip install --build-constraint build-constraints.txt ...` (or `PIP_BUILD_CONSTRAINT`) |
|
|
140
|
+
| pip older than 25.3 | `PIP_CONSTRAINT=build-constraints.txt pip install ...` (pip 26.2 stopped applying this to builds) |
|
|
141
|
+
| Poetry 2.3+ | `[tool.poetry.build-constraints]` `pkg = { setuptools = "<82" }`, then `poetry lock` |
|
|
142
|
+
|
|
143
|
+
Each of these was checked against `flatdict==4.0.1` with uv 0.13, pip 26.3 and 25.1, and
|
|
144
|
+
Poetry 2.5: the install fails without the fix and succeeds with it. When a newer release
|
|
145
|
+
of the package has a wheel for your target, or an sdist without the problem, canibuild
|
|
146
|
+
suggests upgrading to the oldest such release first.
|
|
147
|
+
|
|
148
|
+
Note that uv's own hint for this error suggests adding `pkg_resources` to
|
|
149
|
+
`extra-build-dependencies`. That can't work: `pkg_resources` isn't a package on PyPI.
|
|
150
|
+
|
|
151
|
+
## Tested on real lockfiles
|
|
152
|
+
|
|
153
|
+
canibuild was run on 13 lockfiles from public repositories (5 `uv.lock`, 8 requirements
|
|
154
|
+
files). Then every sdist those lockfiles would build was actually built, in a fresh
|
|
155
|
+
environment with `uv pip install --no-deps`, to see which builds really fail.
|
|
156
|
+
|
|
157
|
+
- 26 packages would build from source (23 distinct package versions).
|
|
158
|
+
- 10 of them really fail: `flatdict` 4.0.1 (2 lockfiles), `openai-whisper` 20231117 (2)
|
|
159
|
+
and 20240930 (2), `salib` 1.3.12 and `mmcv` 2.2.0 import `pkg_resources`; `flash-attn`
|
|
160
|
+
2.8.3.post2 imports `torch` without declaring it; `faiss-cpu` 1.7.4 has no wheel for
|
|
161
|
+
Python 3.12 and no sdist.
|
|
162
|
+
- canibuild reported all 10 with the right cause, and none of the 16 that built fine.
|
|
163
|
+
- With the suggested `setuptools<82` build constraint, all five distinct `pkg_resources`
|
|
164
|
+
failures build. `jproperties` 2.1.2 built from source (its `setup_requires` pins
|
|
165
|
+
setuptools-scm 3.x) is caught by `build-tool-needs-pkg-resources`, fails for real, and
|
|
166
|
+
builds with the same constraint.
|
|
167
|
+
|
|
168
|
+
The lockfiles, their commits and the per-package results are in
|
|
169
|
+
[`docs/validation.md`](docs/validation.md).
|
|
170
|
+
|
|
171
|
+
## Usage
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
|
|
175
|
+
[--fail-on error|warning|never] [--tool TOOL] [--jobs N]
|
|
176
|
+
[--cache-dir DIR] [--no-cache] [-v]
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- `LOCKFILE`: `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
|
|
180
|
+
Requirements files may include other files with `-r`. Unpinned requirements are checked
|
|
181
|
+
at the newest release that matches and supports the target Python.
|
|
182
|
+
- `--python`: the target Python, such as `3.12`. Defaults to the running interpreter, or
|
|
183
|
+
to the oldest version a `uv.lock` or `pylock.toml` allows when the running one is outside
|
|
184
|
+
its `requires-python`.
|
|
185
|
+
- `--platform`: `linux-x86_64`, `linux-aarch64`, `musllinux-x86_64`, `musllinux-aarch64`,
|
|
186
|
+
`macos-arm64`, `macos-x86_64`, `windows-amd64`, `windows-arm64`, `windows-x86`, or a raw
|
|
187
|
+
platform tag such as `manylinux_2_28_x86_64`. Defaults to the current machine.
|
|
188
|
+
- `--format json`: machine-readable output with every finding and fix.
|
|
189
|
+
- `--fail-on`: exit with 1 on errors (the default), on warnings too, or never.
|
|
190
|
+
Usage errors and unreadable lockfiles exit with 2.
|
|
191
|
+
|
|
192
|
+
Downloaded sdists are cached in the user cache directory (`~/.cache/canibuild` on Linux,
|
|
193
|
+
or `$CANIBUILD_CACHE_DIR`).
|
|
194
|
+
|
|
195
|
+
## Limits
|
|
196
|
+
|
|
197
|
+
- Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
|
|
198
|
+
other indexes (such as `torch==2.1.2+cu121`), are listed as not checked.
|
|
199
|
+
- The checks are static. A `setup.py` that fails for a reason not in the table above, or
|
|
200
|
+
that needs a compiler or system library you don't have, isn't caught.
|
|
201
|
+
- Requirements files are not resolved: only the packages they list are checked, not their
|
|
202
|
+
dependencies. Use a lockfile (`uv.lock`, `pylock.toml`, or `pip-compile` output) for the
|
|
203
|
+
full tree.
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
MIT
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# canibuild
|
|
2
|
+
|
|
3
|
+
Find the dependencies in your lockfile that will fail to build from source, before you
|
|
4
|
+
run `pip install`, `uv sync` or `poetry install`. For each one, canibuild tells you why
|
|
5
|
+
and gives you the one-line fix for your tool.
|
|
6
|
+
|
|
7
|
+
setuptools 82 removed `pkg_resources`. Every sdist whose `setup.py` still imports it now
|
|
8
|
+
fails in a fresh isolated build with `ModuleNotFoundError: No module named 'pkg_resources'`,
|
|
9
|
+
and pinning setuptools in your own environment doesn't help, because the build gets its
|
|
10
|
+
own, newest setuptools. canibuild reads your lockfile, works out which packages have no
|
|
11
|
+
wheel for your Python and platform, opens their sdists without running them, and reports
|
|
12
|
+
what will break.
|
|
13
|
+
|
|
14
|
+
```console
|
|
15
|
+
$ pip install canibuild
|
|
16
|
+
$ canibuild uv.lock
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
This is the `uv.lock` of a public project ([geosp/mcp-bible](https://github.com/geosp/mcp-bible)
|
|
22
|
+
at `904dc66`), whose `uv sync` broke on `flatdict` 4.0.1:
|
|
23
|
+
|
|
24
|
+
```console
|
|
25
|
+
$ canibuild check uv.lock --python 3.12 --platform linux-x86_64
|
|
26
|
+
canibuild: uv.lock for CPython 3.12 on linux-x86_64
|
|
27
|
+
81 packages checked, 1 build from source, 1 will fail, 0 may fail
|
|
28
|
+
|
|
29
|
+
SEVERITY PACKAGE VERSION RULE PROBLEM
|
|
30
|
+
ERROR flatdict 4.0.1 pkg-resources setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
31
|
+
|
|
32
|
+
flatdict 4.0.1: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
33
|
+
at setup.py:1: import pkg_resources
|
|
34
|
+
fix (any): Upgrade flatdict to 4.1.0, the first newer release with a wheel for this target
|
|
35
|
+
uv lock --upgrade-package 'flatdict>=4.1.0'
|
|
36
|
+
fix (uv): Constrain setuptools in flatdict's build (pyproject.toml)
|
|
37
|
+
[tool.uv.extra-build-dependencies]
|
|
38
|
+
flatdict = ["setuptools<82"]
|
|
39
|
+
fix (uv): Or constrain it for every build (pyproject.toml)
|
|
40
|
+
[tool.uv]
|
|
41
|
+
build-constraint-dependencies = ["setuptools<82"]
|
|
42
|
+
|
|
43
|
+
Not checked: 1 (mcp-weather: git source, not checked)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The run took under a second with a warm cache. It exits with status 1, so it can gate CI.
|
|
47
|
+
|
|
48
|
+
For a `requirements.txt` that pins `openai-whisper==20231117`, which has no wheels at all:
|
|
49
|
+
|
|
50
|
+
```console
|
|
51
|
+
$ canibuild requirements.txt --python 3.12 --platform linux-x86_64
|
|
52
|
+
...
|
|
53
|
+
openai-whisper 20231117: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
54
|
+
at setup.py:5: import pkg_resources
|
|
55
|
+
fix (any): Upgrade openai-whisper to 20250625, the first newer release whose sdist has none of these problems
|
|
56
|
+
openai-whisper>=20250625 # in requirements
|
|
57
|
+
fix (uv pip): Pass a build constraints file
|
|
58
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
59
|
+
uv pip install -b build-constraints.txt -r requirements.txt
|
|
60
|
+
fix (pip): Pass a build constraints file (pip 25.3+)
|
|
61
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
62
|
+
pip install --build-constraint build-constraints.txt -r requirements.txt
|
|
63
|
+
fix (pip): pip older than 25.3: use PIP_CONSTRAINT (ignored for builds since pip 26.2)
|
|
64
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
65
|
+
PIP_CONSTRAINT=build-constraints.txt pip install -r requirements.txt
|
|
66
|
+
|
|
67
|
+
Builds from source with no known problem: deepspeed 0.20.2 (compiles native code), langid 1.1.6, textgrid 1.6.1
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## What it checks
|
|
71
|
+
|
|
72
|
+
canibuild only looks at packages that will be built from source: those with no wheel
|
|
73
|
+
matching the target interpreter and platform. For each of them it downloads the sdist
|
|
74
|
+
(cached), reads `pyproject.toml`, `setup.py`, `setup.cfg` and the local modules `setup.py`
|
|
75
|
+
imports, and parses them with `ast`. It never runs code from a package.
|
|
76
|
+
|
|
77
|
+
| Rule | Fails when |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `pkg-resources` | `setup.py` (or a local module it imports) imports `pkg_resources` and the build would get setuptools 82 or newer |
|
|
80
|
+
| `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 |
|
|
81
|
+
| `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 |
|
|
82
|
+
| `numpy-distutils` | `setup.py` imports `numpy.distutils`, which doesn't exist on Python 3.12+ or with NumPy 2 |
|
|
83
|
+
| `distutils` | `setup.py` imports `distutils` on Python 3.12+ and setuptools isn't in the build |
|
|
84
|
+
| `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 |
|
|
85
|
+
| `no-installable-file` | there is no wheel for the target and no sdist |
|
|
86
|
+
|
|
87
|
+
An import inside a `try: ... except ImportError` is ignored. An import inside a function
|
|
88
|
+
is reported as a warning, since it fails only if that code runs during the build.
|
|
89
|
+
Packages that build from source with no known problem are listed as such, with a note
|
|
90
|
+
when they compile native code.
|
|
91
|
+
|
|
92
|
+
The setuptools version a build would get is worked out from the sdist's own
|
|
93
|
+
`build-system.requires` (or pip's and uv's default of `setuptools>=40.8.0` when it has
|
|
94
|
+
none) and the setuptools releases on PyPI, so a package that already caps
|
|
95
|
+
`setuptools<82` isn't flagged.
|
|
96
|
+
|
|
97
|
+
## Fixes
|
|
98
|
+
|
|
99
|
+
Every finding comes with fixes for the tool that matches your lockfile (`uv.lock` gets
|
|
100
|
+
uv, `pylock.toml` and requirements files get pip and `uv pip`). Pass `--tool` to choose
|
|
101
|
+
(`uv`, `uv-pip`, `pip`, `poetry` or `all`).
|
|
102
|
+
|
|
103
|
+
| Tool | Fix for a build that needs `setuptools<82` |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| uv | `[tool.uv.extra-build-dependencies]` `pkg = ["setuptools<82"]`, or `[tool.uv] build-constraint-dependencies = ["setuptools<82"]` |
|
|
106
|
+
| uv pip | `uv pip install -b build-constraints.txt ...` |
|
|
107
|
+
| pip 25.3+ | `pip install --build-constraint build-constraints.txt ...` (or `PIP_BUILD_CONSTRAINT`) |
|
|
108
|
+
| pip older than 25.3 | `PIP_CONSTRAINT=build-constraints.txt pip install ...` (pip 26.2 stopped applying this to builds) |
|
|
109
|
+
| Poetry 2.3+ | `[tool.poetry.build-constraints]` `pkg = { setuptools = "<82" }`, then `poetry lock` |
|
|
110
|
+
|
|
111
|
+
Each of these was checked against `flatdict==4.0.1` with uv 0.13, pip 26.3 and 25.1, and
|
|
112
|
+
Poetry 2.5: the install fails without the fix and succeeds with it. When a newer release
|
|
113
|
+
of the package has a wheel for your target, or an sdist without the problem, canibuild
|
|
114
|
+
suggests upgrading to the oldest such release first.
|
|
115
|
+
|
|
116
|
+
Note that uv's own hint for this error suggests adding `pkg_resources` to
|
|
117
|
+
`extra-build-dependencies`. That can't work: `pkg_resources` isn't a package on PyPI.
|
|
118
|
+
|
|
119
|
+
## Tested on real lockfiles
|
|
120
|
+
|
|
121
|
+
canibuild was run on 13 lockfiles from public repositories (5 `uv.lock`, 8 requirements
|
|
122
|
+
files). Then every sdist those lockfiles would build was actually built, in a fresh
|
|
123
|
+
environment with `uv pip install --no-deps`, to see which builds really fail.
|
|
124
|
+
|
|
125
|
+
- 26 packages would build from source (23 distinct package versions).
|
|
126
|
+
- 10 of them really fail: `flatdict` 4.0.1 (2 lockfiles), `openai-whisper` 20231117 (2)
|
|
127
|
+
and 20240930 (2), `salib` 1.3.12 and `mmcv` 2.2.0 import `pkg_resources`; `flash-attn`
|
|
128
|
+
2.8.3.post2 imports `torch` without declaring it; `faiss-cpu` 1.7.4 has no wheel for
|
|
129
|
+
Python 3.12 and no sdist.
|
|
130
|
+
- canibuild reported all 10 with the right cause, and none of the 16 that built fine.
|
|
131
|
+
- With the suggested `setuptools<82` build constraint, all five distinct `pkg_resources`
|
|
132
|
+
failures build. `jproperties` 2.1.2 built from source (its `setup_requires` pins
|
|
133
|
+
setuptools-scm 3.x) is caught by `build-tool-needs-pkg-resources`, fails for real, and
|
|
134
|
+
builds with the same constraint.
|
|
135
|
+
|
|
136
|
+
The lockfiles, their commits and the per-package results are in
|
|
137
|
+
[`docs/validation.md`](docs/validation.md).
|
|
138
|
+
|
|
139
|
+
## Usage
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
|
|
143
|
+
[--fail-on error|warning|never] [--tool TOOL] [--jobs N]
|
|
144
|
+
[--cache-dir DIR] [--no-cache] [-v]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- `LOCKFILE`: `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
|
|
148
|
+
Requirements files may include other files with `-r`. Unpinned requirements are checked
|
|
149
|
+
at the newest release that matches and supports the target Python.
|
|
150
|
+
- `--python`: the target Python, such as `3.12`. Defaults to the running interpreter, or
|
|
151
|
+
to the oldest version a `uv.lock` or `pylock.toml` allows when the running one is outside
|
|
152
|
+
its `requires-python`.
|
|
153
|
+
- `--platform`: `linux-x86_64`, `linux-aarch64`, `musllinux-x86_64`, `musllinux-aarch64`,
|
|
154
|
+
`macos-arm64`, `macos-x86_64`, `windows-amd64`, `windows-arm64`, `windows-x86`, or a raw
|
|
155
|
+
platform tag such as `manylinux_2_28_x86_64`. Defaults to the current machine.
|
|
156
|
+
- `--format json`: machine-readable output with every finding and fix.
|
|
157
|
+
- `--fail-on`: exit with 1 on errors (the default), on warnings too, or never.
|
|
158
|
+
Usage errors and unreadable lockfiles exit with 2.
|
|
159
|
+
|
|
160
|
+
Downloaded sdists are cached in the user cache directory (`~/.cache/canibuild` on Linux,
|
|
161
|
+
or `$CANIBUILD_CACHE_DIR`).
|
|
162
|
+
|
|
163
|
+
## Limits
|
|
164
|
+
|
|
165
|
+
- Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
|
|
166
|
+
other indexes (such as `torch==2.1.2+cu121`), are listed as not checked.
|
|
167
|
+
- The checks are static. A `setup.py` that fails for a reason not in the table above, or
|
|
168
|
+
that needs a compiler or system library you don't have, isn't caught.
|
|
169
|
+
- Requirements files are not resolved: only the packages they list are checked, not their
|
|
170
|
+
dependencies. Use a lockfile (`uv.lock`, `pylock.toml`, or `pip-compile` output) for the
|
|
171
|
+
full tree.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Validation on real lockfiles
|
|
2
|
+
|
|
3
|
+
Run on 2026-12-05 with canibuild 0.1.0. For each lockfile, canibuild was run with
|
|
4
|
+
`--platform linux-x86_64` and the Python shown. Separately, every package the lockfile
|
|
5
|
+
would build from source was installed on its own with
|
|
6
|
+
`uv pip install --no-deps --no-cache` (uv 0.13.10, which builds in an isolated
|
|
7
|
+
environment with the newest setuptools, 84.2.1) to record whether the build really fails.
|
|
8
|
+
|
|
9
|
+
## Lockfiles
|
|
10
|
+
|
|
11
|
+
| Lockfile | Repository and commit | Python |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `uv.lock` | [geosp/mcp-bible](https://github.com/geosp/mcp-bible) `904dc66` (before its flatdict fix) | 3.12 |
|
|
14
|
+
| `uv.lock` | [vndee/local-talking-llm](https://github.com/vndee/local-talking-llm) `0f538c0` | 3.12 |
|
|
15
|
+
| `uv.lock` | [kyutai-labs/moshi-finetune](https://github.com/kyutai-labs/moshi-finetune) `2acc879` | 3.12 |
|
|
16
|
+
| `uv.lock` | [podly-pure-podcasts/podly_pure_podcasts](https://github.com/podly-pure-podcasts/podly_pure_podcasts) `718514a` | 3.11 |
|
|
17
|
+
| `uv.lock` | [okta/okta-mcp-server](https://github.com/okta/okta-mcp-server) `5acdcde` | 3.13 |
|
|
18
|
+
| `requirements.txt` | [wenet-e2e/wenet](https://github.com/wenet-e2e/wenet) `be6ad97` | 3.12 |
|
|
19
|
+
| `requirements.txt` | [shashikg/WhisperS2T](https://github.com/shashikg/WhisperS2T) `078cdb6` | 3.12 |
|
|
20
|
+
| `RAG/src/chain_server/requirements.txt` | [NVIDIA/GenerativeAIExamples](https://github.com/NVIDIA/GenerativeAIExamples) `203b0de` | 3.12 |
|
|
21
|
+
| `hail/python/pinned-requirements.txt` | [hail-is/hail](https://github.com/hail-is/hail) `64e1993` | 3.12 |
|
|
22
|
+
| `requirements.txt` | [broadinstitute/gnomad-browser](https://github.com/broadinstitute/gnomad-browser) `8990f19` | 3.12 |
|
|
23
|
+
| `requirements.txt` | [ajwdewit/pcse_notebooks](https://github.com/ajwdewit/pcse_notebooks) `da1a1bd` (before its salib fix) | 3.12 |
|
|
24
|
+
| `requirements.txt` | [Ma-Zhuang/OmniNWM](https://github.com/Ma-Zhuang/OmniNWM) `8e2333e` | 3.11 |
|
|
25
|
+
| `requirements.txt` | [jhj0517/Whisper-WebUI](https://github.com/jhj0517/Whisper-WebUI) `c3bb3b1` (before its pkg_resources fix) | 3.12 |
|
|
26
|
+
|
|
27
|
+
## Results
|
|
28
|
+
|
|
29
|
+
Every package any of these lockfiles would build from source:
|
|
30
|
+
|
|
31
|
+
| Lockfile | Package | Real build | canibuild |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| mcp-bible | flatdict 4.0.1 | fails: `No module named 'pkg_resources'` | error `pkg-resources` |
|
|
34
|
+
| local-talking-llm | openai-whisper 20240930 | fails: `pkg_resources` | error `pkg-resources` |
|
|
35
|
+
| local-talking-llm | antlr4-python3-runtime 4.9.3 | builds | builds from source |
|
|
36
|
+
| local-talking-llm | s3tokenizer 0.1.7 | builds | builds from source |
|
|
37
|
+
| moshi-finetune | openai-whisper 20240930 | fails: `pkg_resources` | error `pkg-resources` |
|
|
38
|
+
| moshi-finetune | fire 0.7.0 | builds | builds from source |
|
|
39
|
+
| podly | cd 1.1.0 | builds | builds from source |
|
|
40
|
+
| podly | flask-apscheduler 1.13.1 | builds | builds from source |
|
|
41
|
+
| podly | openai-whisper 20250625 | builds | builds from source |
|
|
42
|
+
| podly | pyrss2gen 1.1 | builds | builds from source |
|
|
43
|
+
| podly | sgmllib3k 1.0.0 | builds | builds from source |
|
|
44
|
+
| wenet | openai-whisper 20231117 | fails: `pkg_resources` | error `pkg-resources` |
|
|
45
|
+
| wenet | deepspeed 0.20.2 | builds | builds from source (native code) |
|
|
46
|
+
| wenet | langid 1.1.6 | builds | builds from source |
|
|
47
|
+
| wenet | textgrid 1.6.1 | builds | builds from source |
|
|
48
|
+
| WhisperS2T | openai-whisper 20231117 | fails: `pkg_resources` | error `pkg-resources` |
|
|
49
|
+
| NVIDIA chain_server | flatdict 4.0.1 | fails: `pkg_resources` | error `pkg-resources` |
|
|
50
|
+
| NVIDIA chain_server | faiss-cpu 1.7.4 | no wheel for cp312 and no sdist | error `no-installable-file` |
|
|
51
|
+
| hail | pyspark 4.1.2 | builds | builds from source |
|
|
52
|
+
| gnomad-browser | pyspark 3.3.4 | builds | builds from source |
|
|
53
|
+
| pcse_notebooks | salib 1.3.12 | fails: `pkg_resources` | error `pkg-resources` |
|
|
54
|
+
| pcse_notebooks | traitlets-pcse 5.0.0.dev | builds | builds from source |
|
|
55
|
+
| OmniNWM | mmcv 2.2.0 | fails: `pkg_resources` | error `pkg-resources` |
|
|
56
|
+
| OmniNWM | flash-attn 2.8.3.post2 (unpinned) | fails: `No module named 'torch'` | error `missing-build-requires` (torch) |
|
|
57
|
+
| OmniNWM | colossalai 0.5.0 (unpinned) | builds | builds from source (native code) |
|
|
58
|
+
| OmniNWM | pandarallel 1.6.5 (unpinned) | builds | builds from source |
|
|
59
|
+
|
|
60
|
+
okta-mcp-server builds nothing from source. Whisper-WebUI's failing dependency is a git
|
|
61
|
+
URL, which canibuild doesn't check (it lists it as not checked). WhisperS2T also pins
|
|
62
|
+
`torch==2.1.2+cu121` from the PyTorch index, which is listed as not checked.
|
|
63
|
+
|
|
64
|
+
Totals: 26 source builds, 10 real failures, 10 reported with the right cause, 0 false
|
|
65
|
+
reports among the 16 clean builds.
|
|
66
|
+
|
|
67
|
+
## The fixes
|
|
68
|
+
|
|
69
|
+
Each distinct `pkg_resources` failure was built again with a build constraints file
|
|
70
|
+
containing `setuptools<82` (`uv pip install --no-deps -b build-constraints.txt`):
|
|
71
|
+
flatdict 4.0.1, openai-whisper 20231117 and 20240930, salib 1.3.12 and mmcv 2.2.0 all
|
|
72
|
+
build. jproperties 2.1.2 built from source (`--no-binary jproperties`) fails because its
|
|
73
|
+
`setup_requires` pins setuptools-scm 3.x, which imports `pkg_resources`; canibuild
|
|
74
|
+
reports `build-tool-needs-pkg-resources`, and the same constraint fixes the build.
|
|
75
|
+
|
|
76
|
+
The upgrade suggestions were checked too: `uv lock --upgrade-package 'flatdict>=4.1.0'`
|
|
77
|
+
on mcp-bible moves flatdict to 4.1.0, which has a wheel, and openai-whisper 20250625
|
|
78
|
+
(suggested for 20231117) builds.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "canibuild"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Check a lockfile for dependencies that will fail to build from source, before you install."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "driftwright" }]
|
|
13
|
+
keywords = ["packaging", "lockfile", "sdist", "setuptools", "pkg_resources", "uv", "pip", "poetry"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Software Development :: Build Tools",
|
|
25
|
+
"Topic :: System :: Software Distribution",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"packaging>=24",
|
|
30
|
+
"tomli>=2; python_version < \"3.11\"",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = ["pytest>=8", "ruff==0.17.6", "mypy>=1.10"]
|
|
35
|
+
|
|
36
|
+
[project.scripts]
|
|
37
|
+
canibuild = "canibuild.cli:main"
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/driftwright/canibuild"
|
|
41
|
+
Issues = "https://github.com/driftwright/canibuild/issues"
|
|
42
|
+
Changelog = "https://github.com/driftwright/canibuild/blob/main/CHANGELOG.md"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.version]
|
|
45
|
+
path = "src/canibuild/__init__.py"
|
|
46
|
+
|
|
47
|
+
[tool.ruff]
|
|
48
|
+
line-length = 100
|
|
49
|
+
src = ["src", "tests"]
|
|
50
|
+
|
|
51
|
+
[tool.ruff.lint]
|
|
52
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
53
|
+
|
|
54
|
+
[tool.mypy]
|
|
55
|
+
files = ["src/canibuild"]
|
|
56
|
+
python_version = "3.10"
|
|
57
|
+
check_untyped_defs = true
|
|
58
|
+
warn_unused_ignores = true
|
|
59
|
+
strict_equality = true
|
|
60
|
+
|
|
61
|
+
[tool.pytest.ini_options]
|
|
62
|
+
testpaths = ["tests"]
|
|
63
|
+
addopts = "-q"
|