canibuild 0.2.0__tar.gz → 0.4.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.
Files changed (55) hide show
  1. {canibuild-0.2.0 → canibuild-0.4.0}/.github/workflows/integrations.yml +48 -0
  2. canibuild-0.4.0/CHANGELOG.md +63 -0
  3. {canibuild-0.2.0 → canibuild-0.4.0}/PKG-INFO +92 -10
  4. {canibuild-0.2.0 → canibuild-0.4.0}/README.md +91 -9
  5. {canibuild-0.2.0 → canibuild-0.4.0}/action/run.sh +2 -0
  6. {canibuild-0.2.0 → canibuild-0.4.0}/action.yml +9 -1
  7. {canibuild-0.2.0 → canibuild-0.4.0}/docs/validation.md +55 -0
  8. canibuild-0.4.0/examples/git/requirements.txt +1 -0
  9. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/__init__.py +1 -1
  10. canibuild-0.4.0/src/canibuild/capi.py +471 -0
  11. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/check.py +331 -18
  12. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/cli.py +83 -3
  13. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/fixes.py +36 -0
  14. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/lockfiles.py +348 -5
  15. canibuild-0.4.0/src/canibuild/model.py +235 -0
  16. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/pypi.py +4 -0
  17. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/report.py +10 -2
  18. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/rules.py +45 -1
  19. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/sdist.py +119 -31
  20. canibuild-0.4.0/src/canibuild/sources.py +254 -0
  21. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/target.py +47 -7
  22. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/verify.py +103 -34
  23. canibuild-0.4.0/tests/fixtures/uv-direct-sources.pyproject.toml +12 -0
  24. canibuild-0.4.0/tests/fixtures/uv-direct-sources.uv.lock +54 -0
  25. canibuild-0.4.0/tests/test_capi.py +307 -0
  26. canibuild-0.4.0/tests/test_check.py +880 -0
  27. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_cli.py +67 -1
  28. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_fixes.py +59 -0
  29. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_lockfiles.py +195 -2
  30. canibuild-0.4.0/tests/test_model.py +84 -0
  31. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_report.py +60 -4
  32. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_rules.py +61 -0
  33. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_sdist.py +68 -1
  34. canibuild-0.4.0/tests/test_sources.py +96 -0
  35. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_target.py +34 -0
  36. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_verify.py +129 -1
  37. canibuild-0.2.0/CHANGELOG.md +0 -29
  38. canibuild-0.2.0/src/canibuild/model.py +0 -118
  39. canibuild-0.2.0/tests/test_check.py +0 -412
  40. {canibuild-0.2.0 → canibuild-0.4.0}/.github/workflows/tests.yml +0 -0
  41. {canibuild-0.2.0 → canibuild-0.4.0}/.gitignore +0 -0
  42. {canibuild-0.2.0 → canibuild-0.4.0}/.pre-commit-hooks.yaml +0 -0
  43. {canibuild-0.2.0 → canibuild-0.4.0}/LICENSE +0 -0
  44. {canibuild-0.2.0 → canibuild-0.4.0}/examples/broken/requirements.txt +0 -0
  45. {canibuild-0.2.0 → canibuild-0.4.0}/examples/clean/pyproject.toml +0 -0
  46. {canibuild-0.2.0 → canibuild-0.4.0}/examples/clean/uv.lock +0 -0
  47. {canibuild-0.2.0 → canibuild-0.4.0}/pyproject.toml +0 -0
  48. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/__main__.py +0 -0
  49. {canibuild-0.2.0 → canibuild-0.4.0}/src/canibuild/py.typed +0 -0
  50. {canibuild-0.2.0 → canibuild-0.4.0}/tests/conftest.py +0 -0
  51. {canibuild-0.2.0 → canibuild-0.4.0}/tests/fixtures/base.txt +0 -0
  52. {canibuild-0.2.0 → canibuild-0.4.0}/tests/fixtures/pylock.toml +0 -0
  53. {canibuild-0.2.0 → canibuild-0.4.0}/tests/fixtures/requirements.txt +0 -0
  54. {canibuild-0.2.0 → canibuild-0.4.0}/tests/fixtures/uv.lock +0 -0
  55. {canibuild-0.2.0 → canibuild-0.4.0}/tests/test_pypi.py +0 -0
@@ -49,6 +49,54 @@ jobs:
49
49
  assert flatdict["verification"]["fix_builds"] is True, flatdict
50
50
  PY
51
51
 
52
+ - name: no-build turns the missing wheel into a failure
53
+ id: nobuild
54
+ continue-on-error: true
55
+ uses: ./
56
+ with:
57
+ lockfiles: examples/broken/requirements.txt
58
+ python: "3.12"
59
+ no-build: ":all:"
60
+
61
+ - name: Check the no-build run reported the no-build rule
62
+ shell: bash
63
+ env:
64
+ OUTCOME: ${{ steps.nobuild.outcome }}
65
+ REPORT: ${{ steps.nobuild.outputs.report }}
66
+ run: |
67
+ test "$OUTCOME" = failure
68
+ python3 - "$REPORT" <<'PY'
69
+ import json, sys
70
+ reports = json.load(open(sys.argv[1]))
71
+ rules = {f["rule"] for r in reports for f in r["findings"]}
72
+ assert rules == {"no-build"}, rules
73
+ PY
74
+
75
+ - name: Git dependency is fetched, checked and built
76
+ id: git
77
+ continue-on-error: true
78
+ uses: ./
79
+ with:
80
+ lockfiles: examples/git/requirements.txt
81
+ python: "3.12"
82
+ verify: "true"
83
+
84
+ - name: Check the git dependency was confirmed by a real build
85
+ shell: bash
86
+ env:
87
+ OUTCOME: ${{ steps.git.outcome }}
88
+ REPORT: ${{ steps.git.outputs.report }}
89
+ run: |
90
+ test "$OUTCOME" = failure
91
+ python3 - "$REPORT" <<'PY'
92
+ import json, sys
93
+ [finding] = [f for r in json.load(open(sys.argv[1])) for f in r["findings"]]
94
+ assert finding["rule"] == "pkg-resources", finding
95
+ assert finding["source"].startswith("flatdict @ git+https://github.com/gmr/flatdict@"), finding
96
+ assert finding["verification"]["status"] == "confirmed", finding
97
+ assert finding["verification"]["fix_builds"] is True, finding
98
+ PY
99
+
52
100
  - name: Lockfiles found automatically
