Skip to content

Commit 42a8ad5

Browse files
committed
Merge branch 'develop' into feature/ALM
# Conflicts: # gtsam/constrained/constrained.md
2 parents 3a2ee72 + 1941cc5 commit 42a8ad5

473 files changed

Lines changed: 261265 additions & 28652 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ For reviewing PRs:
44
* Use meaningful variable names, e.g. `measurement` not `msm`, avoid abbreviations.
55
* Flag overly complex or long/functions: break up in smaller functions
66
* On Windows it is necessary to explicitly export all functions from the library which should be externally accessible. To do this, include the macro `GTSAM_EXPORT` in your class or function definition.
7+
* When adding or modifying public classes/methods, always review and follow `Using-GTSAM-EXPORT.md` before finalizing changes, including template specialization/export rules.
78
* If we add a C++ function to a `.i` file to expose it to the wrapper, we must ensure that the parameter names match exactly between the declaration in the header file and the declaration in the `.i`. Similarly, if we change any parameter names in a wrapped function in a header file, or change any parameter names in a `.i` file, we must change the corresponding function in the other file to reflect those changes.
9+
* For templated classes/factors in wrappers, prefer the normal `.i` template mechanism over hand-writing one wrapper class per instantiation. Let the wrapper generate names such as `AttitudeFactorRot3` from `template<...> class AttitudeFactor`.
10+
* Do not add or keep C++ `using`/`typedef` aliases solely to manufacture wrapper names. Only keep aliases when they are genuinely useful in the C++ API as well.
811
* Classes are Uppercase, methods and functions lowerMixedCase.
912
* Public fields in structs keep plain names (no trailing underscore).
1013
* Apart from those naming conventions, we adopt Google C++ style.
14+
* Prefer concise, elegant examples: use the fewest helpers possible, favor direct construction and small local functors/lambdas over extra adapter functions.
15+
* Notebooks in `*/doc/*.ipynb` and `*/examples/*.ipynb` should follow the standard preamble:
16+
1) title/introduction markdown cell,
17+
2) copyright markdown cell tagged `remove-cell`,
18+
3) Colab badge markdown cell,
19+
4) Colab install code cell tagged `remove-cell`,
20+
5) imports/setup code cell.
21+
Use the same `remove-cell` tagging convention as existing notebooks so docs build and Colab behavior stay consistent.
1122
* After any code change, always run relevant tests via `make -j6 testXXX.run` in the build folder $WORKSPACE/build. If in VS code, ask for escalated permissions if needed.

.github/scripts/python.sh

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if [ -z ${PYTHON_VERSION+x} ]; then
2424
fi
2525

2626
export PYTHON="python${PYTHON_VERSION}"
27+
NO_BOOST_BUILD=OFF
2728

