Skip to content

fix: remove BUILD_WITH_INSTALL_RPATH so dev builds find libOpenMS.so - #8892

Merged
timosachsenberg merged 2 commits into
developfrom
fix/pyopenms-rpath-dev-build
Mar 12, 2026
Merged

timosachsenberg merged 2 commits into
developfrom
fix/pyopenms-rpath-dev-build

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Removes BUILD_WITH_INSTALL_RPATH 1 from the non-wheel-repair RPATH code path in src/pyOpenMS/CMakeLists.txt
  • This property replaced CMake's default build-tree RPATH (absolute path to build/lib/) with the install RPATH ($ORIGIN/../lib/), which resolves to build/pyOpenMS/lib/ — a directory that doesn't exist
  • Without it, CMake embeds the correct build-tree path at build time and still applies INSTALL_RPATH during cmake --install

Before: nanobind modules had RUNPATH $ORIGIN/../lib/:$ORIGIN/ → libOpenMS.so not found → import fails

After: nanobind modules have RUNPATH /abs/path/to/build/lib/ → libOpenMS.so found → import works

Wheel builds are unaffected — they use the PYOPENMS_PREPARE_WHEEL_REPAIR=ON code path which never set this property.

Fixes #8891

Test plan

  • Verified RUNPATH on built module now includes absolute build-tree lib path
  • Verified import pyopenms succeeds without LD_LIBRARY_PATH from build tree
  • CI wheel builds still pass (different code path, should be unaffected)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated build configuration to apply bundled-dependency runtime path settings only when dependencies are included, leaving builds without bundled dependencies unaffected. This refines packaging behavior during build and reduces unnecessary install-time path adjustments.

BUILD_WITH_INSTALL_RPATH replaced CMake's default build-tree RPATH
(absolute path to build/lib/) with the install RPATH ($ORIGIN/../lib/).
That relative path resolves correctly for installed executables in bin/
but not for nanobind modules in pyOpenMS/pyopenms/, causing
"libOpenMS.so: cannot open shared object file" on import.

Removing this property lets CMake embed the build-tree library path
at build time while still applying INSTALL_RPATH during cmake --install.
Wheel builds are unaffected (they use the PYOPENMS_PREPARE_WHEEL_REPAIR
code path which never set this property).

Fixes #8891

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai

coderabbitai Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The CMake logic in src/pyOpenMS/CMakeLists.txt was changed to set the BUILD_WITH_INSTALL_RPATH target property only when dependencies are bundled (i.e., when NO_DEPENDENCIES is not set), making the install RPATH conditional instead of always removed during non-wheel-repair builds.

Changes

Cohort / File(s) Summary
Build Configuration
src/pyOpenMS/CMakeLists.txt
Make BUILD_WITH_INSTALL_RPATH conditional: set it only if dependencies are bundled (when NO_DEPENDENCIES is not set); previously it was unconditionally removed during non-wheel-repair preparation.

Suggested reviewers

  • jpfeuffer

Poem

🐰 A tiny hop in CMake land,
RPATH set only when deps stand,
Conditional logic, neat and spry,
Builds behave and wheels comply,
Hopper hums a quiet, grateful sigh.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title states the primary change: removing BUILD_WITH_INSTALL_RPATH to fix dev builds finding libOpenMS.so, matching the core issue described in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/pyopenms-rpath-dev-build
📝 Coding Plan for PR comments
  • Generate coding plan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@timosachsenberg
timosachsenberg requested a review from pjones March 12, 2026 13:23
@jpfeuffer

jpfeuffer commented Mar 12, 2026 •

Copy link
Copy Markdown
Contributor

i dont think this will fix it and will break other workflows. libOpenMS is clearly copied into the pyopenms build tree.

And stupid AI is lying since we set the RPATH to ORIGIN not ORIGIN/../lib

Without further information I would not touch the CMake setup.
We need a clear file tree, what was called from where etc., to see if the setup was correct and a supported build workflow was used.

@jpfeuffer

