Skip to content

Commit

Permalink
python: Rework bindings install
Browse files Browse the repository at this point in the history
Compute the full path to the library, otherwise install of the bindings
may fail as it cannot find the installed shared library on OSX.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Jul 14, 2023
1 parent 3d87084 commit a5d9a2a
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions bindings/python/setup.py.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,18 @@ class InstallWrapper(install):
from platform import system as _system
from ctypes import CDLL as _cdll
from ctypes.util import find_library
from os import getenv
from os.path import join

iiolib = "iio" if "Darwin" in _system() else "libiio${CMAKE_SHARED_LIBRARY_SUFFIX}"

destdir = getenv("DESTDIR", "") or ""
destdir = join("${CMAKE_INSTALL_FULL_LIBDIR}", destdir)
fulllibpath = find_recursive(destdir, iiolib)

if "Windows" in _system():
_iiolib = "libiio.dll"
else:
# Non-windows, possibly Posix system
_iiolib = "iio"
try:
import os

destdir = os.getenv("DESTDIR", "")
if destdir:
destdir = os.path.join("${CMAKE_BINARY_DIR}", destdir)
fulllibpath = find_recursive(destdir, "libiio.so")
_lib = _cdll(fulllibpath, use_errno=True, use_last_error=True)
else:
_lib = _cdll(find_library(_iiolib), use_errno=True, use_last_error=True)

_lib = _cdll(fulllibpath, use_errno=True, use_last_error=True)
if not _lib._name:
raise OSError
except OSError:
Expand Down

0 comments on commit a5d9a2a

Please sign in to comment.