From 6190e3d13ffec5b7435fd9e3d62a2a94a9d6fb9f Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 11:03:15 -0400 Subject: [PATCH 01/10] Revert "Fix compile error on Clang 18, tweak for better type generation" This reverts commit e3dd4e1704bc3a2cdcd3856adc151f38bdbd7407. --- gtsam/inference/Factor.h | 1 - python/CMakeLists.txt | 4 ++-- python/gtsam/gtsam.tpl | 6 +++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gtsam/inference/Factor.h b/gtsam/inference/Factor.h index f073c4975b..e357a9c88c 100644 --- a/gtsam/inference/Factor.h +++ b/gtsam/inference/Factor.h @@ -25,7 +25,6 @@ #include #endif #include -#include #include #include diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 674f17d3fd..404f5ecc0e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -257,7 +257,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var gtsam_unstable + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam_unstable DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_UNSTABLE_TARGET} WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" ) @@ -284,7 +284,7 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var gtsam + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_TARGET} WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" ) diff --git a/python/gtsam/gtsam.tpl b/python/gtsam/gtsam.tpl index 6876b4ab45..c72a216a29 100644 --- a/python/gtsam/gtsam.tpl +++ b/python/gtsam/gtsam.tpl @@ -39,12 +39,12 @@ namespace py = pybind11; {module_def} {{ m_.doc() = "pybind11 wrapper of {module_name}"; -// Specializations for STL classes -#include "python/gtsam/specializations/{module_name}.h" - {submodules_init} {wrapped_namespace} +// Specializations for STL classes +#include "python/gtsam/specializations/{module_name}.h" + }} From 92c7f51db53abeb27755e46fa0bd9a04013fb5d0 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 11:06:51 -0400 Subject: [PATCH 02/10] Revert "Use pybind11-stubgen for generating stubs" This reverts commit 30c789dbdb54bacc8ded04b557416a7911b01229. --- python/CMakeLists.txt | 49 +++++++++++-------------------------- python/dev_requirements.txt | 2 +- 2 files changed, 15 insertions(+), 36 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 404f5ecc0e..43f8d78bd4 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -171,7 +171,6 @@ file(COPY "${GTSAM_SOURCE_DIR}/examples/Data" DESTINATION "${GTSAM_MODULE_PATH}" # Add gtsam as a dependency to the install target set(GTSAM_PYTHON_DEPENDENCIES ${GTSAM_PYTHON_TARGET}) -set(GTSAM_PYTHON_INSTALL_EXTRA "") if(GTSAM_UNSTABLE_BUILD_PYTHON) set(ignore @@ -251,22 +250,6 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) VERBATIM ) endif() - - add_custom_target( - python-unstable-stubs - COMMAND - ${CMAKE_COMMAND} -E env - "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam_unstable - DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_UNSTABLE_TARGET} - WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" - ) - - if(NOT WIN32) - # Add the stubgen target as a dependency to the install target - list(APPEND GTSAM_PYTHON_INSTALL_EXTRA python-unstable-stubs) - endif() - # Custom make command to run all GTSAM_UNSTABLE Python tests add_custom_target( python-test-unstable @@ -279,30 +262,26 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) ) endif() -add_custom_target( - python-stubs - COMMAND - ${CMAKE_COMMAND} -E env - "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam - DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_TARGET} - WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" -) - -if(NOT WIN32) - # Add the stubgen target as a dependency to the install target - list(APPEND GTSAM_PYTHON_INSTALL_EXTRA python-stubs) -endif() - # Add custom target so we can install with `make python-install` # Note below we make sure to install with --user iff not in a virtualenv set(GTSAM_PYTHON_INSTALL_TARGET python-install) - -add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} +#TODO(Varun) Maybe move the long command to script? +# https://stackoverflow.com/questions/49053544/how-do-i-run-a-python-script-every-time-in-a-cmake-build +if (NOT WIN32) # WIN32=1 is target platform is Windows + add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} + COMMAND stubgen -q -p gtsam && cp -a out/gtsam/ gtsam && ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])" + DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} + WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY} + VERBATIM) +else() + #TODO(Varun) Find equivalent cp on Windows + add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} COMMAND ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])" - DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_INSTALL_EXTRA} + DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY} VERBATIM) +endif() + # Custom make command to run all GTSAM Python tests add_custom_target( diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt index 94ab40189c..6a5e7f9241 100644 --- a/python/dev_requirements.txt +++ b/python/dev_requirements.txt @@ -1,3 +1,3 @@ -r requirements.txt pyparsing>=2.4.2 -pybind11-stubgen>=2.5.1 \ No newline at end of file +mypy==1.4.1 #TODO(Varun) A bug in mypy>=1.5.0 causes an unresolved placeholder error when importing numpy>=2.0.0 (https://github.com/python/mypy/issues/17396) \ No newline at end of file From 798db544a4dc90e3b10610ee2ca1e5d3b8e661b5 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 11:08:00 -0400 Subject: [PATCH 03/10] keep include --- gtsam/inference/Factor.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gtsam/inference/Factor.h b/gtsam/inference/Factor.h index e357a9c88c..074151e166 100644 --- a/gtsam/inference/Factor.h +++ b/gtsam/inference/Factor.h @@ -24,12 +24,13 @@ #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION #include #endif -#include - -#include #include +#include #include +#include +#include + namespace gtsam { /// Define collection types: From 832ef7725bd2ce0aacd1b2e570614a77a5ec59cf Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 11:28:38 -0400 Subject: [PATCH 04/10] wrap TriangulationFactor --- gtsam/slam/slam.i | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/gtsam/slam/slam.i b/gtsam/slam/slam.i index f054aaab42..97dcfcae7b 100644 --- a/gtsam/slam/slam.i +++ b/gtsam/slam/slam.i @@ -347,11 +347,50 @@ virtual class FrobeniusBetweenFactor : gtsam::NoiseModelFactor { gtsam::Vector evaluateError(const T& R1, const T& R2); }; - + +#include +template +virtual class TriangulationFactor : gtsam::NoiseModelFactor { + TriangulationFactor(); + TriangulationFactor(const CAMERA& camera, const gtsam::This::Measurement& measured, + const gtsam::noiseModel::Base* model, gtsam::Key pointKey, + bool throwCheirality = false, + bool verboseCheirality = false); + + void print(const string& s = "", const gtsam::KeyFormatter& keyFormatter = + gtsam::DefaultKeyFormatter) const; + bool equals(const This& p, double tol = 1e-9) const; + + gtsam::Vector evaluateError(const gtsam::Point3& point) const; + + const gtsam::This::Measurement& measured() const; +}; +typedef gtsam::TriangulationFactor> + TriangulationFactorCal3_S2; +typedef gtsam::TriangulationFactor> + TriangulationFactorCal3DS2; +typedef gtsam::TriangulationFactor> + TriangulationFactorCal3Bundler; +typedef gtsam::TriangulationFactor> + TriangulationFactorCal3Fisheye; +typedef gtsam::TriangulationFactor> + TriangulationFactorCal3Unified; + +typedef gtsam::TriangulationFactor> + TriangulationFactorPoseCal3_S2; +typedef gtsam::TriangulationFactor> + TriangulationFactorPoseCal3DS2; +typedef gtsam::TriangulationFactor> + TriangulationFactorPoseCal3Bundler; +typedef gtsam::TriangulationFactor> + TriangulationFactorPoseCal3Fisheye; +typedef gtsam::TriangulationFactor> + TriangulationFactorPoseCal3Unified; + #include namespace lago { gtsam::Values initialize(const gtsam::NonlinearFactorGraph& graph, bool useOdometricPath = true); gtsam::Values initialize(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& initialGuess); } - + } // namespace gtsam From e2fba7a85cf4cbd9b652768becc495b4db0b1d00 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 11:28:54 -0400 Subject: [PATCH 05/10] expose Measurement type in TriangulationFactor --- gtsam/slam/TriangulationFactor.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gtsam/slam/TriangulationFactor.h b/gtsam/slam/TriangulationFactor.h index 32aa590a65..3b8486a594 100644 --- a/gtsam/slam/TriangulationFactor.h +++ b/gtsam/slam/TriangulationFactor.h @@ -34,6 +34,8 @@ class TriangulationFactor: public NoiseModelFactorN { /// CAMERA type using Camera = CAMERA; + /// shorthand for measurement type, e.g. Point2 or StereoPoint2 + using Measurement = typename CAMERA::Measurement; protected: @@ -43,9 +45,6 @@ class TriangulationFactor: public NoiseModelFactorN { /// shorthand for this class using This = TriangulationFactor; - /// shorthand for measurement type, e.g. Point2 or StereoPoint2 - using Measurement = typename CAMERA::Measurement; - // Keep a copy of measurement and calibration for I/O const CAMERA camera_; ///< CAMERA in which this landmark was seen const Measurement measured_; ///< 2D measurement From 569eeb9202c3e15be73857ac684956efea211f72 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 25 Sep 2024 16:45:06 -0400 Subject: [PATCH 06/10] update Config.cmake.in to conditionally include Boost --- cmake/Config.cmake.in | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index 36906d090d..338ff85004 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -15,10 +15,12 @@ endif() # Find dependencies, required by cmake exported targets: include(CMakeFindDependencyMacro) # Allow using cmake < 3.8 -if(${CMAKE_VERSION} VERSION_LESS "3.8.0") -find_package(Boost @BOOST_FIND_MINIMUM_VERSION@ COMPONENTS @BOOST_FIND_MINIMUM_COMPONENTS@) -else() -find_dependency(Boost @BOOST_FIND_MINIMUM_VERSION@ COMPONENTS @BOOST_FIND_MINIMUM_COMPONENTS@) +if (@GTSAM_ENABLE_BOOST_SERIALIZATION@ OR @GTSAM_USE_BOOST_FEATURES@) + if(${CMAKE_VERSION} VERSION_LESS "3.8.0") + find_package(Boost @BOOST_FIND_MINIMUM_VERSION@ COMPONENTS @BOOST_FIND_MINIMUM_COMPONENTS@) + else() + find_dependency(Boost @BOOST_FIND_MINIMUM_VERSION@ COMPONENTS @BOOST_FIND_MINIMUM_COMPONENTS@) + endif() endif() if(@GTSAM_USE_TBB@) From e023360843362eb8df83c786835c0207737501e4 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 11:50:58 -0400 Subject: [PATCH 07/10] Revert "Revert "Use pybind11-stubgen for generating stubs"" This reverts commit 92c7f51db53abeb27755e46fa0bd9a04013fb5d0. --- python/CMakeLists.txt | 49 ++++++++++++++++++++++++++----------- python/dev_requirements.txt | 2 +- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 43f8d78bd4..404f5ecc0e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -171,6 +171,7 @@ file(COPY "${GTSAM_SOURCE_DIR}/examples/Data" DESTINATION "${GTSAM_MODULE_PATH}" # Add gtsam as a dependency to the install target set(GTSAM_PYTHON_DEPENDENCIES ${GTSAM_PYTHON_TARGET}) +set(GTSAM_PYTHON_INSTALL_EXTRA "") if(GTSAM_UNSTABLE_BUILD_PYTHON) set(ignore @@ -250,6 +251,22 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) VERBATIM ) endif() + + add_custom_target( + python-unstable-stubs + COMMAND + ${CMAKE_COMMAND} -E env + "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam_unstable + DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_UNSTABLE_TARGET} + WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" + ) + + if(NOT WIN32) + # Add the stubgen target as a dependency to the install target + list(APPEND GTSAM_PYTHON_INSTALL_EXTRA python-unstable-stubs) + endif() + # Custom make command to run all GTSAM_UNSTABLE Python tests add_custom_target( python-test-unstable @@ -262,26 +279,30 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) ) endif() +add_custom_target( + python-stubs + COMMAND + ${CMAKE_COMMAND} -E env + "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam + DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_TARGET} + WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" +) + +if(NOT WIN32) + # Add the stubgen target as a dependency to the install target + list(APPEND GTSAM_PYTHON_INSTALL_EXTRA python-stubs) +endif() + # Add custom target so we can install with `make python-install` # Note below we make sure to install with --user iff not in a virtualenv set(GTSAM_PYTHON_INSTALL_TARGET python-install) -#TODO(Varun) Maybe move the long command to script? -# https://stackoverflow.com/questions/49053544/how-do-i-run-a-python-script-every-time-in-a-cmake-build -if (NOT WIN32) # WIN32=1 is target platform is Windows - add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} - COMMAND stubgen -q -p gtsam && cp -a out/gtsam/ gtsam && ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])" - DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} - WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY} - VERBATIM) -else() - #TODO(Varun) Find equivalent cp on Windows - add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} + +add_custom_target(${GTSAM_PYTHON_INSTALL_TARGET} COMMAND ${PYTHON_EXECUTABLE} -c "import sys, subprocess; cmd = [sys.executable, '-m', 'pip', 'install']; has_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); cmd.append('--user' if not has_venv else ''); cmd.append('.'); subprocess.check_call([c for c in cmd if c])" - DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} + DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_INSTALL_EXTRA} WORKING_DIRECTORY ${GTSAM_PYTHON_BUILD_DIRECTORY} VERBATIM) -endif() - # Custom make command to run all GTSAM Python tests add_custom_target( diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt index 6a5e7f9241..94ab40189c 100644 --- a/python/dev_requirements.txt +++ b/python/dev_requirements.txt @@ -1,3 +1,3 @@ -r requirements.txt pyparsing>=2.4.2 -mypy==1.4.1 #TODO(Varun) A bug in mypy>=1.5.0 causes an unresolved placeholder error when importing numpy>=2.0.0 (https://github.com/python/mypy/issues/17396) \ No newline at end of file +pybind11-stubgen>=2.5.1 \ No newline at end of file From e36fa332f2752ae14f825831721d7037fd49f7bc Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 11:51:41 -0400 Subject: [PATCH 08/10] Revert "Revert "Fix compile error on Clang 18, tweak for better type generation"" This reverts commit 6190e3d13ffec5b7435fd9e3d62a2a94a9d6fb9f. --- python/CMakeLists.txt | 4 ++-- python/gtsam/gtsam.tpl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 404f5ecc0e..674f17d3fd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -257,7 +257,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam_unstable + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var gtsam_unstable DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_UNSTABLE_TARGET} WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" ) @@ -284,7 +284,7 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" gtsam + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var gtsam DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_TARGET} WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" ) diff --git a/python/gtsam/gtsam.tpl b/python/gtsam/gtsam.tpl index c72a216a29..6876b4ab45 100644 --- a/python/gtsam/gtsam.tpl +++ b/python/gtsam/gtsam.tpl @@ -39,12 +39,12 @@ namespace py = pybind11; {module_def} {{ m_.doc() = "pybind11 wrapper of {module_name}"; +// Specializations for STL classes +#include "python/gtsam/specializations/{module_name}.h" + {submodules_init} {wrapped_namespace} -// Specializations for STL classes -#include "python/gtsam/specializations/{module_name}.h" - }} From 580dcb27f4cca11fd0708783d5a1b5e7b78141d0 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 12:12:26 -0400 Subject: [PATCH 09/10] ignore errors in stub generation --- python/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 674f17d3fd..5012189249 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -257,7 +257,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var gtsam_unstable + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var --ignore-all-errors gtsam_unstable DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_UNSTABLE_TARGET} WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" ) @@ -284,7 +284,7 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=${GTSAM_PYTHON_BUILD_DIRECTORY}/$ENV{PYTHONPATH}" - pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var gtsam + pybind11-stubgen -o . --enum-class-locations \"KernelFunctionType|NoiseFormat:gtsam.gtsam\" --enum-class-locations \"OrderingType:gtsam.gtsam.Ordering\" --numpy-array-use-type-var --ignore-all-errors gtsam DEPENDS ${GTSAM_PYTHON_DEPENDENCIES} ${GTSAM_PYTHON_TEST_FILES} ${GTSAM_PYTHON_TARGET} WORKING_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/" ) From e3e83cd2fb64db36a9e87b895e5e842da547ca60 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Fri, 27 Sep 2024 13:43:43 -0400 Subject: [PATCH 10/10] use User-Agent as Other --- .github/workflows/build-python.yml | 7 ++++++- .github/workflows/build-windows.yml | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 57b4435aff..f581a5974f 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -138,7 +138,12 @@ jobs: # Use the prebuilt binary for Windows $Url = "https://sourceforge.net/projects/boost/files/boost-binaries/$env:BOOST_VERSION/$env:BOOST_EXE-${{matrix.platform}}.exe" - (New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost.exe") + + # Create WebClient with appropriate settings and download Boost exe + $wc = New-Object System.Net.Webclient + $wc.Headers.Add("User-Agent: Other"); + $wc.DownloadFile($Url, "$env:TEMP\boost.exe") + Start-Process -Wait -FilePath "$env:TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=$BOOST_PATH" # Set the BOOST_ROOT variable diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 1bda7e40ac..20b4a846f9 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -70,9 +70,6 @@ jobs: } if ("${{ matrix.compiler }}" -eq "gcc") { - # Chocolatey GCC is broken on the windows-2019 image. - # See: https://github.com/DaanDeMeyer/doctest/runs/231595515 - # See: https://github.community/t5/GitHub-Actions/Something-is-wrong-with-the-chocolatey-installed-version-of-gcc/td-p/32413 scoop install gcc --global echo "CC=gcc" >> $GITHUB_ENV echo "CXX=g++" >> $GITHUB_ENV @@ -98,7 +95,12 @@ jobs: # Use the prebuilt binary for Windows $Url = "https://sourceforge.net/projects/boost/files/boost-binaries/$env:BOOST_VERSION/$env:BOOST_EXE-${{matrix.platform}}.exe" - (New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost.exe") + + # Create WebClient with appropriate settings and download Boost exe + $wc = New-Object System.Net.Webclient + $wc.Headers.Add("User-Agent: Other"); + $wc.DownloadFile($Url, "$env:TEMP\boost.exe") + Start-Process -Wait -FilePath "$env:TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=$BOOST_PATH" # Set the BOOST_ROOT variable