Skip to content

fix: resolve editable installation issue for python package #1989

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

Merged
merged 1 commit into from
May 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ def bazel_build(self, ext: BazelExtension) -> None: # noqa: C901
pkgname = "google_benchmark"
pythonroot = Path("bindings") / "python" / "google_benchmark"
srcdir = temp_path / "bazel-bin" / pythonroot
libdir = Path(self.build_lib) / pkgname
if not self.inplace:
libdir = Path(self.build_lib) / pkgname
else:
build_py = self.get_finalized_command("build_py")
libdir = build_py.get_package_dir(pkgname)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested with self.inplace? This looks wrong, since get_package_dir returns a str, which would make the path concatenation in shutil.copyfile below fail, see https://github.com/pypa/setuptools/blob/main/setuptools/command/build_py.py#L275.

At minimum, I think this should be a Path(build_py.get_package_dir(pkgname)).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tested it and it works fp in libdir / fp is Path, and 'str / Path' results in Path

for root, dirs, files in os.walk(srcdir, topdown=True):
# exclude runfiles directories and children.
dirs[:] = [d for d in dirs if "runfiles" not in d]
Expand Down
Loading