Skip to content

Commit 0fc481a

Browse files
committed
[DEBUG] Add some more debug options
Signed-off-by: Cristian Le <[email protected]>
1 parent a6219cd commit 0fc481a

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

src/scikit_build_core/repair_wheel/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ def get_wheel_repairer(
206206
wheel_dirs=wheel_dirs,
207207
)
208208

209+
logger.debug(
210+
"wheel_dirs[platlib] = {platlib}\n"
211+
"sysconfig.get_path(platlib) = {sysconfig_path}\n"
212+
"install_dir = {install_dir}\n",
213+
platlib=wheel_dirs["platlib"],
214+
sysconfig_path=sysconfig.get_path("platlib"),
215+
install_dir=install_dir,
216+
)
209217
WheelRepairer.initialize()
210218
if not (
211219
repairer_cls := WheelRepairer._platform_repairers.get(platform.system())

src/scikit_build_core/repair_wheel/linux.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,23 @@ def patch_linux_library_rpath(self, artifact: Path, rpaths: list[str]) -> None:
4848
final_rpaths.add(rpath_str)
4949
continue
5050
# Otherwise change the RPATH to point use $ORIGIN
51+
logger.debug(
52+
"Patch path from patch_linux_library_rpath: "
53+
"rpath={rpath}, artifact={artifact}",
54+
rpath=rpath_path,
55+
artifact=artifact,
56+
)
5157
new_rpath = self.path_relative_site_packages(rpath_path, artifact.parent)
5258
new_rpath_str = f"$ORIGIN/{new_rpath}"
5359
final_rpaths.add(new_rpath_str)
5460
# Merge with all the rpaths we were given
5561
final_rpaths = final_rpaths.union(rpaths)
5662
patcher = Patchelf()
63+
logger.debug(
64+
"Setting RPATH for {artifact} to: {rpath}",
65+
artifact=artifact,
66+
rpath=final_rpaths,
67+
)
5768
patcher.set_rpath(artifact, ":".join(final_rpaths))
5869

5970
def get_dependency_rpaths(self, target: Target, install_path: Path) -> list[str]:
@@ -64,6 +75,12 @@ def get_dependency_rpaths(self, target: Target, install_path: Path) -> list[str]
6475
dep_install_paths = self.get_wheel_install_paths(dep_target)
6576
assert len(dep_install_paths) == 1
6677
dep_install_path = self.install_dir / next(iter(dep_install_paths))
78+
logger.debug(
79+
"Patch path from get_dependency_rpaths: "
80+
"dep_install_path={dep_install_path}, target_path={target_path}",
81+
dep_install_path=dep_install_path,
82+
target_path=target_path,
83+
)
6784
rpath = self.path_relative_site_packages(dep_install_path, target_path)
6885
new_rpath_str = f"$ORIGIN/{rpath}"
6986
rpaths.append(new_rpath_str)
@@ -106,6 +123,13 @@ def get_package_rpaths(self, target: Target, install_path: Path) -> list[str]:
106123
# Skip empty rpaths. Most likely will have on at the end
107124
continue
108125
rpath = Path(rpath_str)
126+
logger.debug(
127+
"Patch path from get_package_rpaths (1): "
128+
"rpath={rpath}, install_path={install_path}, is_in_site={is_in_site}",
129+
rpath=rpath,
130+
install_path=install_path,
131+
is_in_site=self.path_is_in_site_packages(rpath),
132+
)
109133
if not self.path_is_in_site_packages(rpath):
110134
# Skip any paths that cannot be handled. We do not check for paths in
111135
# the build directory, it should be covered by `get_dependency_rpaths`
@@ -118,16 +142,24 @@ def get_package_rpaths(self, target: Target, install_path: Path) -> list[str]:
118142
try:
119143
# TODO: how to best catch if a string is a valid path?
120144
rpath = Path(link_command.fragment)
145+
logger.debug(
146+
"Patch path from get_package_rpaths (2): "
147+
"rpath={rpath}, install_path={install_path}, is_in_site={is_in_site}",
148+
rpath=rpath,
149+
install_path=install_path,
150+
is_in_site=self.path_is_in_site_packages(rpath),
151+
)
121152
if not rpath.is_absolute():
122153
# Relative paths should be handled by `get_dependency_rpaths`
123154
continue
124155
rpath = self.path_relative_site_packages(rpath, install_path)
125156
new_rpath_str = f"$ORIGIN/{rpath.parent}"
126157
rpaths.append(new_rpath_str)
127-
except Exception:
158+
except Exception as exc:
128159
logger.warning(
129-
"Could not parse link-library as a path: {fragment}",
160+
"Could not parse link-library as a path: {fragment}\nexc = {exc}",
130161
fragment=link_command.fragment,
162+
exc=exc,
131163
)
132164
continue
133165
return rpaths

tests/test_repair_wheel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def test_full_build(isolated, isolate, manual_repair, monkeypatch):
3535
isolated.install("delvewheel")
3636
isolated.install("./extern", isolated=isolate)
3737

38-
isolated.install("-v", "./extern", ".", isolated=isolate)
38+
isolated.install(
39+
"-v", "--config-settings=logging.level=DEBUG", "./extern", ".", isolated=isolate
40+
)
3941

4042
isolated.run("main")
4143
isolated.module("repair_wheel")

0 commit comments

Comments
 (0)