Skip to content

Commit

Permalink
Update for setup.py
Browse files Browse the repository at this point in the history
Fixed issue using find_library() from ctypes.util.  At the moment,
this does work properly for macOS on Apple Silicon.
  • Loading branch information
EricEngle-NOAA committed Jan 16, 2024
1 parent 8977717 commit e83d9b8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
# find_library.
# ----------------------------------------------------------------------------------------
def find_library(name, dirs=None):
_libext_by_platform = {"linux": ".so", "darwin": ".dylib"}
out = []
sysinfo = (os.name, sys.platform)

# According to the ctypes documentation Mac and Windows ctypes_find_library
# returns the full path.
if sysinfo != ("posix", "linux"):
return ctypes_find_library(name)
#
# IMPORTANT: The following does not work at this time (Jan. 2024) for macOS on
# Apple Silicon.
if (os.name, sys.platform) != ("posix", "linux"):
if (sys.platform, platform.machine()) == ("darwin", "arm64"):
pass
else:
return ctypes_find_library(name)

# For Linux have to search ourselves.
libext = ".so"
# For Linux and macOS (Apple Silicon), we have to search ourselves.
libext = _libext_by_platform[sys.platform]
if dirs is None:
if os.environ.get("CONDA_PREFIX"):
dirs = [os.environ["CONDA_PREFIX"]]
Expand Down

0 comments on commit e83d9b8

Please sign in to comment.