From 6ccdaafffe45d7bc5bddcd215b827ec256ca3db9 Mon Sep 17 00:00:00 2001 From: Yifan Yu Date: Tue, 21 Jan 2025 11:25:48 +0100 Subject: [PATCH 1/3] Fix non-editable install does not include .so file --- CMakeLists.txt | 2 -- setup.py | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 47a65b3..9698cba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,6 @@ if(${CERES_VERSION} VERSION_LESS "2.2.0") add_definitions("-DCERES_PARAMETERIZATION_ENABLED") endif() -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/madpose) - add_subdirectory(ext/pybind11) include_directories( diff --git a/setup.py b/setup.py index da0a005..4c1e438 100644 --- a/setup.py +++ b/setup.py @@ -119,6 +119,9 @@ def build_extension(self, ext: CMakeExtension) -> None: description="""Solvers and estimators described in the paper "Relative Pose Estimation through Affine Corrections of Monocular Depth Priors".""", long_description="", packages=find_packages(), + package_data={ + "madpose": ["*.so"], # Include .so files in the madpose package + }, ext_modules=[CMakeExtension("madpose")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, From 87f02e8c00074d96ad626ee293d0a92c8cc25be6 Mon Sep 17 00:00:00 2001 From: Yifan Yu Date: Wed, 22 Jan 2025 05:24:36 +0100 Subject: [PATCH 2/3] Change output directory of .so in setup.py --- setup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 4c1e438..bcfca92 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ def build_extension(self, ext: CMakeExtension) -> None: # EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code # from Python. cmake_args = [ - f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}", + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}{ext.name}", f"-DPYTHON_EXECUTABLE={sys.executable}", f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm ] @@ -119,9 +119,6 @@ def build_extension(self, ext: CMakeExtension) -> None: description="""Solvers and estimators described in the paper "Relative Pose Estimation through Affine Corrections of Monocular Depth Priors".""", long_description="", packages=find_packages(), - package_data={ - "madpose": ["*.so"], # Include .so files in the madpose package - }, ext_modules=[CMakeExtension("madpose")], cmdclass={"build_ext": CMakeBuild}, zip_safe=False, From ae1560c464778b203b6b1adfb1c4b3f0d266712a Mon Sep 17 00:00:00 2001 From: Yifan Yu Date: Wed, 22 Jan 2025 05:25:21 +0100 Subject: [PATCH 3/3] Add post-build step in CMake to fix import in root folder --- src/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bef7b6f..23958d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,4 +19,9 @@ target_link_libraries(madpose PRIVATE PoseLib::PoseLib Ceres::ceres ${OpenCV_LIBS} -) \ No newline at end of file +) + +add_custom_command(TARGET madpose POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ ${CMAKE_SOURCE_DIR}/madpose + COMMENT "Copying madpose library to ${CMAKE_SOURCE_DIR}/madpose" +)