From 19ee0ac4c2b552f6358f33a86970c079f8293df5 Mon Sep 17 00:00:00 2001 From: Bas Couwenberg Date: Tue, 17 Oct 2023 22:25:31 +0200 Subject: [PATCH] Fix test failure with built library (#291) --- rtree/finder.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rtree/finder.py b/rtree/finder.py index cf8c6ad8..10899bca 100644 --- a/rtree/finder.py +++ b/rtree/finder.py @@ -81,14 +81,15 @@ def load() -> ctypes.CDLL: # add path for binary wheel prepared with cibuildwheel/auditwheel try: pkg_files = importlib.metadata.files("rtree") - for file in pkg_files: # type: ignore - if ( - file.parent.name == "Rtree.libs" - and file.stem.startswith("libspatialindex") - and ".so" in file.suffixes - ): - _candidates.insert(1, os.path.join(str(file.locate()))) - break + if pkg_files is not None: + for file in pkg_files: # type: ignore + if ( + file.parent.name == "Rtree.libs" + and file.stem.startswith("libspatialindex") + and ".so" in file.suffixes + ): + _candidates.insert(1, os.path.join(str(file.locate()))) + break except importlib.metadata.PackageNotFoundError: pass