Copy link
Copy Markdown
Contributor

Note you are not testing macos dev wheels in CI

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

Evidence

1. RPATH before the fix includes $ORIGIN/../lib/, not just $ORIGIN/

$ patchelf --print-rpath _pyopenms_kernel.cpython-312-x86_64-linux-gnu.so
$ORIGIN/../lib/:$ORIGIN/

This is because PY_RPATH is initialized from CMAKE_INSTALL_RPATH ($ORIGIN/../lib/) then $ORIGIN/ is appended (CMakeLists.txt lines 180-185).

2. NO_DEPENDENCIES=ON is the default — the copy doesn't happen

option(NO_DEPENDENCIES "Do not bundle dependencies (use wheel repair tools instead)" ON)

The pyopenms_copy_deps target is inside if(NOT NO_DEPENDENCIES), so it only runs when explicitly set to OFF. CI sets OFF, but a default dev build does not.

3. Neither RPATH entry resolves to libOpenMS.so

  • $ORIGIN/ = build/pyOpenMS/pyopenms/ — no libOpenMS.so here (not copied)
  • $ORIGIN/../lib/ = build/pyOpenMS/lib/ — doesn't exist (actual location is build/lib/)

4. Reproduced the exact error locally with default settings

$ cd /tmp && PYTHONPATH=.../OpenMS-build/pyOpenMS python3 -c "import pyopenms"
ImportError: libOpenMS.so: cannot open shared object file: No such file or directory

5. After removing BUILD_WITH_INSTALL_RPATH 1, the RPATH becomes the absolute build-tree path and import works

$ patchelf --print-rpath _pyopenms_kernel.cpython-312-x86_64-linux-gnu.so
/home/.../OpenMS-build/lib:

$ cd /tmp && PYTHONPATH=.../OpenMS-build/pyOpenMS python3 -c "import pyopenms"
OK: 3.5.0

6. INSTALL_RPATH is still correctly set for installed layouts

-- pyOpenMS: PY_RPATH = '$ORIGIN/../lib/;$ORIGIN/'

CMake replaces the build-tree RPATH with this during cmake --install.

7. Wheel builds are unaffected

They use the PYOPENMS_PREPARE_WHEEL_REPAIR=ON code path which never sets BUILD_WITH_INSTALL_RPATH.

@jpfeuffer

Copy link
Copy Markdown
Contributor

not in CI: NO_DEPENDENCIES: "${{ startsWith(matrix.os, 'ubuntu') && matrix.compiler == 'g++' && 'OFF' || 'ON' }}"

well claude, then make it dependent on NO_DEPENDENCIES instead of destroying the workflows for others. macOS has a completely interpretation of RPATHs. I would only allow it if claude was also running it on all platforms.

When NO_DEPENDENCIES=ON (the default), libOpenMS.so is not copied into
the pyopenms package directory. BUILD_WITH_INSTALL_RPATH replaces
CMake's build-tree RPATH with the install RPATH ($ORIGIN/../lib/:$ORIGIN/),
neither of which resolves to the actual build/lib/ directory.

Make BUILD_WITH_INSTALL_RPATH conditional on NO_DEPENDENCIES=OFF, where
the libraries are co-located and $ORIGIN/ works. When NO_DEPENDENCIES=ON,
let CMake use its default build-tree RPATH (absolute path to build/lib/).

Fixes #8891

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/pyOpenMS/CMakeLists.txt (1)

246-250: ⚠️ Potential issue | 🟡 Minor

Update workflow comment to match actual configuration.

