Commit 4486aaf174859c90cdc76c45bcefc49cd871fe8b

Authored by Austin Blanton
1 parent 62f9e899

Check for both .so and .dylib in provided lib location

Showing 1 changed file with 11 additions and 3 deletions
scripts/brpy/__init__.py
1 1 from ctypes import *
  2 +import os
2 3  
3 4 def _string_args(n):
4 5 s = []
... ... @@ -11,16 +12,23 @@ def _var_string_args(n):
11 12 s.extend(_string_args(n))
12 13 return s
13 14  
14   -def init_brpy(br_loc='/usr/local/lib/libopenbr.dylib'):
  15 +def init_brpy(br_loc='/usr/local/lib'):
15 16 """Takes the ctypes lib object for br and initializes all function inputs and outputs"""
16   - br = cdll.LoadLibrary(br_loc)
17   - plot_args = _var_string_args(1) + [c_bool]
  17 + br_loc += '/libopenbr.%s'
  18 + if os.path.exists(br_loc % 'dylib'):
  19 + br = cdll.LoadLibrary(br_loc % 'dylib')
  20 + elif os.path.exists(br_loc % 'so'):
  21 + br = cdll.LoadLibrary(br_loc % 'so')
  22 + else:
  23 + raise ValueError('Neither .so nor .dylib libopenbr found in %s' % br_loc)
18 24  
  25 + plot_args = _var_string_args(1) + [c_bool]
19 26 br.br_about.restype = c_char_p
20 27 br.br_cat.argtypes = _var_string_args(1)
21 28 br.br_cluster.argtypes = [c_int, POINTER(c_char_p), c_float, c_char_p]
22 29 br.br_combine_masks.argtypes = _var_string_args(2)
23 30 br.br_compare.argtypes = _string_args(3)
  31 + br.br_compare_n.argtypes = [c_int, POINTER(c_char_p)] + _string_args(2)
24 32 br.br_pairwise_compare.argtypes = _string_args(3)
25 33 br.br_convert.argtypes = _string_args(3)
26 34 br.br_enroll.argtypes = _string_args(2)
... ...