Commit 9f45579
committed
fix(core): don't abort the build on an empty integer build knob
cuda_core/build_hooks.py reads two integer knobs from the environment with
a bare int():
COMPILE_FOR_COVERAGE = bool(int(os.environ.get("CUDA_PYTHON_COVERAGE", "0")))
nthreads = int(os.environ.get("CUDA_PYTHON_PARALLEL_LEVEL", os.cpu_count() // 2))
os.environ.get returns the empty string, not the default, when a variable is
set but empty -- and `VAR= pip install .` (or an empty Dockerfile ENV, or an
unfilled CI job variable) is exactly how these get neutralised. The first
line runs at module scope, so the failure lands while pip is still importing
the PEP 517 backend:
$ CUDA_PYTHON_COVERAGE= pip install ./cuda_core
ValueError: invalid literal for int() with base 10: ''
cuda_core/setup.py carries the same two expressions verbatim.
Add build_hooks.env_int and route all four call sites through it. Unset and
empty/whitespace-only both fall back to the default; a value that is set to
something non-integer still raises, but names the variable
(`environment variable CUDA_PYTHON_COVERAGE='yes' must be an integer`)
instead of an anonymous int() failure. Silently ignoring `=yes` would be
worse than stopping here -- it would hand back a build with no coverage
instrumentation.
Also stop assuming os.cpu_count() returns a number. It is documented to
return None when the count cannot be determined, which made the nthreads
default a TypeError. Fall back to a serial build instead.
setup.py already imports build_hooks, so both build entry points now parse
these knobs through the same helper rather than duplicating the expression.1 parent 3bd069a commit 9f45579
3 files changed
Lines changed: 78 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
30 | 54 | | |
31 | 55 | | |
32 | 56 | | |
| |||
219 | 243 | | |
220 | 244 | | |
221 | 245 | | |
222 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
223 | 249 | | |
224 | 250 | | |
225 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
0 commit comments