Commit f902668
authored
Work around intermittent Windows build failure (missing pyconfig.h. etc.) (#48188)
### What does this PR do?
Add `common:windows --enable_runfiles` to `.bazelrc`.
### Motivation
rules_python 1.9.0 (introduced in #48082) transitions every `py_binary` on Windows to `enable_runfiles=true`.
With Bazel's default of `enable_runfiles=false` on Windows, this creates a second Bazel configuration, causing `python_win` to be built twice concurrently.
`build_python.bat` writes MSBuild intermediate files (`PCbuild/obj/`, `PCbuild/amd64/`, `msbuild.rsp`) into the shared execroot source tree rather than into the action's output directory, so the two concurrent builds race on those files, manifesting as intermittent `pyconfig.h: No such file or directory` errors that disappear when the cache is warm.
See, for instance: https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/1528499363
Setting `enable_runfiles=true` globally makes the transition a no-op (same flag value => same configuration hash => one build of `python_win`), eliminating the race.
### Describe how you validated your changes
Analysis of a failing CI job log (`PCbuild/obj/*.pdb` locked by another process during CleanAll).
### Additional Notes
This is a short-term workaround. The proper fix is to make `build_python.bat` hermetic by redirecting MSBuild's output and intermediate directories to `$(@d)` instead of the execroot source tree.
`rules_python` doesn't touch `build_python.bat` directly. The connection is through Bazel's configuration graph:
1. `build_python.bat` is invoked by `python_win` (`run_binary` target) in `deps/cpython.BUILD.bazel`,
2. `python_win` is a dependency of `pkg_install` (via `install_files_win`),
3. `pkg_install` from `rules_pkg` is backed by a `py_binary`,
4. `rules_python` 1.9.0 makes every `py_binary` on Windows transition into a new Bazel configuration (`enable_runfiles=true`),
5. Since `python_win` sits in the dependency graph of that `py_binary`, Bazel now needs it in two configurations: the base one (for tests / other consumers) and the transitioned one (for `pkg_install`),
6. Two configurations => two independent Bazel actions, both calling `build_python.bat` in the same execroot directory => race.
Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>1 parent c08404f commit f902668
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
0 commit comments