Skip to content

Commit 5281261

Browse files
jpwoodbuaignas
andauthored
fix: normalize stub_path in repl.bzl (bazel-contrib#3104)
When a REPL target is run from an external Bazel module, the `stub_path` can have path components in it (e.g. "/..") which get rejected by the `Rlocation()` function in `runfiles.py` for not being normalized. This commit normalizes the path before it's passed to `Rlocation()`. Fixes bazel-contrib#3101 --------- Co-authored-by: Ignas Anikevicius <[email protected]>
1 parent aa60229 commit 5281261

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ END_UNRELEASED_TEMPLATE
9393
([#3099](https://github.com/bazel-contrib/rules_python/issues/3099)).
9494
* (pypi) Expose pypi packages only common to all Python versions in `all_requirements`
9595
([#2921](https://github.com/bazel-contrib/rules_python/issues/2921)).
96+
* (repl) Normalize the path for the `REPL` stub to make it possible to use the
97+
default stub template from outside `rules_python` ({gh-issue}`3101`).
9698

9799
{#v0-0-0-added}
98100
### Added

python/private/repl_template.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
from python.runfiles import runfiles
77

8-
STUB_PATH = "%stub_path%"
8+
# runfiles.py will reject paths which aren't normalized, which can happen when the REPL rules are
9+
# used from a remote module.
10+
STUB_PATH = os.path.normpath("%stub_path%")
911

1012

1113
def start_repl():

0 commit comments

Comments
 (0)