53
101
  uses: ./
54
102
  with:
@@ -0,0 +1,63 @@
1
+ # Changelog
2
+
3
+ ## 0.4.0 (2026-12-05)
4
+
5
+ - Free-threaded targets: `--python 3.14t` (or `cp314t`, or the running free-threaded
6
+ interpreter) matches `cp314t` wheels and no longer counts `abi3` wheels, which don't
7
+ install there; on 3.15t `abi3t` wheels (PEP 803) count. `--verify` builds with the
8
+ free-threaded interpreter.
9
+ - New `no-wheel-for-python` warning: the release has compiled wheels, but none for the
10
+ target (for example wheels up to `cp313` when checking 3.15 or 3.14t), so pip/uv will
11
+ build it from the sdist. When the build also has a real problem, the other wheels are
12
+ noted on that finding. Upgrades suggested for it must have a matching wheel.
13
+ - New `c-api-removed` rule for Python 3.15+: unguarded calls in C/C++ sources to the
14
+ functions What's New in Python 3.15 lists as removed (`PyWeakref_GetObject`,
15
+ `PyImport_ImportModuleNoBlock`, `Py_GetPrefix` and others).
16
+ - New `free-threading-limited-api` rule for 3.13t and 3.14t: builds that enable the
17
+ limited C API, which those interpreters reject.
18
+ - `--verify` recognises the compiler and setuptools errors for both new rules.
19
+
20
+ ## 0.3.0 (2026-12-05)
21
+
22
+ - Git, path and URL dependencies are now checked instead of listed as not checked.
23
+ Git sources are fetched at the locked commit (shallow, hooks disabled, no submodules)
24
+ and cached by commit; local directories and archives are read in place; URL sdists are
25
+ downloaded and wheel URLs are matched against the target. Package code is never run.
26
+ Findings say where the code came from, and `--verify` builds them from the same
27
+ reference.
28
+ - no-binary and no-build settings are honoured: from `[tool.uv]`, `[tool.uv.pip]`,
29
+ `uv.toml`, requirements-file `--no-binary` / `--only-binary` lines, and the new
30
+ `--no-binary` / `--no-build` options. A package that needs a build while builds are
31
+ forbidden is reported with the new `no-build` rule. The report shows the settings in
32
+ effect. The GitHub Action has matching `no-binary` and `no-build` inputs.
33
+ - `--verify` retries a confirmed missing build requirement with it added through uv's
34
+ `extra-build-dependencies`, and shows the next error when the build still fails.
35
+ - `--verify` explains why it skipped a foreign target platform.
36
+
37
+ ## 0.2.0 (2026-12-05)
38
+
39
+ - `--verify` builds each flagged sdist in a throwaway uv environment and reports, per
40
+ finding, whether the failure is confirmed, fails differently, is refuted, or timed out,
41
+ and whether the suggested build constraint makes it build. Refuted findings no longer
42
+ fail the run. `--verify-timeout` limits each build (default 900 seconds).
43
+ - Several lockfiles can be checked in one run; the run fails if any of them does.
44
+ - `--json-report PATH` writes the JSON report while printing text.
45
+ - A composite GitHub Action (`uses: driftwright/canibuild@v0.2.0`) that writes the report
46
+ to the job summary, and a pre-commit hook (`id: canibuild`).
47
+ - Example lockfiles in `examples/`, used by the integration tests.
48
+ - The summary line uses the singular for counts of one.
49
+
50
+ ## 0.1.0 (2026-12-05)
51
+
52
+ First release.
53
+
54
+ - Reads `uv.lock`, `pylock.toml` and requirements files (with `-r` includes), keeping
55
+ only the packages the target Python and platform need.
56
+ - Finds the packages with no wheel for the target, inspects their sdists without running
57
+ them, and reports builds that will fail: `pkg_resources` with setuptools 82+, old
58
+ setuptools-scm and pbr pins, removed setuptools APIs, `numpy.distutils`, `distutils` on
59
+ Python 3.12+, undeclared build imports such as `torch`, and releases with nothing to
60
+ install.
61
+ - Gives fixes for uv, uv pip, pip and Poetry, and suggests the oldest newer release that
62
+ installs cleanly.
63
+ - 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.2.0
3
+ Version: 0.4.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
@@ -115,11 +115,82 @@ imports, and parses them with `ast`. It never runs code from a package.
115
115
  | `distutils` | `setup.py` imports `distutils` on Python 3.12+ and setuptools isn't in the build |
