canibuild 0.1.0__tar.gz → 0.2.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.2.0/.github/workflows/integrations.yml +70 -0
- canibuild-0.2.0/.pre-commit-hooks.yaml +8 -0
- canibuild-0.2.0/CHANGELOG.md +29 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/PKG-INFO +94 -8
- {canibuild-0.1.0 → canibuild-0.2.0}/README.md +93 -7
- canibuild-0.2.0/action/run.sh +49 -0
- canibuild-0.2.0/action.yml +60 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/docs/validation.md +18 -0
- canibuild-0.2.0/examples/broken/requirements.txt +2 -0
- canibuild-0.2.0/examples/clean/pyproject.toml +8 -0
- canibuild-0.2.0/examples/clean/uv.lock +217 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/__init__.py +1 -1
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/cli.py +57 -30
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/model.py +16 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/report.py +29 -2
- canibuild-0.2.0/src/canibuild/verify.py +276 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_cli.py +99 -1
- canibuild-0.2.0/tests/test_report.py +105 -0
- canibuild-0.2.0/tests/test_verify.py +258 -0
- canibuild-0.1.0/CHANGELOG.md +0 -16
- canibuild-0.1.0/tests/test_report.py +0 -45
- {canibuild-0.1.0 → canibuild-0.2.0}/.github/workflows/tests.yml +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/.gitignore +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/LICENSE +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/pyproject.toml +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/__main__.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/check.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/fixes.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/lockfiles.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/py.typed +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/pypi.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/rules.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/sdist.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/src/canibuild/target.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/conftest.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/fixtures/base.txt +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/fixtures/pylock.toml +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/fixtures/requirements.txt +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/fixtures/uv.lock +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_check.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_fixes.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_lockfiles.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_pypi.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_rules.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_sdist.py +0 -0
- {canibuild-0.1.0 → canibuild-0.2.0}/tests/test_target.py +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: integrations
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
action:
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Clean lockfile passes
|
|
22
|
+
uses: ./
|
|
23
|
+
with:
|
|
24
|
+
lockfiles: examples/clean/uv.lock
|
|
25
|
+
|
|
26
|
+
- name: Broken lockfile fails
|
|
27
|
+
id: broken
|
|
28
|
+
continue-on-error: true
|
|
29
|
+
uses: ./
|
|
30
|
+
with:
|
|
31
|
+
lockfiles: examples/broken/requirements.txt
|
|
32
|
+
python: "3.12"
|
|
33
|
+
tool: uv-pip pip
|
|
34
|
+
verify: "true"
|
|
35
|
+
|
|
36
|
+
- name: Check the broken run failed, and a real build confirmed it
|
|
37
|
+
shell: bash
|
|
38
|
+
env:
|
|
39
|
+
OUTCOME: ${{ steps.broken.outcome }}
|
|
40
|
+
REPORT: ${{ steps.broken.outputs.report }}
|
|
41
|
+
run: |
|
|
42
|
+
test "$OUTCOME" = failure
|
|
43
|
+
python3 - "$REPORT" <<'PY'
|
|
44
|
+
import json, sys
|
|
45
|
+
reports = json.load(open(sys.argv[1]))
|
|
46
|
+
[flatdict] = [f for r in reports for f in r["findings"] if f["package"] == "flatdict"]
|
|
47
|
+
assert flatdict["rule"] == "pkg-resources", flatdict
|
|
48
|
+
assert flatdict["verification"]["status"] == "confirmed", flatdict
|
|
49
|
+
assert flatdict["verification"]["fix_builds"] is True, flatdict
|
|
50
|
+
PY
|
|
51
|
+
|
|
52
|
+
- name: Lockfiles found automatically
|
|
53
|
+
uses: ./
|
|
54
|
+
with:
|
|
55
|
+
working-directory: examples/clean
|
|
56
|
+
|
|
57
|
+
pre-commit:
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v4
|
|
61
|
+
- uses: astral-sh/setup-uv@v10.4.2
|
|
62
|
+
with:
|
|
63
|
+
enable-cache: false
|
|
64
|
+
- name: Hook passes on the clean lockfile
|
|
65
|
+
run: uvx pre-commit try-repo . canibuild --files examples/clean/uv.lock examples/clean/pyproject.toml
|
|
66
|
+
- name: Hook fails on the broken lockfile
|
|
67
|
+
run: |
|
|
68
|
+
if uvx pre-commit try-repo . canibuild --files examples/broken/requirements.txt; then
|
|
69
|
+
echo "expected the hook to fail"; exit 1
|
|
70
|
+
fi
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
- id: canibuild
|
|
2
|
+
name: canibuild
|
|
3
|
+
description: Check lockfiles for dependencies that will fail to build from source
|
|
4
|
+
entry: canibuild
|
|
5
|
+
language: python
|
|
6
|
+
files: (^|/)(uv\.lock|pylock(\.[^/]+)?\.toml|requirements[^/]*\.txt)$
|
|
7
|
+
pass_filenames: true
|
|
8
|
+
require_serial: true
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (2026-12-05)
|
|
4
|
+
|
|
5
|
+
- `--verify` builds each flagged sdist in a throwaway uv environment and reports, per
|
|
6
|
+
finding, whether the failure is confirmed, fails differently, is refuted, or timed out,
|
|
7
|
+
and whether the suggested build constraint makes it build. Refuted findings no longer
|
|
8
|
+
fail the run. `--verify-timeout` limits each build (default 900 seconds).
|
|
9
|
+
- Several lockfiles can be checked in one run; the run fails if any of them does.
|
|
10
|
+
- `--json-report PATH` writes the JSON report while printing text.
|
|
11
|
+
- A composite GitHub Action (`uses: driftwright/canibuild@v0.2.0`) that writes the report
|
|
12
|
+
to the job summary, and a pre-commit hook (`id: canibuild`).
|
|
13
|
+
- Example lockfiles in `examples/`, used by the integration tests.
|
|
14
|
+
- The summary line uses the singular for counts of one.
|
|
15
|
+
|
|
16
|
+
## 0.1.0 (2026-12-05)
|
|
17
|
+
|
|
18
|
+
First release.
|
|
19
|
+
|
|
20
|
+
- Reads `uv.lock`, `pylock.toml` and requirements files (with `-r` includes), keeping
|
|
21
|
+
only the packages the target Python and platform need.
|
|
22
|
+
- Finds the packages with no wheel for the target, inspects their sdists without running
|
|
23
|
+
them, and reports builds that will fail: `pkg_resources` with setuptools 82+, old
|
|
24
|
+
setuptools-scm and pbr pins, removed setuptools APIs, `numpy.distutils`, `distutils` on
|
|
25
|
+
Python 3.12+, undeclared build imports such as `torch`, and releases with nothing to
|
|
26
|
+
install.
|
|
27
|
+
- Gives fixes for uv, uv pip, pip and Poetry, and suggests the oldest newer release that
|
|
28
|
+
installs cleanly.
|
|
29
|
+
- Text and JSON output; exits with 1 when something will fail.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: canibuild
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Check a lockfile for dependencies that will fail to build from source, before you install.
|
|
5
5
|
Project-URL: Homepage, https://github.com/driftwright/canibuild
|
|
6
6
|
Project-URL: Issues, https://github.com/driftwright/canibuild/issues
|
|
@@ -56,7 +56,7 @@ at `904dc66`), whose `uv sync` broke on `flatdict` 4.0.1:
|
|
|
56
56
|
```console
|
|
57
57
|
$ canibuild check uv.lock --python 3.12 --platform linux-x86_64
|
|
58
58
|
canibuild: uv.lock for CPython 3.12 on linux-x86_64
|
|
59
|
-
81 packages checked, 1
|
|
59
|
+
81 packages checked, 1 builds from source, 1 will fail, 0 may fail
|
|
60
60
|
|
|
61
61
|
SEVERITY PACKAGE VERSION RULE PROBLEM
|
|
62
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
|
|
@@ -148,6 +148,49 @@ suggests upgrading to the oldest such release first.
|
|
|
148
148
|
Note that uv's own hint for this error suggests adding `pkg_resources` to
|
|
149
149
|
`extra-build-dependencies`. That can't work: `pkg_resources` isn't a package on PyPI.
|
|
150
150
|
|
|
151
|
+
## Confirming a prediction with a real build
|
|
152
|
+
|
|
153
|
+
The checks above are static. `--verify` goes one step further: for every package with an
|
|
154
|
+
error or warning, it builds that sdist in a throwaway environment with uv
|
|
155
|
+
(`uv pip install --no-deps --no-binary PKG`, from PyPI only, isolated from your uv config),
|
|
156
|
+
and records whether the build really fails the way canibuild said. When the finding has a
|
|
157
|
+
build constraint such as `setuptools<82`, it builds once more with that constraint to show
|
|
158
|
+
whether the fix works.
|
|
159
|
+
|
|
160
|
+
```console
|
|
161
|
+
$ canibuild examples/broken/requirements.txt --python 3.12 --verify --tool uv-pip
|
|
162
|
+
canibuild: building flatdict 4.0.1 to verify...
|
|
163
|
+
canibuild: examples/broken/requirements.txt for CPython 3.12 on linux-x86_64
|
|
164
|
+
2 packages checked, 1 builds from source, 1 will fail, 0 may fail, 1 confirmed by a real build
|
|
165
|
+
|
|
166
|
+
SEVERITY PACKAGE VERSION RULE PROBLEM
|
|
167
|
+
ERROR flatdict 4.0.1 pkg-resources setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
168
|
+
|
|
169
|
+
flatdict 4.0.1: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
170
|
+
at setup.py:1: import pkg_resources
|
|
171
|
+
verified: confirmed (ModuleNotFoundError: No module named 'pkg_resources')
|
|
172
|
+
with setuptools<82 in the build: builds
|
|
173
|
+
fix (any): Upgrade flatdict to 4.1.0, the first newer release with a wheel for this target
|
|
174
|
+
flatdict>=4.1.0 # in requirements
|
|
175
|
+
fix (uv pip): Pass a build constraints file
|
|
176
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
177
|
+
uv pip install -b build-constraints.txt -r requirements.txt
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Each finding gets one of these results:
|
|
181
|
+
|
|
182
|
+
| Result | Meaning |
|
|
183
|
+
| --- | --- |
|
|
184
|
+
| `confirmed` | The build failed with the error the finding predicts. |
|
|
185
|
+
| `fails-differently` | The build failed, but not with that error. The last error line is shown. |
|
|
186
|
+
| `refuted` | The build succeeded. The finding no longer counts toward `--fail-on`. |
|
|
187
|
+
| `timeout` | No result within `--verify-timeout` seconds (default 900). |
|
|
188
|
+
| `skipped` | uv isn't installed, the target platform isn't this machine, or uv couldn't create an environment for the target Python. |
|
|
189
|
+
|
|
190
|
+
Builds run one at a time, so `--verify` takes as long as the flagged builds do; large
|
|
191
|
+
native packages can take minutes. uv may download the target Python if it isn't installed.
|
|
192
|
+
Missing-file and not-checked findings are not built.
|
|
193
|
+
|
|
151
194
|
## Tested on real lockfiles
|
|
152
195
|
|
|
153
196
|
canibuild was run on 13 lockfiles from public repositories (5 `uv.lock`, 8 requirements
|
|
@@ -165,18 +208,23 @@ environment with `uv pip install --no-deps`, to see which builds really fail.
|
|
|
165
208
|
setuptools-scm 3.x) is caught by `build-tool-needs-pkg-resources`, fails for real, and
|
|
166
209
|
builds with the same constraint.
|
|
167
210
|
|
|
211
|
+
Running the same lockfiles with `--verify` confirmed all 9 build failures it could build
|
|
212
|
+
(`faiss-cpu` has nothing to build), and the `setuptools<82` constraint made all 8
|
|
213
|
+
`pkg_resources` cases build.
|
|
214
|
+
|
|
168
215
|
The lockfiles, their commits and the per-package results are in
|
|
169
216
|
[`docs/validation.md`](docs/validation.md).
|
|
170
217
|
|
|
171
218
|
## Usage
|
|
172
219
|
|
|
173
220
|
```
|
|
174
|
-
canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
|
|
175
|
-
|
|
176
|
-
|
|
221
|
+
canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
|
|
222
|
+
[--fail-on error|warning|never] [--tool TOOL] [--jobs N]
|
|
223
|
+
[--verify] [--verify-timeout SECONDS] [--json-report PATH]
|
|
224
|
+
[--cache-dir DIR] [--no-cache] [-v]
|
|
177
225
|
```
|
|
178
226
|
|
|
179
|
-
- `LOCKFILE`: `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
|
|
227
|
+
- `LOCKFILE`: one or more of `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
|
|
180
228
|
Requirements files may include other files with `-r`. Unpinned requirements are checked
|
|
181
229
|
at the newest release that matches and supports the target Python.
|
|
182
230
|
- `--python`: the target Python, such as `3.12`. Defaults to the running interpreter, or
|
|
@@ -185,13 +233,51 @@ canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
|
|
|
185
233
|
- `--platform`: `linux-x86_64`, `linux-aarch64`, `musllinux-x86_64`, `musllinux-aarch64`,
|
|
186
234
|
`macos-arm64`, `macos-x86_64`, `windows-amd64`, `windows-arm64`, `windows-x86`, or a raw
|
|
187
235
|
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
|
|
236
|
+
- `--format json`: machine-readable output with every finding and fix (a list when you
|
|
237
|
+
pass several lockfiles).
|
|
238
|
+
- `--json-report PATH`: also write the JSON report, always as a list, while printing text.
|
|
239
|
+
- `--verify`, `--verify-timeout`: build flagged sdists to confirm the findings (see above).
|
|
189
240
|
- `--fail-on`: exit with 1 on errors (the default), on warnings too, or never.
|
|
190
|
-
|
|
241
|
+
With several lockfiles, the run fails if any of them does. Usage errors and unreadable
|
|
242
|
+
lockfiles exit with 2.
|
|
191
243
|
|
|
192
244
|
Downloaded sdists are cached in the user cache directory (`~/.cache/canibuild` on Linux,
|
|
193
245
|
or `$CANIBUILD_CACHE_DIR`).
|
|
194
246
|
|
|
247
|
+
## GitHub Action
|
|
248
|
+
|
|
249
|
+
```yaml
|
|
250
|
+
- uses: actions/checkout@v4
|
|
251
|
+
- uses: driftwright/canibuild@v0.2.0
|
|
252
|
+
with:
|
|
253
|
+
lockfiles: uv.lock # default: every uv.lock, pylock*.toml, requirements*.txt
|
|
254
|
+
python: "3.12" # default: as for --python below
|
|
255
|
+
# platform: linux-x86_64 # default: the runner
|
|
256
|
+
# fail-on: error # error, warning or never
|
|
257
|
+
# tool: uv # tools to show fixes for
|
|
258
|
+
# verify: "true" # build flagged sdists to confirm the findings
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
The action installs uv, runs canibuild with the code of the tag you pinned (or the PyPI
|
|
262
|
+
release given in `version`), prints the report, adds it to the job summary, and fails the
|
|
263
|
+
step when something will fail to build. The JSON report's path is in the `report` output.
|
|
264
|
+
Check several targets with a matrix over `python` and `platform`; `verify` only builds
|
|
265
|
+
when `platform` is the runner's own.
|
|
266
|
+
|
|
267
|
+
## pre-commit
|
|
268
|
+
|
|
269
|
+
```yaml
|
|
270
|
+
repos:
|
|
271
|
+
- repo: https://github.com/driftwright/canibuild
|
|
272
|
+
rev: v0.2.0
|
|
273
|
+
hooks:
|
|
274
|
+
- id: canibuild
|
|
275
|
+
# args: [--python, "3.12"]
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
The hook runs when `uv.lock`, a `pylock*.toml` or a `requirements*.txt` changes, and needs
|
|
279
|
+
network access to PyPI.
|
|
280
|
+
|
|
195
281
|
## Limits
|
|
196
282
|
|
|
197
283
|
- Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
|
|
@@ -24,7 +24,7 @@ at `904dc66`), whose `uv sync` broke on `flatdict` 4.0.1:
|
|
|
24
24
|
```console
|
|
25
25
|
$ canibuild check uv.lock --python 3.12 --platform linux-x86_64
|
|
26
26
|
canibuild: uv.lock for CPython 3.12 on linux-x86_64
|
|
27
|
-
81 packages checked, 1
|
|
27
|
+
81 packages checked, 1 builds from source, 1 will fail, 0 may fail
|
|
28
28
|
|
|
29
29
|
SEVERITY PACKAGE VERSION RULE PROBLEM
|
|
30
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
|
|
@@ -116,6 +116,49 @@ suggests upgrading to the oldest such release first.
|
|
|
116
116
|
Note that uv's own hint for this error suggests adding `pkg_resources` to
|
|
117
117
|
`extra-build-dependencies`. That can't work: `pkg_resources` isn't a package on PyPI.
|
|
118
118
|
|
|
119
|
+
## Confirming a prediction with a real build
|
|
120
|
+
|
|
121
|
+
The checks above are static. `--verify` goes one step further: for every package with an
|
|
122
|
+
error or warning, it builds that sdist in a throwaway environment with uv
|
|
123
|
+
(`uv pip install --no-deps --no-binary PKG`, from PyPI only, isolated from your uv config),
|
|
124
|
+
and records whether the build really fails the way canibuild said. When the finding has a
|
|
125
|
+
build constraint such as `setuptools<82`, it builds once more with that constraint to show
|
|
126
|
+
whether the fix works.
|
|
127
|
+
|
|
128
|
+
```console
|
|
129
|
+
$ canibuild examples/broken/requirements.txt --python 3.12 --verify --tool uv-pip
|
|
130
|
+
canibuild: building flatdict 4.0.1 to verify...
|
|
131
|
+
canibuild: examples/broken/requirements.txt for CPython 3.12 on linux-x86_64
|
|
132
|
+
2 packages checked, 1 builds from source, 1 will fail, 0 may fail, 1 confirmed by a real build
|
|
133
|
+
|
|
134
|
+
SEVERITY PACKAGE VERSION RULE PROBLEM
|
|
135
|
+
ERROR flatdict 4.0.1 pkg-resources setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
136
|
+
|
|
137
|
+
flatdict 4.0.1: setup.py imports pkg_resources, which setuptools 82 removed; a fresh build gets setuptools 84.2.1
|
|
138
|
+
at setup.py:1: import pkg_resources
|
|
139
|
+
verified: confirmed (ModuleNotFoundError: No module named 'pkg_resources')
|
|
140
|
+
with setuptools<82 in the build: builds
|
|
141
|
+
fix (any): Upgrade flatdict to 4.1.0, the first newer release with a wheel for this target
|
|
142
|
+
flatdict>=4.1.0 # in requirements
|
|
143
|
+
fix (uv pip): Pass a build constraints file
|
|
144
|
+
echo 'setuptools<82' > build-constraints.txt
|
|
145
|
+
uv pip install -b build-constraints.txt -r requirements.txt
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Each finding gets one of these results:
|
|
149
|
+
|
|
150
|
+
| Result | Meaning |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `confirmed` | The build failed with the error the finding predicts. |
|
|
153
|
+
| `fails-differently` | The build failed, but not with that error. The last error line is shown. |
|
|
154
|
+
| `refuted` | The build succeeded. The finding no longer counts toward `--fail-on`. |
|
|
155
|
+
| `timeout` | No result within `--verify-timeout` seconds (default 900). |
|
|
156
|
+
| `skipped` | uv isn't installed, the target platform isn't this machine, or uv couldn't create an environment for the target Python. |
|
|
157
|
+
|
|
158
|
+
Builds run one at a time, so `--verify` takes as long as the flagged builds do; large
|
|
159
|
+
native packages can take minutes. uv may download the target Python if it isn't installed.
|
|
160
|
+
Missing-file and not-checked findings are not built.
|
|
161
|
+
|
|
119
162
|
## Tested on real lockfiles
|
|
120
163
|
|
|
121
164
|
canibuild was run on 13 lockfiles from public repositories (5 `uv.lock`, 8 requirements
|
|
@@ -133,18 +176,23 @@ environment with `uv pip install --no-deps`, to see which builds really fail.
|
|
|
133
176
|
setuptools-scm 3.x) is caught by `build-tool-needs-pkg-resources`, fails for real, and
|
|
134
177
|
builds with the same constraint.
|
|
135
178
|
|
|
179
|
+
Running the same lockfiles with `--verify` confirmed all 9 build failures it could build
|
|
180
|
+
(`faiss-cpu` has nothing to build), and the `setuptools<82` constraint made all 8
|
|
181
|
+
`pkg_resources` cases build.
|
|
182
|
+
|
|
136
183
|
The lockfiles, their commits and the per-package results are in
|
|
137
184
|
[`docs/validation.md`](docs/validation.md).
|
|
138
185
|
|
|
139
186
|
## Usage
|
|
140
187
|
|
|
141
188
|
```
|
|
142
|
-
canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
|
|
143
|
-
|
|
144
|
-
|
|
189
|
+
canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
|
|
190
|
+
[--fail-on error|warning|never] [--tool TOOL] [--jobs N]
|
|
191
|
+
[--verify] [--verify-timeout SECONDS] [--json-report PATH]
|
|
192
|
+
[--cache-dir DIR] [--no-cache] [-v]
|
|
145
193
|
```
|
|
146
194
|
|
|
147
|
-
- `LOCKFILE`: `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
|
|
195
|
+
- `LOCKFILE`: one or more of `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
|
|
148
196
|
Requirements files may include other files with `-r`. Unpinned requirements are checked
|
|
149
197
|
at the newest release that matches and supports the target Python.
|
|
150
198
|
- `--python`: the target Python, such as `3.12`. Defaults to the running interpreter, or
|
|
@@ -153,13 +201,51 @@ canibuild [check] LOCKFILE [--python X.Y] [--platform P] [--format text|json]
|
|
|
153
201
|
- `--platform`: `linux-x86_64`, `linux-aarch64`, `musllinux-x86_64`, `musllinux-aarch64`,
|
|
154
202
|
`macos-arm64`, `macos-x86_64`, `windows-amd64`, `windows-arm64`, `windows-x86`, or a raw
|
|
155
203
|
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
|
|
204
|
+
- `--format json`: machine-readable output with every finding and fix (a list when you
|
|
205
|
+
pass several lockfiles).
|
|
206
|
+
- `--json-report PATH`: also write the JSON report, always as a list, while printing text.
|
|
207
|
+
- `--verify`, `--verify-timeout`: build flagged sdists to confirm the findings (see above).
|
|
157
208
|
- `--fail-on`: exit with 1 on errors (the default), on warnings too, or never.
|
|
158
|
-
|
|
209
|
+
With several lockfiles, the run fails if any of them does. Usage errors and unreadable
|
|
210
|
+
lockfiles exit with 2.
|
|
159
211
|
|
|
160
212
|
Downloaded sdists are cached in the user cache directory (`~/.cache/canibuild` on Linux,
|
|
161
213
|
or `$CANIBUILD_CACHE_DIR`).
|
|
162
214
|
|
|
215
|
+
## GitHub Action
|
|
216
|
+
|
|
217
|
+
```yaml
|
|
218
|
+
- uses: actions/checkout@v4
|
|
219
|
+
- uses: driftwright/canibuild@v0.2.0
|
|
220
|
+
with:
|
|
221
|
+
lockfiles: uv.lock # default: every uv.lock, pylock*.toml, requirements*.txt
|
|
222
|
+
python: "3.12" # default: as for --python below
|
|
223
|
+
# platform: linux-x86_64 # default: the runner
|
|
224
|
+
# fail-on: error # error, warning or never
|
|
225
|
+
# tool: uv # tools to show fixes for
|
|
226
|
+
# verify: "true" # build flagged sdists to confirm the findings
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The action installs uv, runs canibuild with the code of the tag you pinned (or the PyPI
|
|
230
|
+
release given in `version`), prints the report, adds it to the job summary, and fails the
|
|
231
|
+
step when something will fail to build. The JSON report's path is in the `report` output.
|
|
232
|
+
Check several targets with a matrix over `python` and `platform`; `verify` only builds
|
|
233
|
+
when `platform` is the runner's own.
|
|
234
|
+
|
|
235
|
+
## pre-commit
|
|
236
|
+
|
|
237
|
+
```yaml
|
|
238
|
+
repos:
|
|
239
|
+
- repo: https://github.com/driftwright/canibuild
|
|
240
|
+
rev: v0.2.0
|
|
241
|
+
hooks:
|
|
242
|
+
- id: canibuild
|
|
243
|
+
# args: [--python, "3.12"]
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
The hook runs when `uv.lock`, a `pylock*.toml` or a `requirements*.txt` changes, and needs
|
|
247
|
+
network access to PyPI.
|
|
248
|
+
|
|
163
249
|
## Limits
|
|
164
250
|
|
|
165
251
|
- Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Runs canibuild for the composite action. Inputs arrive as CANIBUILD_* variables.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
if [[ -n "$CANIBUILD_VERSION" ]]; then
|
|
6
|
+
source_spec="canibuild==$CANIBUILD_VERSION"
|
|
7
|
+
else
|
|
8
|
+
source_spec="$CANIBUILD_ACTION_PATH"
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
read -r -a lockfiles <<< "$(echo "$CANIBUILD_LOCKFILES" | tr '\n' ' ')"
|
|
12
|
+
if [[ ${#lockfiles[@]} -eq 0 ]]; then
|
|
13
|
+
shopt -s nullglob
|
|
14
|
+
lockfiles=(uv.lock pylock*.toml requirements*.txt)
|
|
15
|
+
shopt -u nullglob
|
|
16
|
+
existing=()
|
|
17
|
+
for f in "${lockfiles[@]}"; do [[ -f "$f" ]] && existing+=("$f"); done
|
|
18
|
+
lockfiles=("${existing[@]+"${existing[@]}"}")
|
|
19
|
+
fi
|
|
20
|
+
if [[ ${#lockfiles[@]} -eq 0 ]]; then
|
|
21
|
+
echo "::error::canibuild: no lockfile found; set the lockfiles input"
|
|
22
|
+
exit 2
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
args=(--fail-on "$CANIBUILD_FAIL_ON")
|
|
26
|
+
[[ -n "$CANIBUILD_PYTHON" ]] && args+=(--python "$CANIBUILD_PYTHON")
|
|
27
|
+
[[ -n "$CANIBUILD_PLATFORM" ]] && args+=(--platform "$CANIBUILD_PLATFORM")
|
|
28
|
+
for tool in $CANIBUILD_TOOL; do args+=(--tool "$tool"); done
|
|
29
|
+
[[ "$CANIBUILD_VERIFY" == "true" ]] && args+=(--verify)
|
|
30
|
+
|
|
31
|
+
report="${RUNNER_TEMP:-/tmp}/canibuild-report.json"
|
|
32
|
+
text="${RUNNER_TEMP:-/tmp}/canibuild-report.txt"
|
|
33
|
+
echo "report=$report" >> "${GITHUB_OUTPUT:-/dev/null}"
|
|
34
|
+
|
|
35
|
+
status=0
|
|
36
|
+
uvx --no-config --from "$source_spec" canibuild "${lockfiles[@]}" "${args[@]}" \
|
|
37
|
+
--json-report "$report" > "$text" || status=$?
|
|
38
|
+
cat "$text"
|
|
39
|
+
|
|
40
|
+
if [[ -n "${GITHUB_STEP_SUMMARY:-}" ]]; then
|
|
41
|
+
{
|
|
42
|
+
echo "### canibuild"
|
|
43
|
+
echo
|
|
44
|
+
echo '```'
|
|
45
|
+
cat "$text"
|
|
46
|
+
echo '```'
|
|
47
|
+
} >> "$GITHUB_STEP_SUMMARY"
|
|
48
|
+
fi
|
|
49
|
+
exit "$status"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: canibuild
|
|
2
|
+
description: Check lockfiles for dependencies that will fail to build from source
|
|
3
|
+
author: driftwright
|
|
4
|
+
branding:
|
|
5
|
+
icon: package
|
|
6
|
+
color: orange
|
|
7
|
+
|
|
8
|
+
inputs:
|
|
9
|
+
lockfiles:
|
|
10
|
+
description: >-
|
|
11
|
+
Lockfiles to check, separated by spaces or newlines. When empty, checks every uv.lock,
|
|
12
|
+
pylock*.toml and requirements*.txt in working-directory (not recursive).
|
|
13
|
+
default: ""
|
|
14
|
+
working-directory:
|
|
15
|
+
description: Directory the lockfile paths are relative to.
|
|
16
|
+
default: "."
|
|
17
|
+
python:
|
|
18
|
+
description: Target Python version (X.Y). Defaults to the oldest version the lockfile allows.
|
|
19
|
+
default: ""
|
|
20
|
+
platform:
|
|
21
|
+
description: Target platform, e.g. linux-x86_64, macos-arm64, windows-amd64. Defaults to the runner.
|
|
22
|
+
default: ""
|
|
23
|
+
fail-on:
|
|
24
|
+
description: "Fail the step on: error, warning or never."
|
|
25
|
+
default: error
|
|
26
|
+
tool:
|
|
27
|
+
description: "Tools to write fixes for, separated by spaces: uv, uv-pip, pip, poetry or all."
|
|
28
|
+
default: ""
|
|
29
|
+
verify:
|
|
30
|
+
description: Build each flagged sdist in a throwaway environment to confirm the prediction.
|
|
31
|
+
default: "false"
|
|
32
|
+
version:
|
|
33
|
+
description: >-
|
|
34
|
+
canibuild version to run, e.g. 0.2.0. Empty runs the code of the action ref you pinned.
|
|
35
|
+
default: ""
|
|
36
|
+
|
|
37
|
+
outputs:
|
|
38
|
+
report:
|
|
39
|
+
description: Path of the JSON report (one object per lockfile, in an array).
|
|
40
|
+
value: ${{ steps.run.outputs.report }}
|
|
41
|
+
|
|
42
|
+
runs:
|
|
43
|
+
using: composite
|
|
44
|
+
steps:
|
|
45
|
+
- uses: astral-sh/setup-uv@v10.4.2
|
|
46
|
+
with:
|
|
47
|
+
enable-cache: false
|
|
48
|
+
- id: run
|
|
49
|
+
shell: bash
|
|
50
|
+
working-directory: ${{ inputs.working-directory }}
|
|
51
|
+
env:
|
|
52
|
+
CANIBUILD_LOCKFILES: ${{ inputs.lockfiles }}
|
|
53
|
+
CANIBUILD_PYTHON: ${{ inputs.python }}
|
|
54
|
+
CANIBUILD_PLATFORM: ${{ inputs.platform }}
|
|
55
|
+
CANIBUILD_FAIL_ON: ${{ inputs.fail-on }}
|
|
56
|
+
CANIBUILD_TOOL: ${{ inputs.tool }}
|
|
57
|
+
CANIBUILD_VERIFY: ${{ inputs.verify }}
|
|
58
|
+
CANIBUILD_VERSION: ${{ inputs.version }}
|
|
59
|
+
CANIBUILD_ACTION_PATH: ${{ github.action_path }}
|
|
60
|
+
run: "$CANIBUILD_ACTION_PATH/action/run.sh"
|
|
@@ -76,3 +76,21 @@ reports `build-tool-needs-pkg-resources`, and the same constraint fixes the buil
|
|
|
76
76
|
The upgrade suggestions were checked too: `uv lock --upgrade-package 'flatdict>=4.1.0'`
|
|
77
77
|
on mcp-bible moves flatdict to 4.1.0, which has a wheel, and openai-whisper 20250625
|
|
78
78
|
(suggested for 20231117) builds.
|
|
79
|
+
|
|
80
|
+
## With `--verify`
|
|
81
|
+
|
|
82
|
+
Run on 2026-12-05 with canibuild 0.2.0 and uv 0.13.10, same lockfiles and targets.
|
|
83
|
+
`--verify` built every package with an error or warning and confirmed each prediction:
|
|
84
|
+
|
|
85
|
+
| Lockfile | Package | `--verify` result | Build with `setuptools<82` |
|
|
86
|
+
| --- | --- | --- | --- |
|
|
87
|
+
| mcp-bible | flatdict 4.0.1 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
88
|
+
| local-talking-llm | openai-whisper 20240930 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
89
|
+
| moshi-finetune | openai-whisper 20240930 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
90
|
+
| nvidia-chain-server | flatdict 4.0.1 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
91
|
+
| nvidia-chain-server | faiss-cpu 1.7.4 | not built (no file to install) | |
|
|
92
|
+
| omninwm | flash_attn 2.8.3.post2 | confirmed: `No module named 'torch'` | |
|
|
93
|
+
| omninwm | mmcv 2.2.0 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
94
|
+
| pcse-notebooks | salib 1.3.12 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
95
|
+
| wenet | openai-whisper 20231117 | confirmed: `No module named 'pkg_resources'` | builds |
|
|
96
|
+
| whisper-s2t | openai-whisper 20231117 | confirmed: `No module named 'pkg_resources'` | builds |
|