diff --git a/cython/CMakeLists.txt b/cython/CMakeLists.txt index 7ea8cd05b..165291246 100644 --- a/cython/CMakeLists.txt +++ b/cython/CMakeLists.txt @@ -4,8 +4,8 @@ include(GtsamCythonWrap) # Create the cython toolbox for the gtsam library if (GTSAM_INSTALL_CYTHON_TOOLBOX) # build and include the eigency version of eigency - add_subdirectory(clonedEigency) - include_directories(${PROJECT_BINARY_DIR}/cython/clonedEigency) + add_subdirectory(gtsam_eigency) + include_directories(${PROJECT_BINARY_DIR}/cython/gtsam_eigency) # wrap gtsam add_custom_target(gtsam_header DEPENDS "../gtsam.h") diff --git a/cython/README.md b/cython/README.md index 9eef6ca9e..2b1fa28d1 100644 --- a/cython/README.md +++ b/cython/README.md @@ -9,7 +9,7 @@ INSTALL ``` - For compatiblity with gtsam's Eigen version, it contains its own cloned version of [Eigency](https://github.com/wouterboomsma/eigency.git), -named **clonedEigency**, to interface between C++'s Eigen and Python's numpy. +named **gtsam_eigency**, to interface between C++'s Eigen and Python's numpy. - Build and install gtsam using cmake with GTSAM_INSTALL_CYTHON_TOOLBOX enabled. The wrapped module will be installed to GTSAM_CYTHON_INSTALL_PATH, which is @@ -71,8 +71,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${GTSAM_DIR}/../GTSAMCMakeTools") # Wrap include(GtsamCythonWrap) -find_package(clonedEigency REQUIRED) -include_directories(${CLONEDEIGENCY_INCLUDE_DIRS}) +include_directories(${GTSAM_EIGENCY_INSTALL_PATH}) wrap_and_install_library_cython("your_project_interface.h" "from gtsam.gtsam cimport *" # extra import of gtsam/gtsam.pxd Cython header "your_install_path" diff --git a/cython/clonedEigency/CMakeLists.txt b/cython/gtsam_eigency/CMakeLists.txt similarity index 61% rename from cython/clonedEigency/CMakeLists.txt rename to cython/gtsam_eigency/CMakeLists.txt index 92dcb9d31..1214d505c 100644 --- a/cython/clonedEigency/CMakeLists.txt +++ b/cython/gtsam_eigency/CMakeLists.txt @@ -4,23 +4,23 @@ include(GtsamCythonWrap) # so that the cython-generated header "conversions_api.h" can be found when cythonizing eigency's core # and eigency's cython pxd headers can be found when cythonizing gtsam file(COPY "." DESTINATION ".") -set(OUTPUT_DIR "${PROJECT_BINARY_DIR}/cython/clonedEigency") +set(OUTPUT_DIR "${PROJECT_BINARY_DIR}/cython/gtsam_eigency") set(EIGENCY_INCLUDE_DIR ${OUTPUT_DIR}) -# This is to make the build/cython/clonedEigency folder a python package -configure_file(__init__.py.in ${PROJECT_BINARY_DIR}/cython/clonedEigency/__init__.py) +# This is to make the build/cython/gtsam_eigency folder a python package +configure_file(__init__.py.in ${PROJECT_BINARY_DIR}/cython/gtsam_eigency/__init__.py) # include eigency headers include_directories(${EIGENCY_INCLUDE_DIR}) # Cythonize and build eigency message(STATUS "Cythonize and build eigency") -# Important trick: use "../clonedEigency/conversions.pyx" to let cython know that the conversions module is -# a part of the clonedEigency package and generate the function call import_clonedEigency__conversions() +# Important trick: use "../gtsam_eigency/conversions.pyx" to let cython know that the conversions module is +# a part of the gtsam_eigency package and generate the function call import_gtsam_igency__conversions() # in conversions_api.h correctly!!! -cythonize(cythonize_eigency_conversions "../clonedEigency/conversions.pyx" "conversions" +cythonize(cythonize_eigency_conversions "../gtsam_eigency/conversions.pyx" "conversions" "${OUTPUT_DIR}" "${EIGENCY_INCLUDE_DIR}" "" "") -cythonize(cythonize_eigency_core "../clonedEigency/core.pyx" "core" +cythonize(cythonize_eigency_core "../gtsam_eigency/core.pyx" "core" ${OUTPUT_DIR} "${EIGENCY_INCLUDE_DIR}" "" "") add_dependencies(cythonize_eigency_core cythonize_eigency_conversions) add_custom_target(cythonize_eigency) @@ -29,6 +29,6 @@ add_dependencies(cythonize_eigency cythonize_eigency_conversions cythonize_eigen # install install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}) install(TARGETS cythonize_eigency_core cythonize_eigency_conversions - DESTINATION "${GTSAM_CYTHON_INSTALL_PATH}/clonedEigency") -install(FILES "${OUTPUT_DIR}/conversions_api.h" DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}/clonedEigency) -configure_file(__init__.py.in ${GTSAM_CYTHON_INSTALL_PATH}/clonedEigency/__init__.py) + DESTINATION "${GTSAM_CYTHON_INSTALL_PATH}/gtsam_eigency") +install(FILES "${OUTPUT_DIR}/conversions_api.h" DESTINATION ${GTSAM_CYTHON_INSTALL_PATH}/gtsam_eigency) +configure_file(__init__.py.in ${GTSAM_CYTHON_INSTALL_PATH}/gtsam_eigency/__init__.py) diff --git a/cython/clonedEigency/LICENSE.txt b/cython/gtsam_eigency/LICENSE.txt similarity index 100% rename from cython/clonedEigency/LICENSE.txt rename to cython/gtsam_eigency/LICENSE.txt diff --git a/cython/clonedEigency/__init__.py.in b/cython/gtsam_eigency/__init__.py.in similarity index 100% rename from cython/clonedEigency/__init__.py.in rename to cython/gtsam_eigency/__init__.py.in diff --git a/cython/clonedEigency/conversions.pxd b/cython/gtsam_eigency/conversions.pxd similarity index 100% rename from cython/clonedEigency/conversions.pxd rename to cython/gtsam_eigency/conversions.pxd diff --git a/cython/clonedEigency/conversions.pyx b/cython/gtsam_eigency/conversions.pyx similarity index 100% rename from cython/clonedEigency/conversions.pyx rename to cython/gtsam_eigency/conversions.pyx diff --git a/cython/clonedEigency/core.pxd b/cython/gtsam_eigency/core.pxd similarity index 100% rename from cython/clonedEigency/core.pxd rename to cython/gtsam_eigency/core.pxd diff --git a/cython/clonedEigency/core.pyx b/cython/gtsam_eigency/core.pyx similarity index 100% rename from cython/clonedEigency/core.pyx rename to cython/gtsam_eigency/core.pyx diff --git a/cython/clonedEigency/eigency_cpp.h b/cython/gtsam_eigency/eigency_cpp.h similarity index 97% rename from cython/clonedEigency/eigency_cpp.h rename to cython/gtsam_eigency/eigency_cpp.h index 4eae69869..45ac6caaa 100644 --- a/cython/clonedEigency/eigency_cpp.h +++ b/cython/gtsam_eigency/eigency_cpp.h @@ -215,7 +215,7 @@ inline PyArrayObject *_ndarray_copy >(const std::complex inline PyArrayObject *ndarray(Eigen::PlainObjectBase &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor); } // If C++11 is available, check if m is an r-value reference, in @@ -223,56 +223,56 @@ inline PyArrayObject *ndarray(Eigen::PlainObjectBase &m) { #if __cplusplus >= 201103L template inline PyArrayObject *ndarray(Eigen::PlainObjectBase &&m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor); } #endif template inline PyArrayObject *ndarray(const Eigen::PlainObjectBase &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor); } template inline PyArrayObject *ndarray_view(Eigen::PlainObjectBase &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor); } template inline PyArrayObject *ndarray_view(const Eigen::PlainObjectBase &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_view(const_cast(m.data()), m.rows(), m.cols(), m.IsRowMajor); } template inline PyArrayObject *ndarray_copy(const Eigen::PlainObjectBase &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor); } template inline PyArrayObject *ndarray(Eigen::Map &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride()); } template inline PyArrayObject *ndarray(const Eigen::Map &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); // Since this is a map, we assume that ownership is correctly taken care // of, and we avoid taking a copy return _ndarray_view(const_cast(m.data()), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride()); } template inline PyArrayObject *ndarray_view(Eigen::Map &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_view(m.data(), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride()); } template inline PyArrayObject *ndarray_view(const Eigen::Map &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_view(const_cast(m.data()), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride()); } template inline PyArrayObject *ndarray_copy(const Eigen::Map &m) { - import_clonedEigency__conversions(); + import_gtsam_eigency__conversions(); return _ndarray_copy(m.data(), m.rows(), m.cols(), m.IsRowMajor, m.outerStride(), m.innerStride()); } diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 28b96b253..0c019303b 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -334,7 +334,7 @@ void Module::generate_cython_wrapper(const string& toolboxPath, const std::strin /* ************************************************************************* */ void Module::emit_cython_pxd(FileWriter& pxdFile) const { // headers - pxdFile.oss << "from clonedEigency.core cimport *\n" + pxdFile.oss << "from gtsam_eigency.core cimport *\n" "from libcpp.string cimport string\n" "from libcpp.vector cimport vector\n" "from libcpp.pair cimport pair\n" @@ -416,7 +416,7 @@ void Module::emit_cython_pyx(FileWriter& pyxFile) const { for(const Qualified& q: Qualified::BasicTypedefs) { pyxFile.oss << "from " << pxdHeader << " cimport " << q.pxdClassName() << "\n"; } - pyxFile.oss << "from clonedEigency.core cimport *\n" + pyxFile.oss << "from gtsam_eigency.core cimport *\n" "from libcpp cimport bool\n\n" "from libcpp.pair cimport pair\n" "from libcpp.string cimport string\n" diff --git a/wrap/tests/expected-cython/geometry.pxd b/wrap/tests/expected-cython/geometry.pxd index b4d36c91a..a48182701 100644 --- a/wrap/tests/expected-cython/geometry.pxd +++ b/wrap/tests/expected-cython/geometry.pxd @@ -1,5 +1,5 @@ -from clonedEigency.core cimport * +from gtsam_eigency.core cimport * from libcpp.string cimport string from libcpp.vector cimport vector from libcpp.pair cimport pair diff --git a/wrap/tests/expected-cython/geometry.pyx b/wrap/tests/expected-cython/geometry.pyx index 838f96aaa..18aa521e7 100644 --- a/wrap/tests/expected-cython/geometry.pyx +++ b/wrap/tests/expected-cython/geometry.pyx @@ -4,7 +4,7 @@ cimport geometry from geometry cimport shared_ptr from geometry cimport dynamic_pointer_cast from geometry cimport make_shared -from clonedEigency.core cimport * +from gtsam_eigency.core cimport * from libcpp cimport bool from libcpp.pair cimport pair