GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — fix(py_test): fix Windows crash in `py_test` main validation by rdesgroppes · Pull Request #4079 · bazel-contrib/rules_python Conversation
|
@rickeylev merci ! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`python/private/py_executable.bzl`'s `_maybe_add_test_main_validation` fix (bazel-contrib#4079) noted `precompile.bzl` as a remaining user of the same `exec_interpreter` relocation issue, needing the same migration. There was no existing test exercising `_precompile`'s action at all: `tests/base_rules/precompile`'s suite is `analysis_test`-only, checking declared providers, never actually running the precompiler. Reproducing this on Windows therefore required a real `bazel build`, via the new `test_precompile_enabled_succeeds`: ``` bazel test \ //tests/base_rules/precompile:test_precompile_enabled_succeeds ... ERROR: .../tests/base_rules/precompile/BUILD.bazel:3:22: Python precompiling .../test_precompile_enabled_succeeds_main.py into .../test_precompile_enabled_succeeds_main.cpython-311.pyc failed: Worker process did not return a WorkResponse: ---8<---8<--- Start of log, file at .../multiplex-worker-1-PyCompile.log ---8<---8<--- (empty) ---8<---8<--- End of log ---8<---8<--- ``` The worker crashes at startup, unable to find its DLLs, before it can write anything to its own log or respond over the worker protocol. `_precompile` now uses `actions_run()` with `exec_runtime`, exactly as `_maybe_add_test_main_validation` does, instead of `exec_tools_info.exec_interpreter[DefaultInfo].files_to_run`. Reproducing and fixing this also uncovered two more problems, both specific to the precompiler's worker mode and unrelated to `exec_interpreter`. First, `tools/precompiler/precompiler.py`'s persistent worker reads each JSON request as a single line via `asyncio.StreamReader`, whose default 64KiB limit is exceeded once every interpreter distribution file, previously hidden by relocation into a much smaller symlink tree, shows up as an actual, individually-digested action input: ``` ValueError: Separator is not found, and chunk exceed the limit ``` A CPython 3.11 distribution's ~2,260 inputs measure ~470KiB this way; `1 << 22` (4MiB) leaves ample headroom. Second, the worker's default implementation, `_AsyncPersistentWorker`, can't start on Windows at all: `asyncio`'s `ProactorEventLoop` fails to wrap `stdin`/`stdout` as pipe transports, with: ``` OSError: [WinError 6] The handle is invalid ``` Bazel gives workers anonymous pipes (`CreatePipe`) for stdio, which never support overlapped I/O, so `asyncio`'s `ProactorEventLoop` can't register them with an I/O completion port. This is unrelated to precompiling's relocation bug: nothing exercises this worker on Windows today. `_SerialPersistentWorker`, the blocking-I/O alternative already present in the file, has no such issue, so `--worker_impl` now defaults to `serial` on Windows. `tests/base_rules/precompile:test_precompile_enabled_succeeds` is a real, executing `py_test` with `precompile = "enabled"`, added alongside the analysis-only suite to close this gap: it forces the precompiler action to actually run, and needs no CI wiring since it carries no tag excluding it from the existing Windows job's default test sweep.
…zel-contrib#4082) `python/private/py_executable.bzl`'s `_maybe_add_test_main_validation` fix (bazel-contrib#4079) noted `precompile.bzl` as a remaining user of the same `exec_interpreter` relocation issue, needing the same migration. There was no existing test exercising `_precompile`'s action at all: `tests/base_rules/precompile`'s suite is `analysis_test`-only, checking declared providers, never actually running the precompiler. Reproducing this on Windows therefore required a real `bazel build`, via the new `test_precompile_enabled_succeeds`: ``` bazel test \ //tests/base_rules/precompile:test_precompile_enabled_succeeds ... ERROR: .../tests/base_rules/precompile/BUILD.bazel:3:22: Python precompiling .../test_precompile_enabled_succeeds_main.py into .../test_precompile_enabled_succeeds_main.cpython-311.pyc failed: Worker process did not return a WorkResponse: ---8<---8<--- Start of log, file at .../multiplex-worker-1-PyCompile.log ---8<---8<--- (empty) ---8<---8<--- End of log ---8<---8<--- ``` The worker crashes at startup, unable to find its DLLs, before it can write anything to its own log or respond over the worker protocol. `_precompile` now uses `actions_run()` with `exec_runtime`, exactly as `_maybe_add_test_main_validation` does, instead of `exec_tools_info.exec_interpreter[DefaultInfo].files_to_run`. Reproducing and fixing this also uncovered two more problems, both specific to the precompiler's worker mode and unrelated to `exec_interpreter`. First, `tools/precompiler/precompiler.py`'s persistent worker reads each JSON request as a single line via `asyncio.StreamReader`, whose default 64KiB limit is exceeded once every interpreter distribution file, previously hidden by relocation into a much smaller symlink tree, shows up as an actual, individually-digested action input: ``` ValueError: Separator is not found, and chunk exceed the limit ``` A CPython 3.11 distribution's ~2,260 inputs measure ~470KiB this way; `1 << 22` (4MiB) leaves ample headroom. Second, the worker's default implementation, `_AsyncPersistentWorker`, can't start on Windows at all: `asyncio`'s `ProactorEventLoop` fails to wrap `stdin`/`stdout` as pipe transports, with: ``` OSError: [WinError 6] The handle is invalid ``` Bazel gives workers anonymous pipes (`CreatePipe`) for stdio, which never support overlapped I/O, so `asyncio`'s `ProactorEventLoop` can't register them with an I/O completion port. This is unrelated to precompiling's relocation bug: nothing exercises this worker on Windows today. `_SerialPersistentWorker`, the blocking-I/O alternative already present in the file, has no such issue, so `--worker_impl` now defaults to `serial` on Windows. `tests/base_rules/precompile:test_precompile_enabled_succeeds` is a real, executing `py_test` with `precompile = "enabled"`, added alongside the analysis-only suite to close this gap: it forces the precompiler action to actually run, and needs no CI wiring since it carries no tag excluding it from the existing Windows job's default test sweep.
tl;dr: brings our own fix: - bazel-contrib/rules_python#4079 --- This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [rules_python](https://redirect.github.com/bazel-contrib/rules_python) | bazel_dep | minor | `2.3.4` → `2.4.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the [Dependency Dashboard](../issues/33469) for more information. --- ### Release Notes <details> <summary>bazel-contrib/rules_python (rules_python)</summary> ### [`v2.4.0`](https://redirect.github.com/bazel-contrib/rules_python/blob/HEAD/CHANGELOG.md#240---2026-09-22) [Compare Source](https://redirect.github.com/bazel-contrib/rules_python/compare/2.3.4...2.4.0) [2.4.0]: https://redirect.github.com/bazel-contrib/rules_python/releases/tag/2.4.0 {#v2-4-0-changed} ##### Changed - (bootstrap) {obj}`sys.path` adds the Python runtime in runfiles instead of the underlying Bazel repository cache directory ([#​4104](https://redirect.github.com/bazel-contrib/rules_python/pull/4104)). - (gazelle) Deprecate the `requirements` argument of `gazelle_python_manifest` in favor of the format-agnostic `lockfiles` argument, which supports `uv.lock`. - (toolchain) Updated default Python 3.15 runtime from `3.15.0a8` to `3.15.0rc1` ([#​4122](https://redirect.github.com/bazel-contrib/rules_python/pull/4122)). - (toolchain) Updated default Python 3.15 runtime from `3.15.0rc1` to `3.15.0rc2`. - (toolchain) Updated the default Python toolchain version from `3.11` to `3.14` in {obj}`python.defaults`, {obj}`python_register_toolchains`, and {obj}`python_register_multi_toolchains` ([#​4023](https://redirect.github.com/bazel-contrib/rules_python/pull/4023)). - (toolchains) Shared `libpython*.so*` files are now excluded by default from hermetic Python runtime files for recognized Astral `python-build-standalone` builds (`20250517` and newer), which statically link `libpython` into the interpreter. Older, custom, or unrecognized runtimes retain them. Set `libpython = "include"` or `"exclude"` on {obj}`python.override`, {obj}`python.single_version_override`, {obj}`python.single_version_platform_override`, or {obj}`python_register_toolchains` to override this behavior ([#​4165](https://redirect.github.com/bazel-contrib/rules_python/pull/4165)). {#v2-4-0-fixed} ##### Fixed - Include the Python toolchain's static libraries when `current_py_cc_libs` is used as a dependency of `cc_shared_library`. - (bzlmod) Fixed a type mismatch error when using {obj}`coverage_tool` with {obj}`python.single_version_platform_override` ([#​2570](https://redirect.github.com/bazel-contrib/rules_python/issues/2570)). - (precompile) Fixed handling of directory and `.pyc` file inputs in {obj}`srcs` when {obj}`precompile` is enabled on {obj}`py_library`, {obj}`py_binary`, and {obj}`py_test` targets ([#​4113](https://redirect.github.com/bazel-contrib/rules_python/pull/4113)). - (pypi) Fixed wheel RECORD file generation on Windows so that rewritten shebang scripts correctly include the `.bat` extension ([#​4114](https://redirect.github.com/bazel-contrib/rules_python/pull/4114)). - (pypi) Fixed {obj}`RECORD` file paths for extracted `.data` directory contents so that {obj}`importlib.metadata.files()` correctly locates installed distribution files ([#​4025](https://redirect.github.com/bazel-contrib/rules_python/pull/4025)). - (pypi) Venv mode now works on NixOS and no longer requires coreutils to process wheel scripts and RECORD files ([#​4125](https://redirect.github.com/bazel-contrib/rules_python/pull/4125)). - (rules) Fixed loading Python extension modules from paths longer than `MAX_PATH` on Windows. - (runfiles) Updated {obj}`runfiles.Path` method signatures for Python 3.14 typeshed compatibility and fixed {obj}`runfiles.Path.match` on Python 3.12+. ([#​4023](https://redirect.github.com/bazel-contrib/rules_python/issues/4023)) - (stamping) The build data spawn action is now skipped when `--stamp=false` and, instead the metadata file is written at analysis time via `ctx.actions.write()`. - (toolchain) Fixed a crash in {obj}`py_test` main validation ({obj}`validate_test_main`) on Windows: the interpreter used for the check couldn't find its DLLs or its stdlib once relocated ([#​4079](https://redirect.github.com/bazel-contrib/rules_python/issues/4079)). - (toolchain) Fixed a crash on Windows when precompiling is enabled: the precompiler's interpreter couldn't find its DLLs once relocated ([#​4082](https://redirect.github.com/bazel-contrib/rules_python/issues/4082)). - (zipapp) Reduced self-contained archive sizes by preserving Python executable symlinks instead of storing each alias as another copy of the interpreter, and by omitting shared `libpython` files from recognized statically linked Astral runtime builds. {#v2-4-0-added} ##### Added - (pypi) `py.typed` files from wheels are now included in the `pyi_srcs` of the wheel's `py_library`, alongside `.pyi` files. The `py.typed` file of `//python/runfiles` is now included in its `pyi_srcs` as well. - (runfiles) Added {obj}`Runfiles.CreateOrRaise` to return a `Runfiles` instance or raise an error if runfiles cannot be found. - (uv) Added {obj}`directory` attribute to {obj}`lock` to support running `uv` commands within subdirectories when generating lock files. Defaults to the package directory, set it to `None` or `""` to set it to the root of the repo ([#​4029](https://redirect.github.com/bazel-contrib/rules_python/issues/4029)). {#v2-3-4} </details> --- ### Configuration 📅 **Schedule**: (in timezone Europe/Paris) - Branch creation - At 12:00 AM through 04:59 AM and 10:00 PM through 11:59 PM, Monday through Friday (`* 0-4,22-23 * * 1-5`) - Only on Sunday and Saturday (`* * * * 0,6`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/DataDog/datadog-agent). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMzQuMSIsInVwZGF0ZWRJblZlciI6IjQ0LjEzNC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJjaGFuZ2Vsb2cvbm8tY2hhbmdlbG9nIiwiZGVwZW5kZW5jaWVzIiwiZGVwZW5kZW5jaWVzLWJhemVsIiwicWEvbm8tY29kZS1jaGFuZ2UiXX0=--> Co-authored-by: rdesgroppes <[email protected]> Co-authored-by: dd-octo-sts[bot] <200755185+dd-octo-sts[bot]@users.noreply.github.com> Co-authored-by: devflow.devflow-routing-intake <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.