Build libcdd.so and include it as a dependency
Change-Id: Idee6b1954d7354f71344572afe7397c08e8008e7
diff --git a/frc971/control_loops/python/libcdd.py b/frc971/control_loops/python/libcdd.py
index 8a0cba6..b46d908 100644
--- a/frc971/control_loops/python/libcdd.py
+++ b/frc971/control_loops/python/libcdd.py
@@ -5,6 +5,7 @@
__author__ = 'Austin Schuh (austin.linux@gmail.com)'
import ctypes
+import os
import sys
# Wrapper around PyFile_AsFile so that we can print out the error messages.
@@ -19,7 +20,15 @@
# manipulate half space and vertex representations of polytopes.
# Unfortunately, the library was compiled with C++ even though it has a lot of C
# code in it, so all the symbol names are mangled. Ug.
-libcdd = ctypes.cdll.LoadLibrary('libcdd.so')
+libcdd = None
+for path in os.environ.get('PYTHONPATH').split(':'):
+ try:
+ libcdd = ctypes.cdll.LoadLibrary(os.path.join(path, 'third_party/cddlib/_cddlib.so'))
+ except OSError, e:
+ pass
+
+assert libcdd is not None, 'Failed to find _cddlib.so'
+
libcdd.dd_set_global_constants()
# The variable type mytype that libcdd defines (double[1])