Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/ci-deps-versions.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
BOOST_VERSION=1.90.0
EIGEN_VERSION=3.4.0
EIGENPY_VERSION=3.13.0
# The number libraries the Linux image builds from source: FLINT 3 (which carries Arb, the ball
# arithmetic behind b2's interval types) needs GMP >= 6.2.1 and the manylinux base ships 6.2.0, so
# GMP comes from source, and MPFR and MPC are built against it so the image has one consistent set.
# macOS takes them from Homebrew and Windows from conda-forge; these pins are for the image only.
GMP_VERSION=6.3.0
MPFR_VERSION=4.2.2
MPC_VERSION=1.3.1
FLINT_VERSION=3.5.0
18 changes: 16 additions & 2 deletions .github/workflows/build-ci-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ name: Build CI deps image 🐳
on:
workflow_dispatch:
push:
branches: [develop]
# An integration branch (ADR-0074) that changes the image publishes its own tag, which its
# wheel jobs pin; develop's tag is untouched.
branches: [develop, 'integration/**']
paths:
- 'docker/manylinux-deps/**'
- '.github/workflows/build-ci-image.yml'
Expand Down Expand Up @@ -63,6 +65,10 @@ jobs:
echo "BOOST_VERSION=$BOOST_VERSION"
echo "EIGEN_VERSION=$EIGEN_VERSION"
echo "EIGENPY_VERSION=$EIGENPY_VERSION"
echo "GMP_VERSION=$GMP_VERSION"
echo "MPFR_VERSION=$MPFR_VERSION"
echo "MPC_VERSION=$MPC_VERSION"
echo "FLINT_VERSION=$FLINT_VERSION"
} >> "$GITHUB_ENV"
- name: Build Boost+eigenpy for ${{ matrix.pytag }} (manylinux)
run: |
Expand Down Expand Up @@ -104,6 +110,10 @@ jobs:
echo "BOOST_VERSION=$BOOST_VERSION"
echo "EIGEN_VERSION=$EIGEN_VERSION"
echo "EIGENPY_VERSION=$EIGENPY_VERSION"
echo "GMP_VERSION=$GMP_VERSION"
echo "MPFR_VERSION=$MPFR_VERSION"
echo "MPC_VERSION=$MPC_VERSION"
echo "FLINT_VERSION=$FLINT_VERSION"
} >> "$GITHUB_ENV"

- name: Collect prebuilt deps into the build context
Expand All @@ -116,7 +126,7 @@ jobs:
- name: Compute toolchain tag
id: tag
run: |
key="boost${BOOST_VERSION}-eigen${EIGEN_VERSION}-eigenpy${EIGENPY_VERSION}-${MANYLINUX_TAG}${{ matrix.suffix }}"
key="boost${BOOST_VERSION}-eigen${EIGEN_VERSION}-eigenpy${EIGENPY_VERSION}-flint${FLINT_VERSION}-${MANYLINUX_TAG}${{ matrix.suffix }}"
echo "key=$key" >> "$GITHUB_OUTPUT"
echo "Image: $IMAGE:$key"
ls -lh docker/manylinux-deps/deps
Expand All @@ -141,3 +151,7 @@ jobs:
BOOST_VERSION=${{ env.BOOST_VERSION }}
EIGEN_VERSION=${{ env.EIGEN_VERSION }}
EIGENPY_VERSION=${{ env.EIGENPY_VERSION }}
GMP_VERSION=${{ env.GMP_VERSION }}
MPFR_VERSION=${{ env.MPFR_VERSION }}
MPC_VERSION=${{ env.MPC_VERSION }}
FLINT_VERSION=${{ env.FLINT_VERSION }}
16 changes: 10 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
boost: ${{ steps.v.outputs.boost }}
eigen: ${{ steps.v.outputs.eigen }}
eigenpy: ${{ steps.v.outputs.eigenpy }}
flint: ${{ steps.v.outputs.flint }}
steps:
- uses: actions/checkout@v5
- id: v
Expand All @@ -100,6 +101,7 @@ jobs:
echo "boost=$BOOST_VERSION"
echo "eigen=$EIGEN_VERSION"
echo "eigenpy=$EIGENPY_VERSION"
echo "flint=$FLINT_VERSION"
} >> "$GITHUB_OUTPUT"