116
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
117
  | `no-installable-file` | there is no wheel for the target and no sdist |
118
+ | `c-api-removed` | Python 3.15+: a C or C++ source calls a function that [Python 3.15 removed](https://docs.python.org/3.15/whatsnew/3.15.html#removed-c-apis), such as `PyWeakref_GetObject` or `Py_GetPrefix`, outside any version check |
119
+ | `free-threading-limited-api` | free-threaded 3.13t or 3.14t: the build enables the limited C API (`py_limited_api` in `setup.cfg` or `setup.py`, or `Py_LIMITED_API` defined in a source file or `define_macros`), which [these builds reject](https://github.com/python/cpython/issues/111506) |
118
120
 
119
121
  An import inside a `try: ... except ImportError` is ignored. An import inside a function
120
122
  is reported as a warning, since it fails only if that code runs during the build.
121
123
  Packages that build from source with no known problem are listed as such, with a note
122
- when they compile native code.
124
+ when they compile native code. When such a package has compiled wheels, just none for
125
+ the target (say, wheels up to `cp313` but not `cp315` or `cp314t`), it is reported as a
126
+ `no-wheel-for-python` warning, since the build is probably unexpected and needs a
127
+ compiler; the fix names the first newer release with a matching wheel.
128
+
129
+ ### New Python versions and free-threaded builds
130
+
131
+ Pass `--python 3.15` to check a new Python before its wheels are out, and
132
+ `--python 3.14t` (or `cp314t`) for the free-threaded build. Wheel matching follows the
133
+ interpreter: `abi3` wheels don't install on free-threaded 3.13t and 3.14t, and on 3.15t
134
+ only `abi3t` wheels ([PEP 803](https://peps.python.org/pep-0803/)) do.
135
+
136
+ Two checks read the C sources of packages that would be built:
137
+
138
+ - `c-api-removed` looks for calls to the functions listed under "Removed C APIs" in
139
+ What's New in Python 3.15. With GCC 14+ or Clang 16+ the build fails with an implicit
140
+ declaration error; older compilers build a module that fails on import. Calls are
141
+ skipped when they sit inside an `#if` on `PY_VERSION_HEX`, `PY_MINOR_VERSION`,
142
+ `Py_LIMITED_API`, `PYPY_VERSION` or a Cython switch (or a macro defined from one of
143
+ those), when the package defines the name itself (a compat header), and under
144
+ `tests/`, `docs/` and `examples/`. Comments and strings are ignored.
145
+ - `free-threading-limited-api` flags builds that turn on the limited API for 3.13t or
146
+ 3.14t. CPython 3.13 and 3.14 stop the compile with `#error "The limited API is not
147
+ currently supported in the free-threaded build"`, and setuptools refuses
148
+ `py_limited_api` there. Settings behind a `Py_GIL_DISABLED` check are not reported.
149
+
150
+ For example, `pygame==2.6.1` on 3.15 (it calls `PyWeakref_GetObject` in
151
+ `src_c/surface.c`) and `pycryptodome==3.19.0` on 3.14t (`py-limited-api = cp35` in
152
+ `setup.cfg`); `--verify` confirms both.
153
+
154
+ ### Git, path and URL dependencies
155
+
156
+ Dependencies that installers fetch directly are always built from source, so canibuild
157
+ checks them with the same rules:
158
+
159
+ - **git** (`source = { git = ... }` in `uv.lock`, `vcs` in `pylock.toml`,
160
+ `name @ git+https://...@rev` or `-e git+...` in requirements): fetched with
161
+ `git fetch --depth 1` at the locked commit (or the branch or tag the requirement names),
162
+ with hooks disabled and no submodules, then read like an sdist. Checkouts of a pinned
163
+ commit are cached. When the requirement names a branch or tag, or nothing, the report
164
+ says which commit was checked.
165
+ - **path** (`directory`, `path` and non-root `editable` sources, `./dir`, `file:` URLs):
166
+ the local directory or archive is read in place, relative to the lockfile.
167
+ - **URL** (`source = { url = ... }`, `archive` in `pylock.toml`, `name @ https://...`):
168
+ sdists are downloaded and read; a wheel URL is only checked against the target's tags.
169
+
170
+ Findings for these show where the code came from, and `--verify` builds them from the same
171
+ reference (`name @ git+URL@commit`), so a git build needs access to that git host.
172
+
173
+ ### Forcing or forbidding source builds
174
+
175
+ Some projects build certain packages from source on purpose, or forbid source builds
176
+ entirely. canibuild reads those settings and checks accordingly:
177
+
178
+ | Setting | Where canibuild reads it | Effect |
179
+ | --- | --- | --- |
180
+ | no-binary | `[tool.uv]` `no-binary = true` / `no-binary-package = [...]` (pyproject.toml or uv.toml next to `uv.lock`); `[tool.uv.pip]` `no-binary = [...]`; `--no-binary` lines in requirements files; `--no-binary PKGS` on the command line | Wheels are ignored for those packages, so their sdists are inspected even when a wheel exists. |
181
+ | no-build | `[tool.uv]` `no-build` / `no-build-package`; `[tool.uv.pip]` `no-build` and `only-binary`; `--only-binary` lines in requirements files; `--no-build PKGS` on the command line | A package with no matching wheel is an error (`no-build`), with the first newer release that has a wheel as the fix. |
182
+
183
+ `PKGS` is a comma-separated list of names or `:all:`; requirements files also accept
184
+ `:none:`, and later lines override earlier ones as in pip. A package named explicitly in
185
+ one setting beats `:all:` in the other. The report shows the settings in effect and where
186
+ they came from:
187
+
188
+ ```console
189
+ $ canibuild examples/broken/requirements.txt --python 3.12 --no-build :all:
190
+ canibuild: examples/broken/requirements.txt for CPython 3.12 on linux-x86_64
191
+ 2 packages checked, 0 build from source, 1 will fail, 0 may fail
192
+ build settings: no-build: :all: (from --no-build)
193
+ ```
123
194
 
124
195
  The setuptools version a build would get is worked out from the sdist's own
125
196
  `build-system.requires` (or pip's and uv's default of `setuptools>=40.8.0` when it has
@@ -155,7 +226,9 @@ error or warning, it builds that sdist in a throwaway environment with uv
155
226
  (`uv pip install --no-deps --no-binary PKG`, from PyPI only, isolated from your uv config),
156
227
  and records whether the build really fails the way canibuild said. When the finding has a
157
228
  build constraint such as `setuptools<82`, it builds once more with that constraint to show
158
- whether the fix works.
229
+ whether the fix works. For a missing build requirement such as `torch`, it builds once more
230
+ with the requirement added through uv's `extra-build-dependencies`, and shows the next error
231
+ if the build still fails (for `flash-attn` that is `CUDA_HOME` not being set).
159
232
 
160
233
  ```console
161
234
  $ canibuild examples/broken/requirements.txt --python 3.12 --verify --tool uv-pip
@@ -185,7 +258,7 @@ Each finding gets one of these results:
185
258
  | `fails-differently` | The build failed, but not with that error. The last error line is shown. |
186
259
  | `refuted` | The build succeeded. The finding no longer counts toward `--fail-on`. |
187
260
  | `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. |
261
+ | `skipped` | uv isn't installed, the target platform isn't this machine (the detail names both), or uv couldn't create an environment for the target Python. |
189
262
 
190
263
  Builds run one at a time, so `--verify` takes as long as the flagged builds do; large
191
264
  native packages can take minutes. uv may download the target Python if it isn't installed.
@@ -220,6 +293,7 @@ The lockfiles, their commits and the per-package results are in
220
293
  ```
221
294
  canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
222
295
  [--fail-on error|warning|never] [--tool TOOL] [--jobs N]
296
+ [--no-binary PKGS] [--no-build PKGS]
223
297
  [--verify] [--verify-timeout SECONDS] [--json-report PATH]
224
298
  [--cache-dir DIR] [--no-cache] [-v]
225
299
  ```
@@ -227,7 +301,8 @@ canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
227
301
  - `LOCKFILE`: one or more of `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
228
302
  Requirements files may include other files with `-r`. Unpinned requirements are checked
229
303
  at the newest release that matches and supports the target Python.
230
- - `--python`: the target Python, such as `3.12`. Defaults to the running interpreter, or
304
+ - `--python`: the target Python, such as `3.12`, `3.15`, or `3.14t` for a free-threaded
305
+ build. Defaults to the running interpreter, or
231
306
  to the oldest version a `uv.lock` or `pylock.toml` allows when the running one is outside
232
307
  its `requires-python`.
233
308
  - `--platform`: `linux-x86_64`, `linux-aarch64`, `musllinux-x86_64`, `musllinux-aarch64`,
@@ -236,6 +311,8 @@ canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
236
311
  - `--format json`: machine-readable output with every finding and fix (a list when you
237
312
  pass several lockfiles).
238
313
  - `--json-report PATH`: also write the JSON report, always as a list, while printing text.
314
+ - `--no-binary`, `--no-build`: force or forbid source builds (see above); added to the
315
+ settings found in the project's files.
239
316
  - `--verify`, `--verify-timeout`: build flagged sdists to confirm the findings (see above).
240
317
  - `--fail-on`: exit with 1 on errors (the default), on warnings too, or never.
241
318
  With several lockfiles, the run fails if any of them does. Usage errors and unreadable
@@ -248,13 +325,15 @@ or `$CANIBUILD_CACHE_DIR`).
248
325
 
249
326
  ```yaml
250
327
  - uses: actions/checkout@v4
251
- - uses: driftwright/canibuild@v0.2.0
328
+ - uses: driftwright/canibuild@v0.4.0
252
329
  with:
253
330
  lockfiles: uv.lock # default: every uv.lock, pylock*.toml, requirements*.txt
254
331
  python: "3.12" # default: as for --python below
255
332
  # platform: linux-x86_64 # default: the runner
256
333
  # fail-on: error # error, warning or never
257
334
  # tool: uv # tools to show fixes for
335
+ # no-binary: ":all:" # build these from source even when a wheel exists
336
+ # no-build: numpy # these must install from a wheel
258
337
  # verify: "true" # build flagged sdists to confirm the findings
259
338
  ```
260
339
 
@@ -269,7 +348,7 @@ when `platform` is the runner's own.
269
348
  ```yaml
270
349
  repos:
271
350
  - repo: https://github.com/driftwright/canibuild
272
- rev: v0.2.0
351
+ rev: v0.4.0
273
352
  hooks:
274
353
  - id: canibuild
275
354
  # args: [--python, "3.12"]
@@ -280,10 +359,13 @@ network access to PyPI.
280
359
 
281
360
  ## Limits
282
361
 
283
- - Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
284
- other indexes (such as `torch==2.1.2+cu121`), are listed as not checked.
362
+ - Versions from other indexes (such as `torch==2.1.2+cu121`) and non-git version control
363
+ (Mercurial, Subversion, Bazaar) are listed as not checked. Private git repositories work
364
+ only if `git` can reach them without a prompt.
285
365
  - The checks are static. A `setup.py` that fails for a reason not in the table above, or
286
- that needs a compiler or system library you don't have, isn't caught.
366
+ that needs a compiler or system library you don't have, isn't caught. The C checks only
367
+ cover the removed 3.15 functions and the limited-API conflict; other free-threading
368
+ problems (thread safety, `Py_mod_gil`) and C files over 512 KiB are not inspected.
287
369
  - Requirements files are not resolved: only the packages they list are checked, not their
288
370
  dependencies. Use a lockfile (`uv.lock`, `pylock.toml`, or `pip-compile` output) for the
289
371
  full tree.
@@ -83,11 +83,82 @@ imports, and parses them with `ast`. It never runs code from a package.
83
83
  | `distutils` | `setup.py` imports `distutils` on Python 3.12+ and setuptools isn't in the build |
84
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
85
  | `no-installable-file` | there is no wheel for the target and no sdist |
86
+ | `c-api-removed` | Python 3.15+: a C or C++ source calls a function that [Python 3.15 removed](https://docs.python.org/3.15/whatsnew/3.15.html#removed-c-apis), such as `PyWeakref_GetObject` or `Py_GetPrefix`, outside any version check |
87
+ | `free-threading-limited-api` | free-threaded 3.13t or 3.14t: the build enables the limited C API (`py_limited_api` in `setup.cfg` or `setup.py`, or `Py_LIMITED_API` defined in a source file or `define_macros`), which [these builds reject](https://github.com/python/cpython/issues/111506) |
86
88
 
87
89
  An import inside a `try: ... except ImportError` is ignored. An import inside a function
88
90
  is reported as a warning, since it fails only if that code runs during the build.
89
91
  Packages that build from source with no known problem are listed as such, with a note
90
- when they compile native code.
92
+ when they compile native code. When such a package has compiled wheels, just none for
93
+ the target (say, wheels up to `cp313` but not `cp315` or `cp314t`), it is reported as a
94
+ `no-wheel-for-python` warning, since the build is probably unexpected and needs a
95
+ compiler; the fix names the first newer release with a matching wheel.
96
+
97
+ ### New Python versions and free-threaded builds
98
+
99
+ Pass `--python 3.15` to check a new Python before its wheels are out, and
100
+ `--python 3.14t` (or `cp314t`) for the free-threaded build. Wheel matching follows the
101
+ interpreter: `abi3` wheels don't install on free-threaded 3.13t and 3.14t, and on 3.15t
102
+ only `abi3t` wheels ([PEP 803](https://peps.python.org/pep-0803/)) do.
103
+
104
+ Two checks read the C sources of packages that would be built:
105
+
106
+ - `c-api-removed` looks for calls to the functions listed under "Removed C APIs" in
107
+ What's New in Python 3.15. With GCC 14+ or Clang 16+ the build fails with an implicit
108
+ declaration error; older compilers build a module that fails on import. Calls are
109
+ skipped when they sit inside an `#if` on `PY_VERSION_HEX`, `PY_MINOR_VERSION`,
110
+ `Py_LIMITED_API`, `PYPY_VERSION` or a Cython switch (or a macro defined from one of
111
+ those), when the package defines the name itself (a compat header), and under
112
+ `tests/`, `docs/` and `examples/`. Comments and strings are ignored.
113
+ - `free-threading-limited-api` flags builds that turn on the limited API for 3.13t or
114
+ 3.14t. CPython 3.13 and 3.14 stop the compile with `#error "The limited API is not
115
+ currently supported in the free-threaded build"`, and setuptools refuses
116
+ `py_limited_api` there. Settings behind a `Py_GIL_DISABLED` check are not reported.
117
+
118
+ For example, `pygame==2.6.1` on 3.15 (it calls `PyWeakref_GetObject` in
119
+ `src_c/surface.c`) and `pycryptodome==3.19.0` on 3.14t (`py-limited-api = cp35` in
120
+ `setup.cfg`); `--verify` confirms both.
121
+
122
+ ### Git, path and URL dependencies
123
+
124
+ Dependencies that installers fetch directly are always built from source, so canibuild
125
+ checks them with the same rules:
126
+
127
+ - **git** (`source = { git = ... }` in `uv.lock`, `vcs` in `pylock.toml`,
128
+ `name @ git+https://...@rev` or `-e git+...` in requirements): fetched with
129
+ `git fetch --depth 1` at the locked commit (or the branch or tag the requirement names),
130
+ with hooks disabled and no submodules, then read like an sdist. Checkouts of a pinned
131
+ commit are cached. When the requirement names a branch or tag, or nothing, the report
132
+ says which commit was checked.
133
+ - **path** (`directory`, `path` and non-root `editable` sources, `./dir`, `file:` URLs):
134
+ the local directory or archive is read in place, relative to the lockfile.
135
+ - **URL** (`source = { url = ... }`, `archive` in `pylock.toml`, `name @ https://...`):
136
+ sdists are downloaded and read; a wheel URL is only checked against the target's tags.
137
+
138
+ Findings for these show where the code came from, and `--verify` builds them from the same
139
+ reference (`name @ git+URL@commit`), so a git build needs access to that git host.
140
+
141
+ ### Forcing or forbidding source builds
142
+
143
+ Some projects build certain packages from source on purpose, or forbid source builds
144
+ entirely. canibuild reads those settings and checks accordingly:
145
+
146
+ | Setting | Where canibuild reads it | Effect |
147
+ | --- | --- | --- |
148
+ | no-binary | `[tool.uv]` `no-binary = true` / `no-binary-package = [...]` (pyproject.toml or uv.toml next to `uv.lock`); `[tool.uv.pip]` `no-binary = [...]`; `--no-binary` lines in requirements files; `--no-binary PKGS` on the command line | Wheels are ignored for those packages, so their sdists are inspected even when a wheel exists. |
149
+ | no-build | `[tool.uv]` `no-build` / `no-build-package`; `[tool.uv.pip]` `no-build` and `only-binary`; `--only-binary` lines in requirements files; `--no-build PKGS` on the command line | A package with no matching wheel is an error (`no-build`), with the first newer release that has a wheel as the fix. |
150
+
151
+ `PKGS` is a comma-separated list of names or `:all:`; requirements files also accept
152
+ `:none:`, and later lines override earlier ones as in pip. A package named explicitly in
153
+ one setting beats `:all:` in the other. The report shows the settings in effect and where
154
+ they came from:
155
+
156
+ ```console
157
+ $ canibuild examples/broken/requirements.txt --python 3.12 --no-build :all:
158
+ canibuild: examples/broken/requirements.txt for CPython 3.12 on linux-x86_64
159
+ 2 packages checked, 0 build from source, 1 will fail, 0 may fail
160
+ build settings: no-build: :all: (from --no-build)
161
+ ```
91
162
 
92
163
  The setuptools version a build would get is worked out from the sdist's own
93
164
  `build-system.requires` (or pip's and uv's default of `setuptools>=40.8.0` when it has
@@ -123,7 +194,9 @@ error or warning, it builds that sdist in a throwaway environment with uv
123
194
  (`uv pip install --no-deps --no-binary PKG`, from PyPI only, isolated from your uv config),
124
195
  and records whether the build really fails the way canibuild said. When the finding has a
125
196
  build constraint such as `setuptools<82`, it builds once more with that constraint to show
126
- whether the fix works.
197
+ whether the fix works. For a missing build requirement such as `torch`, it builds once more
198
+ with the requirement added through uv's `extra-build-dependencies`, and shows the next error
199
+ if the build still fails (for `flash-attn` that is `CUDA_HOME` not being set).
127
200
 
128
201
  ```console
129
202
  $ canibuild examples/broken/requirements.txt --python 3.12 --verify --tool uv-pip
@@ -153,7 +226,7 @@ Each finding gets one of these results:
153
226
  | `fails-differently` | The build failed, but not with that error. The last error line is shown. |
154
227
  | `refuted` | The build succeeded. The finding no longer counts toward `--fail-on`. |
155
228
  | `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. |
229
+ | `skipped` | uv isn't installed, the target platform isn't this machine (the detail names both), or uv couldn't create an environment for the target Python. |
157
230
 
158
231
  Builds run one at a time, so `--verify` takes as long as the flagged builds do; large
159
232
  native packages can take minutes. uv may download the target Python if it isn't installed.
@@ -188,6 +261,7 @@ The lockfiles, their commits and the per-package results are in
188
261
  ```
189
262
  canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
190
263
  [--fail-on error|warning|never] [--tool TOOL] [--jobs N]
264
+ [--no-binary PKGS] [--no-build PKGS]
191
265
  [--verify] [--verify-timeout SECONDS] [--json-report PATH]
192
266
  [--cache-dir DIR] [--no-cache] [-v]
193
267
  ```
@@ -195,7 +269,8 @@ canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
195
269
  - `LOCKFILE`: one or more of `uv.lock`, `pylock.toml` (or `pylock.NAME.toml`), or a requirements file.
196
270
  Requirements files may include other files with `-r`. Unpinned requirements are checked
197
271
  at the newest release that matches and supports the target Python.
198
- - `--python`: the target Python, such as `3.12`. Defaults to the running interpreter, or
272
+ - `--python`: the target Python, such as `3.12`, `3.15`, or `3.14t` for a free-threaded
273
+ build. Defaults to the running interpreter, or
199
274
  to the oldest version a `uv.lock` or `pylock.toml` allows when the running one is outside
200
275
  its `requires-python`.
201
276
  - `--platform`: `linux-x86_64`, `linux-aarch64`, `musllinux-x86_64`, `musllinux-aarch64`,
@@ -204,6 +279,8 @@ canibuild [check] LOCKFILE... [--python X.Y] [--platform P] [--format text|json]
204
279
  - `--format json`: machine-readable output with every finding and fix (a list when you
205
280
  pass several lockfiles).
206
281
  - `--json-report PATH`: also write the JSON report, always as a list, while printing text.
282
+ - `--no-binary`, `--no-build`: force or forbid source builds (see above); added to the
283
+ settings found in the project's files.
207
284
  - `--verify`, `--verify-timeout`: build flagged sdists to confirm the findings (see above).
208
285
  - `--fail-on`: exit with 1 on errors (the default), on warnings too, or never.
209
286
  With several lockfiles, the run fails if any of them does. Usage errors and unreadable
@@ -216,13 +293,15 @@ or `$CANIBUILD_CACHE_DIR`).
216
293
 
217
294
  ```yaml
218
295
  - uses: actions/checkout@v4
219
- - uses: driftwright/canibuild@v0.2.0
296
+ - uses: driftwright/canibuild@v0.4.0
220
297
  with:
221
298
  lockfiles: uv.lock # default: every uv.lock, pylock*.toml, requirements*.txt
222
299
  python: "3.12" # default: as for --python below
223
300
  # platform: linux-x86_64 # default: the runner
224
301
  # fail-on: error # error, warning or never
225
302
  # tool: uv # tools to show fixes for
303
+ # no-binary: ":all:" # build these from source even when a wheel exists
304
+ # no-build: numpy # these must install from a wheel
226
305
  # verify: "true" # build flagged sdists to confirm the findings
227
306
  ```
228
307
 
@@ -237,7 +316,7 @@ when `platform` is the runner's own.
237
316
  ```yaml
238
317
  repos:
239
318
  - repo: https://github.com/driftwright/canibuild
240
- rev: v0.2.0
319
+ rev: v0.4.0
241
320
  hooks:
242
321
  - id: canibuild
243
322
  # args: [--python, "3.12"]
@@ -248,10 +327,13 @@ network access to PyPI.
248
327
 
249
328
  ## Limits
250
329
 
251
- - Only packages from PyPI are checked. Git, path and URL dependencies, and versions from
252
- other indexes (such as `torch==2.1.2+cu121`), are listed as not checked.
330
+ - Versions from other indexes (such as `torch==2.1.2+cu121`) and non-git version control
331
+ (Mercurial, Subversion, Bazaar) are listed as not checked. Private git repositories work
332
+ only if `git` can reach them without a prompt.
253
333
  - The checks are static. A `setup.py` that fails for a reason not in the table above, or
254
- that needs a compiler or system library you don't have, isn't caught.
334
+ that needs a compiler or system library you don't have, isn't caught. The C checks only
335
+ cover the removed 3.15 functions and the limited-API conflict; other free-threading
336
+ problems (thread safety, `Py_mod_gil`) and C files over 512 KiB are not inspected.
255
337
  - Requirements files are not resolved: only the packages they list are checked, not their
256
338
  dependencies. Use a lockfile (`uv.lock`, `pylock.toml`, or `pip-compile` output) for the
257
339
  full tree.
@@ -27,6 +27,8 @@ args=(--fail-on "$CANIBUILD_FAIL_ON")
27
27
  [[ -n "$CANIBUILD_PLATFORM" ]] && args+=(--platform "$CANIBUILD_PLATFORM")
28
28
  for tool in $CANIBUILD_TOOL; do args+=(--tool "$tool"); done
29
29
  [[ "$CANIBUILD_VERIFY" == "true" ]] && args+=(--verify)
30
+ [[ -n "${CANIBUILD_NO_BINARY:-}" ]] && args+=(--no-binary "$CANIBUILD_NO_BINARY")
31
+ [[ -n "${CANIBUILD_NO_BUILD:-}" ]] && args+=(--no-build "$CANIBUILD_NO_BUILD")
30
32
 
31
33
  report="${RUNNER_TEMP:-/tmp}/canibuild-report.json"
32
34
  text="${RUNNER_TEMP:-/tmp}/canibuild-report.txt"
@@ -15,7 +15,7 @@ inputs:
15
15
  description: Directory the lockfile paths are relative to.
16
16
  default: "."
17
17
  python:
18
- description: Target Python version (X.Y). Defaults to the oldest version the lockfile allows.
18
+ description: Target Python version, such as 3.13 or 3.14t (free-threaded). Defaults to the oldest version the lockfile allows.
19
19
  default: ""
20
20
  platform:
21
21
  description: Target platform, e.g. linux-x86_64, macos-arm64, windows-amd64. Defaults to the runner.
@@ -26,6 +26,12 @@ inputs:
26
26
  tool:
27
27
  description: "Tools to write fixes for, separated by spaces: uv, uv-pip, pip, poetry or all."
28
28
  default: ""
29
+ no-binary:
30
+ description: "Packages to build from source even when a wheel exists (comma-separated, or :all:)."
31
+ default: ""
32
+ no-build:
33
+ description: "Packages that must install from a wheel (comma-separated, or :all:)."
34
+ default: ""
29
35
  verify:
30
36
  description: Build each flagged sdist in a throwaway environment to confirm the prediction.
31
37
  default: "false"
@@ -55,6 +61,8 @@ runs:
55
61
  CANIBUILD_FAIL_ON: ${{ inputs.fail-on }}
56
62
  CANIBUILD_TOOL: ${{ inputs.tool }}
57
63
  CANIBUILD_VERIFY: ${{ inputs.verify }}
64
+ CANIBUILD_NO_BINARY: ${{ inputs.no-binary }}
65
+ CANIBUILD_NO_BUILD: ${{ inputs.no-build }}
58
66
  CANIBUILD_VERSION: ${{ inputs.version }}
59
67
  CANIBUILD_ACTION_PATH: ${{ github.action_path }}
60
68
  run: "$CANIBUILD_ACTION_PATH/action/run.sh"
@@ -94,3 +94,58 @@ Run on 2026-12-05 with canibuild 0.2.0 and uv 0.13.10, same lockfiles and target
94
94
  | pcse-notebooks | salib 1.3.12 | confirmed: `No module named 'pkg_resources'` | builds |
95
95
  | wenet | openai-whisper 20231117 | confirmed: `No module named 'pkg_resources'` | builds |
96
96
  | whisper-s2t | openai-whisper 20231117 | confirmed: `No module named 'pkg_resources'` | builds |
97
+
98
+ ## Git, path and URL dependencies
99
+
100
+ Run on 2026-12-05 with canibuild 0.3.0. Every direct dependency in the lockfiles above,
101
+ plus a uv project that locks `flatdict` from git, `jproperties` from an sdist URL and a
102
+ local directory, was checked and then built with `uv pip install --no-deps` from the same
103
+ reference:
104
+
105
+ | Lockfile | Dependency | Real build | canibuild |
106
+ | --- | --- | --- | --- |
107
+ | Whisper-WebUI | `git+https://github.com/jhj0517/jhj0517-whisper.git` (unpinned, checked at `197244318d5d`) | fails: `No module named 'pkg_resources'` | error `pkg-resources` |
108
+ | Whisper-WebUI | `git+https://github.com/jhj0517/ultimatevocalremover_api.git` | builds | builds from source |
109
+ | Whisper-WebUI | `git+https://github.com/jhj0517/pyrubberband.git` | builds | builds from source |
110
+ | mcp-bible | mcp-weather, git `cdcae1b61322` | builds | builds from source |
111
+ | moshi-finetune | moshi, git `061cc4c630d9`, subdirectory `moshi` | builds | builds from source |
112
+ | uv sample | flatdict 4.0.1, git `f86186671944` | fails: `pkg_resources` | error `pkg-resources`, confirmed by `--verify`; builds with `setuptools<82` |
113
+ | uv sample | jproperties 2.1.1, sdist URL | fails: `pkg_resources` (via setuptools-scm 3.5) | error `build-tool-needs-pkg-resources`, confirmed; builds with `setuptools<82` |
114
+ | uv sample | localpkg, local directory | builds | builds from source |
115
+
116
+ `flash-attn` 2.8.3.post2 (OmniNWM) with `torch` added to its build through
117
+ `extra-build-dependencies` gets past the missing import and then fails on
118
+ `CUDA_HOME environment variable is not set`, which `--verify` now reports.
119
+
120
+ ## Python 3.15 and free-threaded 3.14t
121
+
122
+ Run on 2026-12-05 with the 0.4.0 code, with uv-managed CPython 3.15.2 and
123
+ 3.14.10+freethreaded, GCC 14, on linux-x86_64.
124
+
125
+ The 13 lockfiles above, checked with `--python 3.15` and `--python 3.14t`:
126
+
127
+ | Target | `no-wheel-for-python` | `c-api-removed` | `free-threading-limited-api` |
128
+ | --- | --- | --- | --- |
129
+ | 3.15 | 55 pins (PyYAML 6.0.1, aiohttp 3.11.16, cffi 1.17.1, greenlet 3.3.1, numpy 1.26.4, pydantic-core 2.33.2, ...) | psycopg2-binary 2.9.9 (nvidia-chain-server) | n/a |
130
+ | 3.14t | 59 pins (the above plus bcrypt 5.0.0, hf-xet 1.2.0, regex 2024.11.6, ...) | n/a | none |
131
+
132
+ Real builds of the C findings, and of packages that look similar but are fine:
133
+
134
+ | Package | Target | canibuild | Real build |
135
+ | --- | --- | --- | --- |
136
+ | pygame 2.6.1 | 3.15 | `c-api-removed` (`PyWeakref_GetObject`, `src_c/surface.c`) | fails: `implicit declaration of function 'PyWeakref_GetObject'`, confirmed by `--verify` |
137
+ | psycopg2-binary 2.9.9 | 3.15 | `c-api-removed` (`psycopg/connection_int.c:1050`) | fails with the same error, confirmed |
138
+ | pycryptodome 3.19.0 | 3.14t | `free-threading-limited-api` (`py-limited-api = cp35` in `setup.cfg`) | fails: setuptools `` `Py_LIMITED_API` is incompatible with `Py_GIL_DISABLED` ``, confirmed |
139
+ | sentencepiece 0.2.0 | 3.15 | builds from source (SWIG code under `#ifdef SWIGPYTHON_BUILTIN`) | builds |
140
+ | psycopg2 2.9.13, pycurl 7.49.0, PyQt5-sip 12.20.1, msgpack 1.2.4 | 3.15 | builds from source (calls behind `PY_VERSION_HEX` checks) | build |
141
+ | psutil 7.2.2, pycryptodome 3.23.0, gssapi 1.12.0 | 3.14t | builds from source (limited API only when `Py_GIL_DISABLED` is unset) | not built; the settings are visibly conditional |
142
+
143
+ The sentencepiece run and a first version that also reported cffi 1.17.1 (a header it
144
+ ships for generated modules) and sip 6.17.3 (C templates in a pure-Python package) led
145
+ to the rules for optional `#ifdef` branches, included headers and pure-Python builds.
146
+ With those, 32 current releases of common C-extension packages, forced to build with
147
+ `--no-binary :all:`, produce no C findings on either target.
148
+
149
+ Not caught: other reasons a build fails on a new Python. numpy 1.26.4, for example, is
150
+ only reported as building from source on 3.15; whether it compiles there is not
151
+ checked.
@@ -0,0 +1 @@
1
+ flatdict @ git+https://github.com/gmr/flatdict@f86186671944e39ae194b49c5f444d69ffa37424
@@ -1,3 +1,3 @@
1
1
  """Find the dependencies in a lockfile that will fail to build from source."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.4.0"