Skip to content

Commit 6747309

Browse files
nicholasjngdmah42
andauthored
python: Assert that libdir is a Path in all branches (#1992)
The `inplace=True` branch previously relied on some non-trivial interactions between `str` and `pathlib.Path` objects, which produces unexpected values in cases of `s / p`, where `s` is a string and `p` is an absolute path. To fix, just create a `pathlib.Path` of the return value of `build_py.get_package_dir()`. Co-authored-by: dominic <[email protected]>
1 parent f402ffd commit 6747309

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def bazel_build(self, ext: BazelExtension) -> None: # noqa: C901
135135
libdir = Path(self.build_lib) / pkgname
136136
else:
137137
build_py = self.get_finalized_command("build_py")
138-
libdir = build_py.get_package_dir(pkgname)
138+
libdir = Path(build_py.get_package_dir(pkgname))
139+
139140
for root, dirs, files in os.walk(srcdir, topdown=True):
140141
# exclude runfiles directories and children.
141142
dirs[:] = [d for d in dirs if "runfiles" not in d]

0 commit comments

Comments
 (0)