diff --git a/rtree/finder.py b/rtree/finder.py index f852e813..e03d2127 100644 --- a/rtree/finder.py +++ b/rtree/finder.py @@ -143,7 +143,7 @@ def get_include() -> str: if pkg_files is not None: for path in pkg_files: # type: ignore if path.name == "SpatialIndex.h": - return str(path.parent.parent) + return str(Path(path.locate()).parent.parent) except importlib.metadata.PackageNotFoundError: pass diff --git a/setup.py b/setup.py index db474146..a1fc40d9 100755 --- a/setup.py +++ b/setup.py @@ -56,15 +56,12 @@ def finalize_options(self) -> None: else: raise ValueError(f"unhandled platform {sys.platform!r}") + target_lib.mkdir(parents=True, exist_ok=True) for pth in source_lib.glob(lib_pattern): # if the source isn't a file skip it if not pth.is_file(): continue - # make directory if it doesn't exist yet - if not target_lib.is_dir(): - target_lib.mkdir(parents=True) - # copy the source file to the target directory self.copy_file(str(pth), str(target_lib / pth.name)) @@ -73,14 +70,11 @@ def finalize_options(self) -> None: if source_include.is_dir(): for pth in source_include.rglob("*.h"): rpth = pth.relative_to(source_include) - target_subdir = target_include / rpth - - # make directory if it doesn't exist yet - if not target_subdir.is_dir(): - target_subdir.mkdir(parents=True) # copy the source file to the target directory - self.copy_file(str(pth), str(target_include / rpth)) + target_subdir = target_include / rpth.parent + target_subdir.mkdir(parents=True, exist_ok=True) + self.copy_file(str(pth), str(target_subdir)) # See pyproject.toml for other project metadata