Fix Windows Bazel test failures for //data/... and //python/...#1086
Merged
Fix Windows Bazel test failures for //data/... and //python/...#1086
Conversation
Two issues prevented tests from passing on Windows:
1. ConfigDictValidationTest (//data/config): `Runfiles::Rlocation()` on a
directory path returns an empty string in Windows manifest-only mode
(RUNFILES_MANIFEST_ONLY=1). Fixed by looking up a known file within the
directory and deriving the directory via find_last_of("/\\").
2. Python extension (//python/tests): `pybind_extension` on Windows outputs
`opencc_clib.pyd.dll`, but Python's import machinery only loads `.pyd`
files. Fixed by adding a genrule in `src/pyd/` that copies the `.pyd.dll`
to `opencc_clib.pyd`, and using `select()` in `py_opencc` to point at the
renamed file on Windows (with `imports = ["pyd"]`) and the original target
on other platforms.
Also update rules_python to 1.9.0 to match the version resolved by bzlmod
(suppresses the version mismatch warning).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two test targets were failing on Windows under Bazel:
1.
//data/config:config_dict_validation_testError:
hk2s.json not found or not accessibleCause:
Runfiles::Rlocation()on a bare directory path (e.g._main/data/config) returns an empty string on Windows in manifest-only mode (RUNFILES_MANIFEST_ONLY=1). Only file paths have entries in the runfiles manifest.Fix: Look up a known file inside the directory and derive the directory path via
find_last_of("/\\"):2.
//python/tests:test_openccError:
ModuleNotFoundError: No module named 'opencc_clib'Cause: On Windows,
pybind_extensionoutputsopencc_clib.pyd.dll(Bazel appends.dllto all shared libraries). Python's import machinery on Windows only loads.pydfiles, so the module cannot be found even though it's onsys.path.Fix: Add a genrule in
src/pyd/that copiesopencc_clib.pyd.dll→opencc_clib.pyd, and useselect()inpy_openccto use the renamed file on Windows (withimports = ["pyd"]) and the originalpybind_extensionoutput on other platforms.3. Suppress bzlmod version warning
Update
rules_pythonfrom0.40.0to1.9.0to match the version resolved by bzlmod, suppressing the startup warning.Test plan
bazel test //data/config:config_dict_validation_testpasses on Windowsbazel test //python/tests:test_openccpasses on Windowsselect()falls through to the original targets)🤖 Generated with Claude Code