set_matrix:
Expand Down Expand Up @@ -174,11 +176,11 @@ jobs:
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y wget libgmp-dev libmpfr-dev libmpc-dev libeigen3-dev libtool openmpi-bin libopenmpi-dev ccache
sudo apt-get install -y wget libgmp-dev libmpfr-dev libmpc-dev libflint-dev libeigen3-dev libtool openmpi-bin libopenmpi-dev ccache

- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: brew install gmp mpfr libmpc eigen@3 open-mpi ccache
run: brew install gmp mpfr libmpc flint eigen@3 open-mpi ccache

# compiler cache: makes recompiles of unchanged C++ near-free. the key is
# deliberately loose (always save fresh, restore newest) -- ccache does its
Expand Down Expand Up @@ -410,6 +412,7 @@ jobs:
BOOST_VERSION: ${{ needs.set_versions.outputs.boost }}
EIGEN_VERSION: ${{ needs.set_versions.outputs.eigen }}
EIGENPY_VERSION: ${{ needs.set_versions.outputs.eigenpy }}
FLINT_VERSION: ${{ needs.set_versions.outputs.flint }}
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -482,8 +485,8 @@ jobs:
# yet, cibuildwheel's pull fails loudly (the implicit ABI assert; no silent mismatch).
# Each runner builds only its own architecture (cibuildwheel's default), so an x86_64
# runner pulls only the first image and an arm runner only the second.
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/bertiniteam/b2-manylinux-deps:boost${{ env.BOOST_VERSION }}-eigen${{ env.EIGEN_VERSION }}-eigenpy${{ env.EIGENPY_VERSION }}-mlx2_34
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/bertiniteam/b2-manylinux-deps:boost${{ env.BOOST_VERSION }}-eigen${{ env.EIGEN_VERSION }}-eigenpy${{ env.EIGENPY_VERSION }}-mlx2_34-aarch64
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/bertiniteam/b2-manylinux-deps:boost${{ env.BOOST_VERSION }}-eigen${{ env.EIGEN_VERSION }}-eigenpy${{ env.EIGENPY_VERSION }}-flint${{ env.FLINT_VERSION }}-mlx2_34
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/bertiniteam/b2-manylinux-deps:boost${{ env.BOOST_VERSION }}-eigen${{ env.EIGEN_VERSION }}-eigenpy${{ env.EIGENPY_VERSION }}-flint${{ env.FLINT_VERSION }}-mlx2_34-aarch64
# cibuildwheel COPIES the project into the container (no bind mount), so
# a cache written under /project is discarded. mount the host ccache dir
# explicitly; ignored on macOS (host build, no container).
Expand All @@ -495,14 +498,15 @@ jobs:
ls -1 /opt/deps &&
command -v patchelf &&
ccache --version >/dev/null &&
command -v mpicc
command -v mpicc &&
test -f /usr/local/include/flint/flint.h
# On macOS, Homebrew's boost-python3 / eigenpy bottles track the current
# Homebrew default Python (now 3.14), so a cp313 wheel that bundles them
# imports a libboost_python314.dylib into a 3.13 interpreter and segfaults.
# Install only the Python-version-independent libs from brew here; download
# Boost & eigenpy sources to /tmp for the per-Python build in BEFORE_BUILD.
CIBW_BEFORE_ALL_MACOS: >
brew install gmp mpfr libmpc eigen@3 ccache &&
brew install gmp mpfr libmpc flint eigen@3 ccache &&
cd /tmp &&
{ [ -f eigenpy-${{ env.EIGENPY_VERSION }}.tar.gz ] || curl -fsSL -o eigenpy-${{ env.EIGENPY_VERSION }}.tar.gz https://github.com/stack-of-tasks/eigenpy/releases/download/v${{ env.EIGENPY_VERSION }}/eigenpy-${{ env.EIGENPY_VERSION }}.tar.gz ; }

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ _______________________________________________________________________________

The arm64 macOS wheels move to macOS 15, and the fixes made since 4.0.0.

### Added

- FLINT 3 (which carries Arb, arbitrary-precision ball arithmetic) is a dependency of the library, the groundwork for interval evaluation and certification (#412). Wheels bundle it; a source build needs `libflint` (Homebrew `flint`, conda-forge `libflint`, apt `libflint-dev`). `bertini.info.flint_version()` reports the linked version.

### Changed

- The arm64 macOS wheels are built on GitHub's `macos-15` runners, and require macOS 15, as the Intel wheels already did. The `macos-14` runner images were retired on 2026-11-02, and a wheel's minimum macOS follows the runner it is built on, since the Homebrew libraries bundled into it are built for that macOS. The prebuilt macOS dependency tarballs are rebuilt on the same runners.
Expand Down
3 changes: 2 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The build system uses `scikit-build-core` (configured in `pyproject.toml`). The
### macOS Dependencies (Homebrew)

```bash
brew install gmp mpfr libmpc eigen@3 eigenpy boost boost-python3
brew install gmp mpfr libmpc flint eigen@3 eigenpy boost boost-python3
```

### Linux/CI Dependencies (conda)
Expand Down Expand Up @@ -185,6 +185,7 @@ Rules that follow:
## Key Dependencies

- **GMP/MPFR/MPC** -- Arbitrary-precision arithmetic (found via custom CMake modules in `cmake/`)
- **FLINT** (>= 3.0; found via `cmake/FindFLINT.cmake`, linked PUBLIC) -- carries Arb, the arbitrary-precision ball arithmetic behind b2's interval types (#412). `info.flint_version()` reports the linked version. FLINT needs GMP >= 6.2.1 and the manylinux base (AlmaLinux 9) ships 6.2.0, so the Linux deps image builds GMP (fat on x86_64), MPFR, MPC and FLINT from source into `/usr/local`, stripped -- an unstripped `libflint.so` adds ~25 MB to a wheel; the four versions are pinned in `.github/ci-deps-versions.env` and the image tag carries `-flint<version>`. macOS takes `flint` from Homebrew, Windows `libflint` from conda-forge, the Ubuntu C++ job `libflint-dev` from apt. FLINT declares its `mpz`/`mpfr` conversions only when `<gmp.h>`/`<mpfr.h>` are included before its headers.
- **Eigen 3** -- Linear algebra. **Not** pinned in cmake (`find_package(Eigen3)`, no version floor). In practice the version is coupled to the eigenpy build: the wheel CI builds **eigen 3.4.0** and then builds eigenpy against it (a dev env may use newer, e.g. `eigen=5.0.1`). Newer Eigen is welcome -- we *want* upstream improvements -- but it must be matched by an eigenpy built against the same Eigen (they share Eigen types across the binding ABI).
- **Boost** (serialization, filesystem, log, graph, regex, timer, chrono, thread, unit_test_framework, python) -- no minimum version pinned in cmake; `boost_system` is conditionally linked for Boost < 1.89 (header-only from 1.89). Boost.Python is ABI-locked to one CPython version, so it is built **per target Python** -- but this now happens **once, up front, in the prebuilt CI deps** (Linux image / macOS tarballs, ADR-0049), *not* recompiled in every wheel run.
- **eigenpy** -- Eigen/NumPy bridge for Python bindings. **Prebuilt** into the CI deps (image/tarballs), not built-from-source per run, against the chosen Eigen -- eigenpy and bertini must use the *same* Eigen. The version is single-sourced in `.github/ci-deps-versions.env` (`EIGENPY_VERSION`, currently `3.13.0`); eigenpy >= 3.13 sets the Python floor (>= 3.10). **A wheel is not ABI-coupled to a user's own eigenpy:** `auditwheel`/`delocate` bundle private, renamed copies of eigenpy and Boost.Python (`bertini2.libs/libeigenpy-<hash>.so`, `libboost_python3XX-<hash>.so...`), and Python loads extensions `RTLD_LOCAL`, so a PyPI `eigenpy` in the same process loads its own copies beside ours (verified 2026-09-28: both import orders, no warnings, arrays pass both ways). Only numpy arrays cross between the two; another library's Boost.Python objects do not convert (a clean `TypeError`). The coupling that does exist is for **source builds** against shared libraries (conda, Homebrew), which must use the same eigenpy and Eigen as the environment.
Expand Down
62 changes: 62 additions & 0 deletions cmake/FindFLINT.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Try to find the FLINT library (Fast Library for Number Theory).
# See https://flintlib.org/
#
# FLINT 3 includes Arb, the arbitrary-precision ball arithmetic b2 uses for
# interval evaluation, so the minimum is 3.0.0 unless the caller asks for newer:
# find_package(FLINT 3.0.0)
#
# Once done this will define
#
# FLINT_FOUND - system has FLINT with an acceptable version
# FLINT_INCLUDES - the directory holding flint/flint.h
# FLINT_LIBRARIES - the FLINT library
# FLINT_VERSION - FLINT version
#
# Modeled on FindMPFR.cmake (BSD-licensed, from KDE/Eigen).

find_path(FLINT_INCLUDES
NAMES
flint/flint.h
PATHS
$ENV{FLINTDIR}/include
${INCLUDE_INSTALL_DIR}
)

if(NOT FLINT_FIND_VERSION)
set(FLINT_FIND_VERSION "3.0.0")
endif()

if(FLINT_INCLUDES)

file(READ "${FLINT_INCLUDES}/flint/flint.h" _flint_version_header)

string(REGEX MATCH "define[ \t]+__FLINT_VERSION[ \t]+([0-9]+)" _flint_major_version_match "${_flint_version_header}")
set(FLINT_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+__FLINT_VERSION_MINOR[ \t]+([0-9]+)" _flint_minor_version_match "${_flint_version_header}")
set(FLINT_MINOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+__FLINT_VERSION_PATCHLEVEL[ \t]+([0-9]+)" _flint_patchlevel_version_match "${_flint_version_header}")
set(FLINT_PATCHLEVEL_VERSION "${CMAKE_MATCH_1}")

set(FLINT_VERSION ${FLINT_MAJOR_VERSION}.${FLINT_MINOR_VERSION}.${FLINT_PATCHLEVEL_VERSION})

if(${FLINT_VERSION} VERSION_LESS ${FLINT_FIND_VERSION})
set(FLINT_VERSION_OK FALSE)
message(STATUS "FLINT version ${FLINT_VERSION} found in ${FLINT_INCLUDES}, "
"but at least version ${FLINT_FIND_VERSION} is required")
else()
set(FLINT_VERSION_OK TRUE)
endif()

endif(FLINT_INCLUDES)

# The library's file name differs by platform and packager: libflint.so / .dylib on unix,
# flint.lib or libflint.dll.a from conda-forge on Windows. Name every spelling.
find_library(FLINT_LIBRARIES
NAMES flint libflint flint.lib libflint.lib libflint.dll.a
PATHS $ENV{FLINTDIR}/lib ${LIB_INSTALL_DIR}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FLINT DEFAULT_MSG
FLINT_INCLUDES FLINT_LIBRARIES FLINT_VERSION_OK)
mark_as_advanced(FLINT_INCLUDES FLINT_LIBRARIES)
22 changes: 22 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
find_package(GMP REQUIRED)
find_package(MPFR REQUIRED)
find_package(MPC REQUIRED)
# FLINT 3 carries Arb, the ball arithmetic behind b2's interval types (bertiniteam/b2#412).
find_package(FLINT 3.0.0 REQUIRED)

# include_directories(${GMP_INCLUDES})
# include_directories(${MPC_INCLUDES})
Expand Down Expand Up @@ -123,6 +125,7 @@ set(basics_rootinclude_headers
include/bertini2/forbid_mixed_arithmetic.hpp
include/bertini2/double_extensions.hpp
include/bertini2/random.hpp
include/bertini2/flint_version.hpp
include/bertini2/num_traits.hpp
include/bertini2/classic.hpp
include/bertini2/eigen_extensions.hpp
Expand Down Expand Up @@ -350,6 +353,7 @@ set(BERTINI2_LIBRARY_HEADERS

set(basics_sources
src/basics/random.cpp
src/basics/flint_version.cpp
src/basics/have_bertini.cpp
src/basics/fast_allocator.cpp
src/basics/stop_request.cpp
Expand Down Expand Up @@ -461,6 +465,7 @@ target_include_directories(bertini2
${GMP_INCLUDES}
${MPFR_INCLUDES}
${MPC_INCLUDES}
${FLINT_INCLUDES}
# Treat Boost/Eigen headers as system so their (and their template
# instantiations') warnings stay out of our build output. Boost is linked
# below via raw ${Boost_LIBRARIES} (no include propagation), so its include
Expand Down Expand Up @@ -505,6 +510,7 @@ target_include_directories(bertini2 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generat
target_link_libraries(bertini2 PUBLIC ${GMP_LIBRARIES})
target_link_libraries(bertini2 PUBLIC ${MPFR_LIBRARIES})
target_link_libraries(bertini2 PUBLIC ${MPC_LIBRARIES})
target_link_libraries(bertini2 PUBLIC ${FLINT_LIBRARIES})
target_link_libraries(bertini2 PUBLIC Eigen3::Eigen)
target_link_libraries(bertini2 PUBLIC ${Boost_LIBRARIES})

Expand Down Expand Up @@ -1001,6 +1007,22 @@ if (ENABLE_UNIT_TESTING)
target_link_libraries(test_tracking_basics ${Boost_LIBRARIES} bertini2)
add_test(NAME test_tracking_basics COMMAND ${CMAKE_BINARY_DIR}/core/test_tracking_basics)

# What b2 relies on from FLINT, checked on every platform: rigorous enclosures, exact
# mpfr <-> arf conversion, one GMP shared with b2, a zero-filled acb being an exact zero.
set(B2_FLINT_TEST
test/flint/flint_test.cpp
)

add_executable(test_flint ${B2_FLINT_TEST})
target_include_directories(test_flint PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(test_flint ${Boost_LIBRARIES} bertini2)
if(NOT MSVC)
# Boost.Interval's directed rounding is rigorous only if the optimizer respects the
# FPU rounding mode; this flag tells GCC and Clang not to assume round-to-nearest.
set_source_files_properties(${B2_FLINT_TEST} PROPERTIES COMPILE_OPTIONS "-frounding-math")
endif()
add_test(NAME test_flint COMMAND ${CMAKE_BINARY_DIR}/core/test_flint)

enable_testing()

endif (ENABLE_UNIT_TESTING)
Expand Down
44 changes: 44 additions & 0 deletions core/include/bertini2/flint_version.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//This file is part of Bertini 2.
//
//bertini2/flint_version.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//bertini2/flint_version.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with bertini2/flint_version.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.

/**
\file flint_version.hpp

\brief The version of FLINT the library was linked against.

FLINT 3 carries Arb, the ball arithmetic behind b2's interval types (bertiniteam/b2#412). This
is also the one FLINT reference the Python extension makes, which keeps FLINT linked into it:
libbertini2 is a static library, so a linker drops what nothing references, and the wheel repair
tools then bundle nothing.
*/

#pragma once

#include <string>

namespace bertini {

/**
\brief The FLINT version string the library was linked against, e.g. "3.5.0".
*/
std::string FlintVersion();

} // namespace bertini
33 changes: 33 additions & 0 deletions core/src/basics/flint_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//This file is part of Bertini 2.
//
//src/basics/flint_version.cpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//src/basics/flint_version.cpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with src/basics/flint_version.cpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.

#include "bertini2/flint_version.hpp"

#include <flint/flint.h>

namespace bertini {

std::string FlintVersion()
{
return std::string(flint_version);
}

} // namespace bertini
Loading
Loading