From 9385e4937c017a3e7d5a7e9006e46cf45fb04204 Mon Sep 17 00:00:00 2001 From: James Lamb Date: Fri, 6 Sep 2024 07:51:50 -0500 Subject: [PATCH] re-enable mixing libcuspatial wheels with libcudf conda packages (#1456) Fixes #1455 devcontainer conda CI jobs are failing in this project because of the following mix of characteristics for thoes jobs: * all build and runtime dependencies for `libcuspatial`, `cuspatial`, `cuproj` are installed via conda * `libcuspatial`, `cuspatial`, and `cuproj` wheels are then built with `pip install -e --no-deps --no-build-isolation` * `import libcuspatial` results in unconditionally running `import libcudf` * `libcudf` is provided by the `libcudf` **conda** package, which does not have any Python modules, so that import fails This fixes that, and restores the ability to mix a `pip install`'d `cuspatial` / `cuproj` with a `conda`-installed `libcudf`. ## Notes for Reviewers ### How did CI not catch this before? When https://github.com/rapidsai/devcontainers/pull/387 was merged, I only re-ran the **pip** devcontainers CI job on #1450. # Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cuspatial/pull/1456 --- python/libcuspatial/libcuspatial/load.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/python/libcuspatial/libcuspatial/load.py b/python/libcuspatial/libcuspatial/load.py index 285628187..7842de9a0 100644 --- a/python/libcuspatial/libcuspatial/load.py +++ b/python/libcuspatial/libcuspatial/load.py @@ -16,13 +16,22 @@ import ctypes import os -import libcudf - def load_library(): - # libcudf must be loaded before libcuspatial because libcuspatial - # references its symbols - libcudf.load_library() + try: + # libcudf must be loaded before libcuspatial because libcuspatial + # references its symbols + import libcudf + libcudf.load_library() + except ModuleNotFoundError: + # 'libcuspatial' has a runtime dependency on 'libcudf'. However, + # that dependency might be satisfied by the 'libcudf' conda package + # (which does not have any Python modules), instead of the + # 'libcudf' wheel. + # + # In that situation, assume that 'libcudf.so' is in a place where + # the loader can find it. + pass # Dynamically load libcuspatial.so. Prefer a system library if one is # present to avoid clobbering symbols that other packages might expect,