From fe23b81ce6f0f5cea1782bc94fefba128815e9d7 Mon Sep 17 00:00:00 2001 From: Vojta Tuma Date: Mon, 9 Dec 2024 15:45:59 +0100 Subject: [PATCH] Switch to rich binary wheels --- findlibs/__init__.py | 11 +++++++---- tests/transitive/modAlibs/{ => lib64}/libmodA.so | 0 tests/transitive/modBlibs/{ => lib64}/libmodB.so | 0 tests/transitive/test_transitive.py | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) rename tests/transitive/modAlibs/{ => lib64}/libmodA.so (100%) rename tests/transitive/modBlibs/{ => lib64}/libmodB.so (100%) diff --git a/findlibs/__init__.py b/findlibs/__init__.py index 1698ca8..abbe5d9 100644 --- a/findlibs/__init__.py +++ b/findlibs/__init__.py @@ -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""" @@ -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 @@ -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: diff --git a/tests/transitive/modAlibs/libmodA.so b/tests/transitive/modAlibs/lib64/libmodA.so similarity index 100% rename from tests/transitive/modAlibs/libmodA.so rename to tests/transitive/modAlibs/lib64/libmodA.so diff --git a/tests/transitive/modBlibs/libmodB.so b/tests/transitive/modBlibs/lib64/libmodB.so similarity index 100% rename from tests/transitive/modBlibs/libmodB.so rename to tests/transitive/modBlibs/lib64/libmodB.so diff --git a/tests/transitive/test_transitive.py b/tests/transitive/test_transitive.py index c386ed1..484488f 100644 --- a/tests/transitive/test_transitive.py +++ b/tests/transitive/test_transitive.py @@ -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}