Skip to content

Commit

Permalink
Add support for DESTDIR for python builds
Browse files Browse the repository at this point in the history
This fixes #545 when running `make DESTDIR=./some/folder install`. If
DESTDIR is set we will try to find the library in that path.

Signed-off-by: Travis F. Collins <[email protected]>
  • Loading branch information
tfcollins committed Jun 8, 2020
1 parent 3cc5382 commit 5c86f76
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bindings/python/setup.py.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ except:
long_description = description


def find_recursive(folder, filename):
import os

for root, dirs, files in os.walk(folder):
for file in files:
if file == filename:
return os.path.join(root, file)


class InstallWrapper(install):
"""Before installing we check if the
libiio library is actually installed"""
Expand All @@ -55,7 +64,15 @@ class InstallWrapper(install):
# Non-windows, possibly Posix system
_iiolib = "iio"
try:
_lib = _cdll(find_library(_iiolib), use_errno=True, use_last_error=True)
import os

destdir = os.getenv("DESTDIR", "")
if destdir:
destdir = os.path.join("${CMAKE_BINARY_DIR}", destdir)
out = find_recursive(destdir, "libiio.so")
_lib = _cdll(out, use_errno=True, use_last_error=True)
else:
_lib = _cdll(find_library(_iiolib), use_errno=True, use_last_error=True)
if not _lib._name:
raise OSError
except OSError:
Expand Down

0 comments on commit 5c86f76

Please sign in to comment.