The comment on line 311 of .github/workflows/pyopenms-wheels-cibuildwheel.yml states "NO_DEPENDENCIES=OFF enables legacy library copying for macOS" but NO_DEPENDENCIES is not explicitly set in the CIBW_ENVIRONMENT block, so the workflow uses the default NO_DEPENDENCIES=ON from pyproject.toml. The comment should be clarified to reflect that wheel builds intentionally use NO_DEPENDENCIES=ON with wheel repair tools, not the legacy library copying mechanism.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pyOpenMS/CMakeLists.txt` around lines 246 - 250, Update the workflow
comment in .github/workflows/pyopenms-wheels-cibuildwheel.yml to accurately
reflect the actual configuration: note that NO_DEPENDENCIES is not set in the
CIBW_ENVIRONMENT block so the workflow inherits the default NO_DEPENDENCIES=ON
from pyproject.toml, and that wheel builds rely on cibuildwheel/repair-wheel
tools (wheel repair) rather than the legacy library copying mechanism; adjust
the comment text accordingly to mention NO_DEPENDENCIES=ON and the use of wheel
repair tools instead of saying "NO_DEPENDENCIES=OFF enables legacy library
copying for macOS".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/pyOpenMS/CMakeLists.txt`:
- Around line 246-250: Update the workflow comment in
.github/workflows/pyopenms-wheels-cibuildwheel.yml to accurately reflect the
actual configuration: note that NO_DEPENDENCIES is not set in the
CIBW_ENVIRONMENT block so the workflow inherits the default NO_DEPENDENCIES=ON
from pyproject.toml, and that wheel builds rely on cibuildwheel/repair-wheel
tools (wheel repair) rather than the legacy library copying mechanism; adjust
the comment text accordingly to mention NO_DEPENDENCIES=ON and the use of wheel
repair tools instead of saying "NO_DEPENDENCIES=OFF enables legacy library
copying for macOS".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40c6ac8a-dd09-4522-b284-6c57551312d8

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0de04 and 09b3402.

📒 Files selected for processing (1)
  • src/pyOpenMS/CMakeLists.txt

@timosachsenberg
timosachsenberg merged commit 049f130 into develop Mar 12, 2026
18 of 19 checks passed
@timosachsenberg
timosachsenberg deleted the fix/pyopenms-rpath-dev-build branch March 12, 2026 19:05
github-actions Bot pushed a commit that referenced this pull request Mar 17, 2026
Add missing changelog entries for changes merged in the past 7 days:

- PyOpenMS: PeptideAndProteinQuant.getPeptideResults/getProteinResults exposed (#8543)
- PyOpenMS BREAKING: zero-copy _mv methods renamed to _view (#8857)
- TOPP BREAKING: FeatureFinderMultiplex/MultiplexResolver parameter missed_cleavages renamed to max_nr_labelled_aas (#8911)
- TOPP: MaRaClusterAdapter annotates consensus spectra with native IDs and cluster metadata (#8864)
- TOPP: MetaboliteAdductDecharger adds multimer detection (#8888)
- OpenMS Library BREAKING: ChromatogramPeak::IntensityType changed double -> float (#8857)
- Build: CMake 4.x compat fix for Windows packaging (#8880)
- Build: Fix pyOpenMS dev build RPATH (#8892)
- Build: Correctly locate locally installed nanobind (#8874)

Co-authored-by: Copilot <[email protected]>
timosachsenberg pushed a commit that referenced this pull request Mar 17, 2026
Add missing changelog entries for changes merged in the past 7 days:

- PyOpenMS: PeptideAndProteinQuant.getPeptideResults/getProteinResults exposed (#8543)
- PyOpenMS BREAKING: zero-copy _mv methods renamed to _view (#8857)
- TOPP BREAKING: FeatureFinderMultiplex/MultiplexResolver parameter missed_cleavages renamed to max_nr_labelled_aas (#8911)
- TOPP: MaRaClusterAdapter annotates consensus spectra with native IDs and cluster metadata (#8864)
- TOPP: MetaboliteAdductDecharger adds multimer detection (#8888)
- OpenMS Library BREAKING: ChromatogramPeak::IntensityType changed double -> float (#8857)
- Build: CMake 4.x compat fix for Windows packaging (#8880)
- Build: Fix pyOpenMS dev build RPATH (#8892)
- Build: Correctly locate locally installed nanobind (#8874)

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.

Python tests failing with nanobind changes

2 participants