Skip to content

Fix manylinux wheel build: expose fetched Eigen3 package to autodiff#170

Merged
astomodynamics merged 2 commits into
masterfrom
copilot/fix-github-actions-wheel-build
Apr 4, 2026
Merged

Fix manylinux wheel build: expose fetched Eigen3 package to autodiff#170
astomodynamics merged 2 commits into
masterfrom
copilot/fix-github-actions-wheel-build

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

autodiff runs its own find_package(Eigen3) in config mode during CMake configuration, looking for Eigen3Config.cmake. When Eigen is fetched via FetchContent, the file is generated in the build tree but never added to CMake's search path — so autodiff fails even though Eigen3::Eigen target already exists.

Changes

  • Set Eigen3_DIR after fetching Eigen — points to ${eigen_BINARY_DIR} where Eigen3Config.cmake is generated, making subsequent find_package(Eigen3) calls (including from autodiff) succeed
  • Safety-net target creation — adds Eigen3::Eigen as an INTERFACE IMPORTED target if Eigen's CMake didn't create it
  • Simplified linkingtarget_link_libraries now unconditionally links Eigen3::Eigen instead of a conditional generator expression
  • Removed include-dir fallback — the old target_include_directories(... EIGEN3_INCLUDE_DIRS) block is superseded by the proper target
FetchContent_MakeAvailable(eigen)

# Expose generated Eigen3Config.cmake to downstream find_package calls (e.g. autodiff)
set(Eigen3_DIR "${eigen_BINARY_DIR}" CACHE PATH "Path to Eigen3Config.cmake" FORCE)

if(NOT TARGET Eigen3::Eigen)
  add_library(Eigen3::Eigen INTERFACE IMPORTED)
  set_target_properties(Eigen3::Eigen PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${eigen_SOURCE_DIR}")
endif()

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Fix the failing GitHub Actions wheel build in repository astomodynamics/cddp-cpp.

Context:

  • The failing job is from GitHub Actions run 23988531721, job 69964331629.
  • Workflow file: .github/workflows/publish.yml.
  • The failure happens during the Build wheels step using cibuildwheel on Linux manylinux.
  • The build log shows CMake configuration failing inside the fetched autodiff dependency because Eigen3 cannot be found:
    • CMake Error at /tmp/tmp6h41tzny/build/_deps/autodiff-src/CMakeLists.txt:29 (find_package):
    • By not providing "FindEigen3.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Eigen3"...
  • Relevant project files include:
    • CMakeLists.txt
    • .github/workflows/publish.yml
    • pyproject.toml
    • python/CMakeLists.txt

Observed current behavior in CMakeLists.txt:

  • The project calls find_package(Eigen3 QUIET).
  • If Eigen is not found, it fetches Eigen with FetchContent and sets EIGEN3_INCLUDE_DIRS.
  • Then it fetches autodiff with FetchContent_MakeAvailable(autodiff).
  • This is insufficient because autodiff performs its own find_package(Eigen3) and expects a proper CMake package/target, which is not available in the isolated cibuildwheel manylinux environment.

Goal:

  • Update the build configuration so the wheel build succeeds in CI, especially on Linux manylinux.
  • Prefer a robust CMake-side fix over a CI-only package installation workaround.

Suggested direction:

  • Ensure Eigen is made available to downstream dependencies like autodiff as a proper CMake target/package before FetchContent_MakeAvailable(autodiff) is invoked.
  • A good solution may involve fetching Eigen when not found and ensuring Eigen3::Eigen exists and is usable by downstream CMake logic.
  • Simplify linking so the project links against Eigen3::Eigen directly instead of relying on ad hoc include directory fallbacks.
  • Keep the fix minimal and targeted.

Please implement the fix, verify the relevant files changed appropriately, and open a pull request with a concise title and summary.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The job is failing during the Linux wheel build (cibuildwheel/manylinux) at CMake configure time because a dependency brought in via FetchContent (autodiff) runs:

find_package(Eigen3 ...)

and Eigen3 is not discoverable inside the wheel build environment, so configuration aborts:

CMake Error ... autodiff-src/CMakeLists.txt:29 (find_package): ... asked CMake to find ... "Eigen3", but ...

Your top-level CMakeLists.txt tries to handle Eigen by downloading it when not found (lines 65–77), but that does not help autodiff because:

  • autodiff is configured as its own CMake project, and it performs its own find_package(Eigen3) (and fails) before it can use your include directories.
  • Simply setting EIGEN3_INCLUDE_DIRS in your project won’t satisfy autodiff’s find_package(Eigen3).

Fix (recommended): Fetch Eigen and expose a proper Eigen3::Eigen target before autodiff

Patch CMakeLists.txt (ref: 0d7ab73ccf85c03cf238f0477af9d8a3b21e75ad) so that if Eigen isn’t found, you fetch it and create/import the Eigen3::Eigen target that downstream projects (like autodiff) expect.

Replace your Eigen block (currently around lines 65–77) with something like:

# Find packages
find_package(Eigen3 3.4 QUIET NO_MODULE)

# If Eigen3 is not found, download it and make Eigen3::Eigen available
if(NOT Eigen3_FOUND)
  message(STATUS "Eigen3 not found. Downloading...")

  include(FetchContent)
  FetchContent_Declare(
    eigen
    GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
    GIT_TAG 3.4.0
  )
  FetchContent_MakeAvailable(eigen)

  # Eigen's CMake exports a target in many cases, but ensure it exists:
  if(NOT TARGET Eigen3::Eigen)
    add_library(Eigen3::Eigen INTERFACE IMPORTED)
    set_target_properties(Eigen3::Eigen PROPERTIES
      INTERFACE_INCLUDE_DIRECTORIES "${eigen_SOURCE_DIR}"
    )
  endif()
endif()

Then simplify your library linking to always link against Eigen3::Eigen:

target_link_libraries(${PROJECT_NAME}
  PUBLIC
    Eigen3::Eigen
    autodiff
)

and remove the conditional include hack:

# remove this block; it becomes unnecessary
# if(NOT Eigen3_FOUND)
#   target_include_directories(${PROJECT_NAME} PUBLIC ${EIGEN3_INCLUDE_DIRS})
# endif()

Why this works: autodiff’s find_package(Eigen3) will succeed if CMake can “see” Eigen as a proper package/target. By ensuring the canonical Eigen3::Eigen target exists early, you make the dependency graph consistent even in isolated build environments li...

This pull request was created from Copilot chat.

@astomodynamics astomodynamics self-requested a review April 4, 2026 22:16
Copilot AI changed the title [WIP] Fix failing GitHub Actions wheel build for autodiff dependency Fix manylinux wheel build: expose fetched Eigen3 package to autodiff Apr 4, 2026
Copy link
Copy Markdown
Owner

@astomodynamics astomodynamics left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve #170 . The change is minimal and targeted.

@astomodynamics astomodynamics marked this pull request as ready for review April 4, 2026 22:22
@astomodynamics astomodynamics merged commit 0eb3887 into master Apr 4, 2026
2 checks passed
@astomodynamics astomodynamics deleted the copilot/fix-github-actions-wheel-build branch April 4, 2026 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants