Skip to content
Snippets Groups Projects
Unverified Commit 17bceb72 authored by Jay Laura's avatar Jay Laura Committed by GitHub
Browse files

Merge pull request #124 from jlaura/libload

Updates how libusgscsm is found
parents 7f68f614 51722cb8
No related branches found
No related tags found
No related merge requests found
......@@ -35,8 +35,12 @@ release.
## Unreleased
### Added
- A check to `generate_ground_point` when a GeoDataset is used to raise a `ValueError` if the algorithm intersects a no data value in the passed DEM. This ensures that valid heights are used in the intersection computation. Fixes [#120](https://github.com/DOI-USGS/knoten/issues/120)
### Changed
- Removed all `pyproj` calls from csm.py, abstracting them into the reprojection and pyproj.Transformer code inside utils.py. Updated the transformations to use the new pipeline style syntax to avoid deprecation warnings about old syntax.
### Fixed
- Added a check to `generate_ground_point` when a GeoDataset is used to raise a `ValueError` if the algorithm intersects a no data value in the passed DEM. This ensures that valid heights are used in the intersection computation.
- The init method that searches for the libusgscsm to support searching in the `csmplugins` subdirectory. This approach depends on being able to find `csmapi` in a standard location and then assumes that the `libusgscsm` shared library is in a subdirectoy of that `lib` directory. Fixes [#118](https://github.com/DOI-USGS/knoten/issues/118)
......@@ -27,6 +27,6 @@ dependencies:
- scipy
- shapely
- sphinx
- usgscsm>=1.3.1
- usgscsm>=2
- pip:
- sphinx-material
import ctypes
from ctypes.util import find_library
from distutils import sysconfig
from glob import glob
import os
import sys
import warnings
from . import csm
from csmapi import csmapi
# Register the usgscam plugin with the csmapi
libusgscsm_path = find_library('usgscsm')
if not libusgscsm_path:
warnings.warn('libusgscsm not installed, unable to load shared library.')
libcsmapi_path = find_library('csmapi')
usgscsm_folder = os.path.join(os.path.split(libcsmapi_path)[0], "csmplugins")
libusgscsm_path = ""
if os.path.exists(usgscsm_folder):
# Supports py < 3.10, if only supporting 3.10+ use: glob( "*[0-9].[0-9].[0-9].dylib", root_dir=usgscsm_folder)
if sys.platform.startswith('darwin'):
results = glob(os.path.join(usgscsm_folder, "*[0-9].[0-9].[0-9].dylib"))
elif sys.platform.startswith('linux'):
results = glob(os.path.join(usgscsm_folder, "*.so"))
results.sort()
libusgscsm_path = os.path.join(usgscsm_folder, results[-1])
libusgscsm = ctypes.CDLL(libusgscsm_path)
if not os.path.exists(libusgscsm_path):
warnings.warn('libusgscsm not installed, unable to find shared library.')
if not libusgscsm._name:
warnings.warn('Unable to load usgscsm shared library')
try:
libusgscsm = ctypes.CDLL(libusgscsm_path)
except OSError:
warnings.warn(f'Unable to load usgscsm shared library at {libusgscsm_path}')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment