-
Notifications
You must be signed in to change notification settings - Fork 7
Update dependency rules_python to v1.8.4 #1731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+120
−6
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| From c61f3cc8251abef63646587630203a024a1bd575 Mon Sep 17 00:00:00 2001 | ||
| From: Joel Sing <jsing@canva.com> | ||
| Date: Mon, 14 Jul 2025 14:15:41 +1000 | ||
| Subject: [PATCH 1/5] fix(runfiles): correct Python runfiles path assumption | ||
|
|
||
| The current _FindPythonRunfilesRoot() implementation assumes that | ||
| the Python module has been unpacked four levels below the runfiles | ||
| directory. This is not the case in multiple situations, for example when | ||
| rules_pycross is in use and has installed the module via pypi (in which | ||
| case it is five levels below runfiles). | ||
|
|
||
| Both strategies already know where the runfiles directory exists - | ||
| implement _GetRunfilesDir() on the _DirectoryBased strategy, then call | ||
| _GetRunfilesDir() in order to populate self._python_runfiles_dir. | ||
|
|
||
| Stop passing a bogus path to runfiles.Create() in testCurrentRepository(), | ||
| such that the test actually uses the appropriate runfiles path. | ||
|
|
||
| Fixes #3085 | ||
| --- | ||
| CHANGELOG.md | 4 ++++ | ||
| python/runfiles/runfiles.py | 17 ++++------------- | ||
| tests/runfiles/runfiles_test.py | 2 +- | ||
| 3 files changed, 9 insertions(+), 14 deletions(-) | ||
|
|
||
| diff --git a/python/runfiles/runfiles.py b/python/runfiles/runfiles.py | ||
| index fc794272c9..bfa9d0d053 100644 | ||
| --- b/python/runfiles/runfiles.py | ||
| +++ a/python/runfiles/runfiles.py | ||
| @@ -229,9 +229,6 @@ | ||
| # runfiles strategy on those platforms. | ||
| return posixpath.join(self._runfiles_root, path) | ||
|
|
||
| - def _GetRunfilesDir(self) -> str: | ||
| - return self._runfiles_root | ||
| - | ||
| def EnvVars(self) -> Dict[str, str]: | ||
| return { | ||
| "RUNFILES_DIR": self._runfiles_root, | ||
| @@ -249,7 +246,7 @@ | ||
|
|
||
| def __init__(self, strategy: Union[_ManifestBased, _DirectoryBased]) -> None: | ||
| self._strategy = strategy | ||
| - self._python_runfiles_root = strategy._GetRunfilesDir() | ||
| + self._python_runfiles_root = _FindPythonRunfilesRoot() | ||
| self._repo_mapping = _RepositoryMapping.create_from_file( | ||
| strategy.RlocationChecked("_repo_mapping") | ||
| ) | ||
| @@ -472,6 +469,18 @@ | ||
| _Runfiles = Runfiles | ||
|
|
||
|
|
||
| +def _FindPythonRunfilesRoot() -> str: | ||
| + """Finds the root of the Python runfiles tree.""" | ||
| + root = __file__ | ||
| + # Walk up our own runfiles path to the root of the runfiles tree from which | ||
| + # the current file is being run. This path coincides with what the Bazel | ||
| + # Python stub sets up as sys.path[0]. Since that entry can be changed at | ||
| + # runtime, we rederive it here. | ||
| + for _ in range("rules_python/python/runfiles/runfiles.py".count("/") + 1): | ||
| + root = os.path.dirname(root) | ||
| + return root | ||
| + | ||
| + | ||
| def CreateManifestBased(manifest_path: str) -> Runfiles: | ||
| return Runfiles.CreateManifestBased(manifest_path) | ||
|
|
||
| From d86b9e943b1cd2db4387843c1b72531301ea5fc1 Mon Sep 17 00:00:00 2001 | ||
| From: Joel Sing <jsing@canva.com> | ||
| Date: Thu, 23 Oct 2025 13:29:45 +1100 | ||
| Subject: [PATCH 2/5] Add test that ensures we can correctly locate and open a | ||
| data file. | ||
|
|
||
| --- | ||
| tests/runfiles/BUILD.bazel | 3 +++ | ||
| tests/runfiles/runfiles_test.py | 10 ++++++++++ | ||
| 2 files changed, 13 insertions(+) | ||
|
|
||
| From d63226877520b20a0aa4dd10f040a316975f7773 Mon Sep 17 00:00:00 2001 | ||
| From: Joel Sing <jsing@canva.com> | ||
| Date: Thu, 23 Oct 2025 13:30:08 +1100 | ||
| Subject: [PATCH 3/5] Add workaround for buggy zip file bootstrap. | ||
|
|
||
| --- | ||
| .../runtime_env_toolchain/toolchain_runs_test.py | 16 +++++++++++++--- | ||
| 1 file changed, 13 insertions(+), 3 deletions(-) | ||
|
|
||
| From 6166d66a3672648fd9178d2031c9030922b2026e Mon Sep 17 00:00:00 2001 | ||
| From: Ignas Anikevicius <240938+aignas@users.noreply.github.com> | ||
| Date: Wed, 5 Nov 2025 17:47:58 +0900 | ||
| Subject: [PATCH 4/5] doc: move changelog to the unreleased section. | ||
|
|
||
| --- | ||
| CHANGELOG.md | 8 ++++---- | ||
| 1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
|
||
| From 7e48c4e89f233ef43f15b993ceafc12e90ae0e40 Mon Sep 17 00:00:00 2001 | ||
| From: Joel Sing <jsing@canva.com> | ||
| Date: Thu, 6 Nov 2025 14:15:02 +1100 | ||
| Subject: [PATCH 5/5] Appease mypy | ||
|
|
||
| --- | ||
| tests/runfiles/runfiles_test.py | 6 ++++-- | ||
| 1 file changed, 4 insertions(+), 2 deletions(-) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.