LIRC libraries
LinuxInfraredRemoteControl
paths.py
1 ''' Set up paths to components, including in-tree development. '''
2 
3 import glob
4 import sys
5 import os.path
6 
7 
8 HERE = os.path.abspath(os.path.dirname(__file__))
9 if HERE not in sys.path:
10  sys.path.insert(0, HERE)
11 
12 if os.path.exists(os.path.join(HERE, '_client.so')):
13  try:
14  os.unlink(os.path.join(HERE, '_client.so'))
15  except PermissionError:
16  pass
17 if os.path.exists(os.path.join(HERE, '..', 'lib', '.libs', '_client.so')):
18  if not os.path.exists(os.path.join(HERE, '_client.so')):
19  # development tree Makefile.am creates lib/libs/_client.so
20  # after 'make install'; plain 'make' isn't enough.
21  os.symlink(os.path.join('..', 'lib', '.libs', '_client.so'),
22  os.path.join(HERE, '_client.so'))
23 else:
24  # 'python setup.py' artifact:
25  SRC = glob.glob(os.path.join(
26  HERE, '..build/lib.linux*/_client.cpython*.so'))
27  if len(SRC) == 1:
28  os.symlink(os.path.join(SRC[0]), os.path.join(HERE, '_client.so'))