mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 00:23:33 +08:00
fix and re-enable EKF pytests
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -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}
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
import swig_example
|
||||
swig_example.swig_example_hello()
|
||||
swig_example.link_liba_hello()
|
||||
Reference in New Issue
Block a user