Skip to content

Commit

Permalink
Switch to rich binary wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
tmi committed Dec 9, 2024
1 parent 0c26e72 commit fe23b81
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions findlibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
win32=".dll",
)

binary_module_name = lambda s: f"{s}libs"


def _single_preload_deps(path: str) -> None:
"""See _find_in_package"""
Expand All @@ -45,11 +47,12 @@ def _transitive_preload_deps(module: ModuleType) -> None:
if hasattr(module, "findlibs_dependencies"):
for module_name in module.findlibs_dependencies:
try:
rec_into = importlib.import_module(module_name)
ext_path = str(Path(rec_into.__file__).parent)
rec_into = importlib.import_module(binary_module_name(module_name))
# NOTE we need *first* to evaluate recursive call, *then* preload,
# to ensure that dependencies are already in place
_transitive_preload_deps(rec_into)

ext_path = str(Path(rec_into.__file__).parent / "lib64")
_single_preload_deps(ext_path)
except ImportError:
# NOTE we don't use ImportWarning here as thats off by default
Expand All @@ -72,10 +75,10 @@ def _find_in_package(
It would be tempting to just extend LD_LIBRARY_PATH -- alas, that won't have any
effect as the linker has been configured already by the time cpython is running"""
try:
module = importlib.import_module(pkg_name + "libs")
module = importlib.import_module(binary_module_name(pkg_name))
if preload_deps:
_transitive_preload_deps(module)
venv_wheel_lib = str((Path(module.__file__).parent / lib_name))
venv_wheel_lib = str((Path(module.__file__).parent / "lib64" / lib_name))
if os.path.exists(venv_wheel_lib):
return venv_wheel_lib
except ImportError:
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/transitive/test_transitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def libload_accumulator(path: str):

# test
found = findlibs.find("modA")
expected_found = str(Path(__file__).parent / "modAlibs" / "libmodA.so")
expected_found = str(Path(__file__).parent / "modAlibs" / "lib64" / "libmodA.so")
assert found == expected_found

expected_dylib = str(Path(__file__).parent / "modBlibs" / "libmodB.so")
expected_dylib = str(Path(__file__).parent / "modBlibs" / "lib64" / "libmodB.so")
assert loaded_libs == {expected_dylib}

0 comments on commit fe23b81

Please sign in to comment.