Skip to content

Commit

Permalink
Merge pull request #89 from BBN-Q/fix/python-path
Browse files Browse the repository at this point in the history
Fixing OS specific path issue.
  • Loading branch information
matthewware authored Dec 14, 2017
2 parents 7452b77 + 0ba1e6e commit 8182294
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/python/aps2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,25 @@
np_uint16_1D = npct.ndpointer(dtype=np.uint16, ndim=1, flags='CONTIGUOUS')
np_uint8_1D = npct.ndpointer(dtype=np.uint8, ndim=1, flags='CONTIGUOUS')

# determine OS
if os.name == 'nt': # windows
suffix = '\\Library\\bin'
elif os.name == 'posix':
suffix = '/lib'
else:
suffix = ''

# load the shared library
# try with and without "lib" prefix
libpath = find_library("aps2")
if libpath is None:
libpath = find_library("libaps2")
# if we still can't find it, then look in python prefix (where conda stores binaries)
if libpath is None:
libpath = sys.prefix + '/lib'
libpath = sys.prefix + suffix
libaps2 = npct.load_library("libaps2", libpath)
else:
libpath = sys.prefix + suffix

This comment has been minimized.

Copy link
@dieris

dieris Jan 6, 2018

Collaborator

@matthewware I don't think you want this here. If the library was found (either aps2 or libaps2) it already has the full file name in the path. Or am I missing some case?

This comment has been minimized.

Copy link
@matthewware

matthewware Jan 7, 2018

Author Collaborator

This was a conda issue with the file structures having a different layout depending on the OS. If I remember when I was testing, you needed to do this to load the library otherwise it couldn't find it. Let me do some more testing later today or tomorrow.

libaps2 = CDLL(libpath)

libaps2.get_device_IPs.argtypes = [POINTER(c_char_p)]
Expand Down

0 comments on commit 8182294

Please sign in to comment.