diff --git a/.github/scripts/python.sh b/.github/scripts/python.sh index c72e9abd6..08b8084a0 100644 --- a/.github/scripts/python.sh +++ b/.github/scripts/python.sh @@ -39,8 +39,6 @@ function install_dependencies() if [ "${GTSAM_WITH_TBB:-OFF}" == "ON" ]; then install_tbb fi - - $PYTHON -m pip install -r $GITHUB_WORKSPACE/python/requirements.txt } function build() diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index 480c791dc..91bc4e80a 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -109,10 +109,13 @@ jobs: with: swap-size-gb: 6 - - name: Install Dependencies + - name: Install System Dependencies run: | bash .github/scripts/python.sh -d + - name: Install Python Dependencies + run: python$PYTHON_VERSION -m pip install -r python/dev_requirements.txt + - name: Build run: | bash .github/scripts/python.sh -b diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index a1d232b2a..f0568394f 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -150,7 +150,10 @@ jobs: # cmake --build build -j4 --config ${{ matrix.build_type }} --target check.dynamics_unstable # Compile. Fail with exception # cmake --build build -j4 --config ${{ matrix.build_type }} --target check.nonlinear_unstable - # Compilation error + # Compile. Fail with exception # cmake --build build -j4 --config ${{ matrix.build_type }} --target check.slam_unstable - # Compilation error + # Compile. Fail with exception # cmake --build build -j4 --config ${{ matrix.build_type }} --target check.partition + + # Run all tests + # cmake --build build -j1 --config ${{ matrix.build_type }} --target check diff --git a/CMakeLists.txt b/CMakeLists.txt index 309cc7c4e..63c7f9e54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,5 @@ cmake_minimum_required(VERSION 3.0) -# new feature to Cmake Version > 2.8.12 -# Mac ONLY. Define Relative Path on Mac OS -if(NOT DEFINED CMAKE_MACOSX_RPATH) - set(CMAKE_MACOSX_RPATH 0) -endif() - # Set the version number for the library set (GTSAM_VERSION_MAJOR 4) set (GTSAM_VERSION_MINOR 3) diff --git a/INSTALL.md b/INSTALL.md index f148e3718..10bee196c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -182,7 +182,7 @@ Here are some tips to get the best possible performance out of GTSAM. optimization by 30-50%. Please note that this may not be true for very small problems where the overhead of dispatching work to multiple threads outweighs the benefit. We recommend that you benchmark your problem with/without TBB. -3. Add `-march=native` to `GTSAM_CMAKE_CXX_FLAGS`. A performance gain of +3. Use `GTSAM_BUILD_WITH_MARCH_NATIVE`. A performance gain of 25-30% can be expected on modern processors. Note that this affects the portability of your executable. It may not run when copied to another system with older/different processor architecture. diff --git a/docker/ubuntu-gtsam-python/Dockerfile b/docker/ubuntu-gtsam-python/Dockerfile index 85eed4d4e..4a7c4b37f 100644 --- a/docker/ubuntu-gtsam-python/Dockerfile +++ b/docker/ubuntu-gtsam-python/Dockerfile @@ -6,9 +6,6 @@ FROM borglab/ubuntu-gtsam:bionic # Install pip RUN apt-get install -y python3-pip python3-dev -# Install python wrapper requirements -RUN python3 -m pip install -U -r /usr/src/gtsam/python/requirements.txt - # Run cmake again, now with python toolbox on WORKDIR /usr/src/gtsam/build RUN cmake \ diff --git a/gtsam/base/serialization.h b/gtsam/base/serialization.h index e615afe83..18612bc22 100644 --- a/gtsam/base/serialization.h +++ b/gtsam/base/serialization.h @@ -17,6 +17,7 @@ * @date Feb 7, 2012 */ +#ifdef GTSAM_ENABLE_BOOST_SERIALIZATION #pragma once #include @@ -270,3 +271,4 @@ void deserializeBinary(const std::string& serialized, T& output, ///@} } // namespace gtsam +#endif diff --git a/gtsam/discrete/AlgebraicDecisionTree.h b/gtsam/discrete/AlgebraicDecisionTree.h index 20ab4bd68..9f55f3b63 100644 --- a/gtsam/discrete/AlgebraicDecisionTree.h +++ b/gtsam/discrete/AlgebraicDecisionTree.h @@ -36,7 +36,7 @@ namespace gtsam { * @ingroup discrete */ template - class GTSAM_EXPORT AlgebraicDecisionTree : public DecisionTree { + class AlgebraicDecisionTree : public DecisionTree { /** * @brief Default method used by `labelFormatter` or `valueFormatter` when * printing. diff --git a/gtsam/linear/SubgraphBuilder.h b/gtsam/linear/SubgraphBuilder.h index aafba9306..f9ddd4c9a 100644 --- a/gtsam/linear/SubgraphBuilder.h +++ b/gtsam/linear/SubgraphBuilder.h @@ -182,7 +182,7 @@ GaussianFactorGraph buildFactorSubgraph(const GaussianFactorGraph &gfg, /** Split the graph into a subgraph and the remaining edges. * Note that the remaining factorgraph has null factors. */ -std::pair splitFactorGraph( +std::pair GTSAM_EXPORT splitFactorGraph( const GaussianFactorGraph &factorGraph, const Subgraph &subgraph); } // namespace gtsam diff --git a/gtsam/nonlinear/NonlinearFactor.h b/gtsam/nonlinear/NonlinearFactor.h index 57c4a00eb..725117748 100644 --- a/gtsam/nonlinear/NonlinearFactor.h +++ b/gtsam/nonlinear/NonlinearFactor.h @@ -46,7 +46,7 @@ namespace gtsam { * Had to use the static_cast of a nullptr, because the compiler is not able to * deduce the type of the nullptr when expanding the evaluateError templates. */ -#define OptionalNone static_cast(nullptr) +#define OptionalNone static_cast(nullptr) /** This typedef will be used everywhere boost::optional reference was used * previously. This is used to indicate that the Jacobian is optional. In the future diff --git a/gtsam/sfm/TranslationRecovery.h b/gtsam/sfm/TranslationRecovery.h index 44a5ef43e..4848d7cfa 100644 --- a/gtsam/sfm/TranslationRecovery.h +++ b/gtsam/sfm/TranslationRecovery.h @@ -48,7 +48,7 @@ namespace gtsam { // where s is an arbitrary scale that can be supplied, default 1.0. Hence, two // versions are supplied below corresponding to whether we have initial values // or not. -class TranslationRecovery { +class GTSAM_EXPORT TranslationRecovery { public: using KeyPair = std::pair; using TranslationEdges = std::vector>; diff --git a/gtsam_unstable/geometry/Event.h b/gtsam_unstable/geometry/Event.h index a4055d038..a3c907646 100644 --- a/gtsam_unstable/geometry/Event.h +++ b/gtsam_unstable/geometry/Event.h @@ -34,7 +34,7 @@ namespace gtsam { * SLAM, where we have "time of arrival" measurements at a set of sensors. The * TOA functor below provides a measurement function for those applications. */ -class Event { +class GTSAM_UNSTABLE_EXPORT Event { double time_; ///< Time event was generated Point3 location_; ///< Location at time event was generated @@ -62,10 +62,10 @@ class Event { } /** print with optional string */ - GTSAM_UNSTABLE_EXPORT void print(const std::string& s = "") const; + void print(const std::string& s = "") const; /** equals with an tolerance */ - GTSAM_UNSTABLE_EXPORT bool equals(const Event& other, + bool equals(const Event& other, double tol = 1e-9) const; /// Updates a with tangent space delta diff --git a/gtsam_unstable/partition/GenericGraph.h b/gtsam_unstable/partition/GenericGraph.h index bcfd77336..a7f2c1ea3 100644 --- a/gtsam_unstable/partition/GenericGraph.h +++ b/gtsam_unstable/partition/GenericGraph.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "PartitionWorkSpace.h" @@ -49,7 +50,7 @@ namespace gtsam { namespace partition { typedef std::vector GenericGraph2D; /** merge nodes in DSF using constraints captured by the given graph */ - std::list > findIslands(const GenericGraph2D& graph, const std::vector& keys, WorkSpace& workspace, + std::list > GTSAM_UNSTABLE_EXPORT findIslands(const GenericGraph2D& graph, const std::vector& keys, WorkSpace& workspace, const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark); /** eliminate the sensors from generic graph */ @@ -97,11 +98,11 @@ namespace gtsam { namespace partition { typedef std::vector GenericGraph3D; /** merge nodes in DSF using constraints captured by the given graph */ - std::list > findIslands(const GenericGraph3D& graph, const std::vector& keys, WorkSpace& workspace, + std::list > GTSAM_UNSTABLE_EXPORT findIslands(const GenericGraph3D& graph, const std::vector& keys, WorkSpace& workspace, const size_t minNrConstraintsPerCamera, const size_t minNrConstraintsPerLandmark); /** eliminate the sensors from generic graph */ - void reduceGenericGraph(const GenericGraph3D& graph, const std::vector& cameraKeys, const std::vector& landmarkKeys, + void GTSAM_UNSTABLE_EXPORT reduceGenericGraph(const GenericGraph3D& graph, const std::vector& cameraKeys, const std::vector& landmarkKeys, const std::vector& dictionary, GenericGraph3D& reducedGraph); /** check whether the 3D graph is singular (under constrained) */ diff --git a/gtsam_unstable/partition/tests/CMakeLists.txt b/gtsam_unstable/partition/tests/CMakeLists.txt index 0b918e497..4ca6b9186 100644 --- a/gtsam_unstable/partition/tests/CMakeLists.txt +++ b/gtsam_unstable/partition/tests/CMakeLists.txt @@ -1,6 +1,6 @@ set(ignore_test "testNestedDissection.cpp") -if (NOT GTSAM_USE_BOOST_FEATURES) +if (NOT GTSAM_USE_BOOST_FEATURES OR MSVC) list(APPEND ignore_test "testFindSeparator.cpp") endif() diff --git a/gtsam_unstable/slam/ProjectionFactorPPPC.h b/gtsam_unstable/slam/ProjectionFactorPPPC.h index 5b6a83a33..df63330df 100644 --- a/gtsam_unstable/slam/ProjectionFactorPPPC.h +++ b/gtsam_unstable/slam/ProjectionFactorPPPC.h @@ -32,7 +32,7 @@ namespace gtsam { * @ingroup slam */ template -class GTSAM_UNSTABLE_EXPORT ProjectionFactorPPPC +class ProjectionFactorPPPC : public NoiseModelFactorN { protected: Point2 measured_; ///< 2D measurement diff --git a/gtsam_unstable/slam/SmartProjectionPoseFactorRollingShutter.h b/gtsam_unstable/slam/SmartProjectionPoseFactorRollingShutter.h index 4af0be751..4a2047ee1 100644 --- a/gtsam_unstable/slam/SmartProjectionPoseFactorRollingShutter.h +++ b/gtsam_unstable/slam/SmartProjectionPoseFactorRollingShutter.h @@ -42,7 +42,7 @@ namespace gtsam { * @ingroup slam */ template -class GTSAM_UNSTABLE_EXPORT SmartProjectionPoseFactorRollingShutter +class SmartProjectionPoseFactorRollingShutter : public SmartProjectionFactor { private: typedef SmartProjectionFactor Base; diff --git a/gtsam_unstable/slam/tests/testSmartStereoProjectionPoseFactor.cpp b/gtsam_unstable/slam/tests/testSmartStereoProjectionPoseFactor.cpp index 1eceb8061..872cd2dea 100644 --- a/gtsam_unstable/slam/tests/testSmartStereoProjectionPoseFactor.cpp +++ b/gtsam_unstable/slam/tests/testSmartStereoProjectionPoseFactor.cpp @@ -1441,14 +1441,14 @@ TEST( SmartStereoProjectionPoseFactor, HessianWithRotationNonDegenerate ) { std::shared_ptr hessianFactorRotTran = smartFactor->linearize(tranValues); - // Hessian is invariant to rotations and translations in the degenerate case - EXPECT( - assert_equal(hessianFactor->information(), + double error; #ifdef GTSAM_USE_EIGEN_MKL - hessianFactorRotTran->information(), 1e-5)); + error = 1e-5; #else - hessianFactorRotTran->information(), 1e-6)); + error = 1e-6; #endif + // Hessian is invariant to rotations and translations in the degenerate case + EXPECT(assert_equal(hessianFactor->information(), hessianFactorRotTran->information(), error)); } /* ************************************************************************* */ diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 2b2abf507..f874c2f21 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,3 +1,4 @@ +set(PROJECT_PYTHON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/python) set(GTSAM_PYTHON_BUILD_DIRECTORY ${PROJECT_BINARY_DIR}/python) if (NOT GTSAM_BUILD_PYTHON) @@ -6,11 +7,11 @@ endif() # Generate setup.py. file(READ "${PROJECT_SOURCE_DIR}/README.md" README_CONTENTS) -configure_file(${PROJECT_SOURCE_DIR}/python/setup.py.in +configure_file(${PROJECT_PYTHON_SOURCE_DIR}/setup.py.in ${GTSAM_PYTHON_BUILD_DIRECTORY}/setup.py) # Supply MANIFEST.in for older versions of Python -file(COPY ${PROJECT_SOURCE_DIR}/python/MANIFEST.in +file(COPY ${PROJECT_PYTHON_SOURCE_DIR}/MANIFEST.in DESTINATION ${GTSAM_PYTHON_BUILD_DIRECTORY}) set(WRAP_BUILD_TYPE_POSTFIXES ${GTSAM_BUILD_TYPE_POSTFIXES}) @@ -99,7 +100,7 @@ pybind_wrap(${GTSAM_PYTHON_TARGET} # target "gtsam" # module_name "gtsam" # top_namespace "${ignore}" # ignore_classes - ${PROJECT_SOURCE_DIR}/python/gtsam/gtsam.tpl + ${PROJECT_PYTHON_SOURCE_DIR}/gtsam/gtsam.tpl gtsam # libs "gtsam;gtsam_header" # dependencies ${GTSAM_ENABLE_BOOST_SERIALIZATION} # use_boost_serialization @@ -178,7 +179,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) "gtsam_unstable" # module_name "gtsam" # top_namespace "${ignore}" # ignore_classes - ${PROJECT_SOURCE_DIR}/python/gtsam_unstable/gtsam_unstable.tpl + ${PROJECT_PYTHON_SOURCE_DIR}/gtsam_unstable/gtsam_unstable.tpl gtsam_unstable # libs "gtsam_unstable;gtsam_unstable_header" # dependencies ${GTSAM_ENABLE_BOOST_SERIALIZATION} # use_boost_serialization diff --git a/python/README.md b/python/README.md index 278d62094..e81be74fc 100644 --- a/python/README.md +++ b/python/README.md @@ -16,7 +16,7 @@ For instructions on updating the version of the [wrap library](https://github.co - This wrapper needs `pyparsing(>=2.4.2)`, and `numpy(>=1.11.0)`. These can be installed as follows: ```bash - pip install -r /python/requirements.txt + pip install -r /python/dev_requirements.txt ``` ## Install diff --git a/python/dev_requirements.txt b/python/dev_requirements.txt new file mode 100644 index 000000000..6970ee613 --- /dev/null +++ b/python/dev_requirements.txt @@ -0,0 +1,2 @@ +-r requirements.txt +pyparsing>=2.4.2 \ No newline at end of file diff --git a/python/requirements.txt b/python/requirements.txt index 481d27d8e..099cc80d6 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -1,2 +1 @@ numpy>=1.11.0 -pyparsing>=2.4.2 diff --git a/python/setup.py.in b/python/setup.py.in index 9aa4b71f4..e15e39075 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -1,19 +1,17 @@ """Setup file to install the GTSAM package.""" -try: - from setuptools import setup, find_packages -except ImportError: - from distutils.core import setup, find_packages +from setuptools import setup, find_namespace_packages -packages = find_packages(where=".") +packages = find_namespace_packages( + where=".", + exclude=('build', 'build.*', 'CMakeFiles', 'CMakeFiles.*', + 'gtsam.notebooks', '*.preamble', '*.specializations', 'dist')) print("PACKAGES: ", packages) package_data = { '': [ "./*.so", - "./*.dll", - "Data/*" # Add the data files to the package - "Data/**/*" # Add the data files in subdirectories + "./*.dll" ] } @@ -41,7 +39,6 @@ setup( 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', ], packages=packages,