2829
function install_dependencies()
2930
{
@@ -43,20 +44,26 @@ function install_dependencies()
4344

4445
function build()
4546
{
46-
export CMAKE_GENERATOR=Ninja
4747
BUILD_PYBIND="ON"
48+
USE_BOOST_FEATURES="ON"
49+
ENABLE_BOOST_SERIALIZATION="ON"
50+
51+
if [ "${NO_BOOST_BUILD}" == "ON" ]; then
52+
USE_BOOST_FEATURES="OFF"
53+
ENABLE_BOOST_SERIALIZATION="OFF"
54+
fi
4855

4956
# Add Boost hints on Windows
5057
BOOST_CMAKE_ARGS=""
51-
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then
58+
if [ "${NO_BOOST_BUILD}" != "ON" ] && [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" || "$OSTYPE" == "cygwin" ]]; then
5259
if [ -n "${BOOST_ROOT}" ]; then
5360
BOOST_ROOT_UNIX=$(echo "$BOOST_ROOT" | sed 's/\\/\//g')
5461
BOOST_CMAKE_ARGS="-DBOOST_ROOT=${BOOST_ROOT_UNIX} -DBOOST_INCLUDEDIR=${BOOST_ROOT_UNIX}/include -DBOOST_LIBRARYDIR=${BOOST_ROOT_UNIX}/lib"
5562
fi
5663
fi
5764

5865
cmake $GITHUB_WORKSPACE \
59-
-B build \
66+
-B build -G Ninja \
6067
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
6168
-DGTSAM_BUILD_TESTS=OFF \
6269
-DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
@@ -68,20 +75,28 @@ function build()
6875
-DGTSAM_UNSTABLE_BUILD_PYTHON=${GTSAM_BUILD_UNSTABLE:-ON} \
6976
-DGTSAM_PYTHON_VERSION=$PYTHON_VERSION \
7077
-DPYTHON_EXECUTABLE:FILEPATH=$(which $PYTHON) \
71-
-DGTSAM_USE_BOOST_FEATURES=ON \
72-
-DGTSAM_ENABLE_BOOST_SERIALIZATION=ON \
78+
-DGTSAM_USE_BOOST_FEATURES=${USE_BOOST_FEATURES} \
79+
-DGTSAM_ENABLE_BOOST_SERIALIZATION=${ENABLE_BOOST_SERIALIZATION} \
7380
-DGTSAM_ALLOW_DEPRECATED_SINCE_V43=OFF \
7481
-DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/gtsam_install \
7582
$BOOST_CMAKE_ARGS
7683

77-
# Set to 2 cores so that Actions does not error out during resource provisioning.
78-
cmake --build build -j2
79-
80-
cmake --build build --target python-install
84+
if [ "${NO_BOOST_BUILD}" == "ON" ]; then
85+
# Build only wrapper targets for the no-Boost verification lane.
86+
cmake --build build -j2 --target gtsam_py gtsam_unstable_py
87+
else
88+
# Set to 2 cores so that Actions does not error out during resource provisioning.
89+
cmake --build build -j2
90+
cmake --build build --target python-install
91+
fi
8192
}
8293

8394
function test()
8495
{
96+
if [ "${NO_BOOST_BUILD}" == "ON" ]; then
97+
export PYTHONPATH="$GITHUB_WORKSPACE/build/python:$PYTHONPATH"
98+
fi
99+
85100
cd $GITHUB_WORKSPACE/python/gtsam/tests
86101
$PYTHON -m unittest discover -v
87102
cd $GITHUB_WORKSPACE
@@ -94,8 +109,30 @@ function test()
94109
# cmake --build build --target python-test-unstable
95110
}
96111

112+
# Parse optional flags.
113+
if [ $# -lt 1 ]; then
114+
echo "Usage: $0 {-d|-b|-t} [--no-boost]"
115+
exit 2
116+
fi
117+
118+
ACTION="$1"
119+
shift
120+
121+
while [ $# -gt 0 ]; do
122+
case "$1" in
123+
--no-boost)
124+
NO_BOOST_BUILD=ON
125+
;;
126+
*)
127+
echo "Unknown option: $1"
128+
exit 2
129+
;;
130+
esac
131+
shift
132+
done
133+
97134
# select between build or test
98-
case $1 in
135+
case $ACTION in
99136
-d)
100137
install_dependencies
101138
;;

.github/scripts/python_wheels/cibw_before_all.sh

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -x
88

99
PYTHON_VERSION="$1"
1010
PROJECT_DIR="$2"
11-
ARCH=$(uname -m)
11+
WHEEL_BUILD_JOBS=2
1212

1313
export PYTHON="python${PYTHON_VERSION}"
1414

@@ -33,11 +33,26 @@ BOOST_PREFIX="$HOME/opt/boost"
3333
./bootstrap.sh --prefix=${BOOST_PREFIX}
3434

3535
if [ "$(uname)" == "Linux" ]; then
36-
./b2 install --prefix=${BOOST_PREFIX} --with=all -d0
36+
./b2 -j${WHEEL_BUILD_JOBS} install --prefix=${BOOST_PREFIX} -d0 --with-graph \
37+
--with-move --with-optional --with-program_options --with-random \
38+
--with-serialization --with-smart_ptr --with-timer --with-chrono
3739
elif [ "$(uname)" == "Darwin" ]; then
38-
./b2 install --prefix=${BOOST_PREFIX} --with=all -d0 \
40+
./b2 -j${WHEEL_BUILD_JOBS} install --prefix=${BOOST_PREFIX} -d0 --with-graph \
41+
--with-move --with-optional --with-program_options --with-random \
42+
--with-serialization --with-smart_ptr --with-timer --with-chrono \
43+
architecture=arm \
3944
cxxflags="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
4045
linkflags="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
46+
./b2 -j${WHEEL_BUILD_JOBS} install --prefix=${BOOST_PREFIX}/x86 -d0 --with-graph \
47+
--with-move --with-optional --with-program_options --with-random \
48+
--with-serialization --with-smart_ptr --with-timer --with-chrono \
49+
architecture=x86 \
50+
cxxflags="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
51+
linkflags="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
52+
for dylib in ${BOOST_PREFIX}/lib/*.dylib; do
53+
lipo -create -output $dylib $dylib ${BOOST_PREFIX}/x86/lib/$(basename $dylib)
54+
done
55+
rm -r ${BOOST_PREFIX}/x86
4156
fi
4257
cd ..
4358

@@ -67,6 +82,7 @@ rm -rf CMakeCache.txt CMakeFiles
6782
cmake $PROJECT_DIR \
6883
-B build \
6984
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
85+
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
7086
-DGTSAM_BUILD_TESTS=OFF \
7187
-DGTSAM_BUILD_UNSTABLE=${GTSAM_BUILD_UNSTABLE:-ON} \
7288
-DGTSAM_USE_QUATERNIONS=OFF \
@@ -87,11 +103,5 @@ doxygen build/doc/Doxyfile
87103

88104
# Install the Python wrapper module and generate Python stubs
89105
cd $PROJECT_DIR/build/python
90-
if [ "$(uname)" == "Linux" ]; then
91-
make -j $(nproc) install
92-
make -j $(nproc) python-stubs
93-
elif [ "$(uname)" == "Darwin" ]; then
94-
make -j $(sysctl -n hw.logicalcpu) install
95-
make -j $(sysctl -n hw.logicalcpu) python-stubs
96-
fi
97-
106+
make -j${WHEEL_BUILD_JOBS} install
107+
make -j${WHEEL_BUILD_JOBS} python-stubs

.github/scripts/unix.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ function configure()
1717

1818
# GTSAM_BUILD_WITH_MARCH_NATIVE=OFF: to avoid crashes in builder VMs
1919
# CMAKE_CXX_FLAGS="-w": Suppress warnings to avoid IO latency in CI logs
20-
export CMAKE_GENERATOR=Ninja
2120
cmake $GITHUB_WORKSPACE \
22-
-B build \
21+
-B build -G Ninja \
2322
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} \
2423
-DCMAKE_CXX_FLAGS="-w" \
2524
-DGTSAM_BUILD_TESTS=${GTSAM_BUILD_TESTS:-OFF} \
@@ -34,6 +33,7 @@ function configure()
3433
-DGTSAM_USE_SYSTEM_METIS=${GTSAM_USE_SYSTEM_METIS:-OFF} \
3534
-DGTSAM_USE_BOOST_FEATURES=${GTSAM_USE_BOOST_FEATURES:-OFF} \
3635
-DGTSAM_ENABLE_BOOST_SERIALIZATION=${GTSAM_ENABLE_BOOST_SERIALIZATION:-OFF} \
36+
-DGTSAM_ENABLE_CONSISTENCY_CHECKS=${GTSAM_ENABLE_CONSISTENCY_CHECKS:-OFF} \
3737
-DGTSAM_BUILD_WITH_MARCH_NATIVE=OFF \
3838
-DGTSAM_SINGLE_TEST_EXE=${GTSAM_SINGLE_TEST_EXE:-OFF} \
3939
-DGTSAM_ENABLE_GEOGRAPHICLIB=${GTSAM_ENABLE_GEOGRAPHICLIB:-OFF}

.github/workflows/build-cibw.yml

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ jobs:
3232
matrix:
3333
include:
3434
# Linux x86_64
35-
- os: ubuntu-latest
36-
python_version: "3.10"
37-
cibw_python_version: 310
38-
platform_id: manylinux_x86_64
39-
manylinux_image: manylinux2014
4035
- os: ubuntu-latest
4136
python_version: "3.11"
4237
cibw_python_version: 311
@@ -52,13 +47,13 @@ jobs:
5247
cibw_python_version: 313
5348
platform_id: manylinux_x86_64
5449
manylinux_image: manylinux2014
50+
- os: ubuntu-latest
51+
python_version: "3.14"
52+
cibw_python_version: 314
53+
platform_id: manylinux_x86_64
54+
manylinux_image: manylinux2014
5555

5656
# Linux aarch64
57-
- os: ubuntu-24.04-arm
58-
python_version: "3.10"
59-
cibw_python_version: 310
60-
platform_id: manylinux_aarch64
61-
manylinux_image: manylinux2014
6257
- os: ubuntu-24.04-arm
6358
python_version: "3.11"
6459
cibw_python_version: 311
@@ -74,42 +69,29 @@ jobs:
7469
cibw_python_version: 313
7570
platform_id: manylinux_aarch64
7671
manylinux_image: manylinux2014
77-
78-
# MacOS x86_64
79-
- os: macos-15-intel
80-
python_version: "3.10"
81-
cibw_python_version: 310
82-
platform_id: macosx_x86_64
83-
- os: macos-15-intel
84-
python_version: "3.11"
85-
cibw_python_version: 311
86-
platform_id: macosx_x86_64
87-
- os: macos-15-intel
88-
python_version: "3.12"
89-
cibw_python_version: 312
90-
platform_id: macosx_x86_64
91-
- os: macos-15-intel
92-
python_version: "3.13"
93-
cibw_python_version: 313
94-
platform_id: macosx_x86_64
72+
- os: ubuntu-24.04-arm
73+
python_version: "3.14"
74+
cibw_python_version: 314
75+
platform_id: manylinux_aarch64
76+
manylinux_image: manylinux2014
9577

9678
# MacOS arm64
97-
- os: macos-latest
98-
python_version: "3.10"
99-
cibw_python_version: 310
100-
platform_id: macosx_arm64
10179
- os: macos-latest
10280
python_version: "3.11"
10381
cibw_python_version: 311
104-
platform_id: macosx_arm64
82+
platform_id: macosx_universal2
10583
- os: macos-latest
10684
python_version: "3.12"
10785
cibw_python_version: 312
108-
platform_id: macosx_arm64
86+
platform_id: macosx_universal2
10987
- os: macos-latest
11088
python_version: "3.13"
11189
cibw_python_version: 313
112-
platform_id: macosx_arm64
90+
platform_id: macosx_universal2
91+
- os: macos-latest
92+
python_version: "3.14"
93+
cibw_python_version: 314
94+
platform_id: macosx_universal2
11395

11496
steps:
11597
- name: Checkout
@@ -131,9 +113,10 @@ jobs:
131113
run: |
132114
python3 -m pip install -r python/dev_requirements.txt
133115
if [ "$RUNNER_OS" == "Linux" ]; then
134-
sudo apt-get install -y wget libicu-dev python3-pip python3-setuptools libboost-all-dev ninja-build
116+
sudo apt update
117+
sudo apt-get install -y libicu-dev python3-pip python3-setuptools libboost-all-dev
135118
elif [ "$RUNNER_OS" == "macOS" ]; then
136-
brew install wget icu4c boost ninja python-setuptools
119+
brew install boost python-setuptools
137120
else
138121
echo "$RUNNER_OS not supported"
139122
exit 1
@@ -146,7 +129,7 @@ jobs:
146129
# the wheels to ensure platform compatibility.
147130
- name: Run CMake
148131
run: |
149-
cmake . -B build -DGTSAM_BUILD_PYTHON=1 -DGTSAM_PYTHON_VERSION=${{ matrix.python_version }}
132+
cmake -B build -G Ninja -DGTSAM_BUILD_PYTHON=1 -DGTSAM_PYTHON_VERSION=${{ matrix.python_version }}
150133
151134
# If on macOS, we previously installed boost using homebrew for the first build.
152135
# We need to uninstall it before building the wheels with cibuildwheel, which will
@@ -163,6 +146,7 @@ jobs:
163146
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
164147
CIBW_MANYLINUX_AARCH64_IMAGE: ${{ matrix.manylinux_image }}
165148
CIBW_ARCHS: all
149+
CIBW_ARCHS_MACOS: universal2
166150
CIBW_ENVIRONMENT_PASS_LINUX: DEVELOP TIMESTAMP
167151

168152
# Set the minimum required MacOS version for the wheels.
@@ -181,6 +165,17 @@ jobs:
181165

182166
run: bash .github/scripts/python_wheels/build_wheels.sh
183167

168+
- name: Test wheel
169+
run: |
170+
python3 -m pip install wheelhouse/*.whl
171+
python3 -c "import platform; print(platform.machine()); import gtsam"
172+
if [ "$RUNNER_OS" == "macOS" ]; then
173+
# Uninstall numpy and reinstall wheel to get x86 numpy for smoke test
174+
arch -x86_64 python3 -m pip uninstall -y numpy
175+
arch -x86_64 python3 -m pip install wheelhouse/*.whl
176+
arch -x86_64 python3 -c "import platform; print(platform.machine()); import gtsam;"
177+
fi
178+
184179
- name: Store artifacts
185180
uses: actions/upload-artifact@v4
186181
with:

.github/workflows/build-linux.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ jobs:
9494
run: |
9595
echo "GTSAM_ENABLE_GEOGRAPHICLIB=ON" >> $GITHUB_ENV
9696
97+
- name: Enable Consistency Checks (Debug)
98+
if: matrix.build_type == 'Debug'
99+
run: |
100+
echo "GTSAM_ENABLE_CONSISTENCY_CHECKS=ON" >> $GITHUB_ENV
101+
97102
- name: Build and Test
98103
run: |
99104
.github/scripts/unix.sh -t

0 commit comments

Comments
 (0)