fix and re-enable EKF pytests

This commit is contained in:
Daniel Agar
2018-05-03 22:25:36 -04:00
parent 4dabf7a1a8
commit 3a61035ac2
21 changed files with 413 additions and 182 deletions
+40
View File
@@ -0,0 +1,40 @@
# Use Python 3.5
set(Python_ADDITIONAL_VERSIONS 3.5)
find_package(PythonLibs 3 REQUIRED)
find_package(PythonInterp 3 REQUIRED)
include_directories(${PYTHON_INCLUDE_PATH})
# Find numpy include
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())" OUTPUT_VARIABLE NUMPY_INCLUDE_DIRS ERROR_QUIET)
include_directories(${NUMPY_INCLUDE_DIRS})
set(CMAKE_SWIG_FLAGS "")
set_source_files_properties(../ecl_EKF.i PROPERTIES CPLUSPLUS ON)
include_directories(../..)
# Add swig module
swig_add_module(ecl_EKF python ../ecl_EKF.i)
swig_link_libraries(ecl_EKF ecl_EKF ${PYTHON_LIBRARIES})
# Files to install with Python
set(PYTHON_INSTALL_FILES
${CMAKE_CURRENT_BINARY_DIR}/ecl_EKF.py
${CMAKE_CURRENT_BINARY_DIR}/_ecl_EKF.so
)
# Configure setup.py and copy to output directory
set(SETUP_PY_IN ${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in)
set(SETUP_PY_OUT ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
configure_file(${SETUP_PY_IN} ${SETUP_PY_OUT})
# Declare install target for python
#install(TARGETS swig_example
# COMMAND "${PYTHON_EXECUTABLE} setup.py"
# COMPONENT swig-python)
# Install target to call setup.py
add_custom_target(install-python
DEPENDS _ecl_EKF
COMMAND python ${SETUP_PY_OUT} install
)
+35
View File
@@ -0,0 +1,35 @@
import setuptools.command.install
import shutil
from distutils.sysconfig import get_python_lib
class CompiledLibInstall(setuptools.command.install.install):
"""
Specialized install to install to python libs
"""
def run(self):
"""
Run method called by setup
:return:
"""
# Get filenames from CMake variable
filenames = '${PYTHON_INSTALL_FILES}'.split(';')
# Directory to install to
install_dir = get_python_lib()
# Install files
[shutil.copy(filename, install_dir) for filename in filenames]
if __name__ == '__main__':
setuptools.setup(
name='ecl_EKF',
version='1.0.0-dev',
packages=['ecl_EKF'],
license='BSD 3.0',
author='PX4',
author_email='px4@px4.io',
cmdclass={'install': CompiledLibInstall}
)
+3
View File
@@ -0,0 +1,3 @@
import swig_example
swig_example.swig_example_hello()
swig_example.link_liba_hello()