From 07f981ba25de72082b08d05e0e111d780560043f Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Thu, 13 Aug 2026 18:34:06 +0200 Subject: [PATCH] drop pip cmake from the pytorch base * Install cmake via apt and uninstall the pip package. Its shims in /usr/local/bin shadow /usr/bin/cmake, and they fail with ModuleNotFoundError when a build calls them from inside a pip build isolation environment -- which is why `pip install cellplm` could not build louvain. * Add a test checking that cmake, cpack and ctest resolve to /usr/bin * Bump the version to 1.2.0 --- base_images/CHANGELOG.md | 14 +++++++ base_images/_viash.yaml | 2 +- .../src/pytorch_nvidia/config.vsh.yaml | 8 ++++ base_images/src/pytorch_nvidia/test_cmake.py | 40 +++++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 base_images/src/pytorch_nvidia/test_cmake.py diff --git a/base_images/CHANGELOG.md b/base_images/CHANGELOG.md index 9d777bc..fa3bc04 100644 --- a/base_images/CHANGELOG.md +++ b/base_images/CHANGELOG.md @@ -1,3 +1,17 @@ +# OpenProblems Base Images v1.2.0 + +## BUG FIXES + +* `base_pytorch_nvidia`: drop the pip-installed `cmake` in favour of apt's (PR #48). The pip + shims in `/usr/local/bin` shadow `/usr/bin/cmake`, and they fail with `ModuleNotFoundError: + No module named 'cmake'` when a build calls them from inside a pip build isolation + environment -- which broke, among others, building `louvain` for `cellplm`. + +## TESTING + +* Check that `cmake`, `cpack` and `ctest` resolve to the apt-provided binaries in + `base_pytorch_nvidia` (PR #48). + # OpenProblems Base Images v1.1.0 ## MAJOR CHANGES diff --git a/base_images/_viash.yaml b/base_images/_viash.yaml index 8814033..6626333 100644 --- a/base_images/_viash.yaml +++ b/base_images/_viash.yaml @@ -1,5 +1,5 @@ organization: openproblems -version: 1.1.0 +version: 1.2.0 viash_version: 0.9.7 links: repository: https://github.com/openproblems-bio/base_images diff --git a/base_images/src/pytorch_nvidia/config.vsh.yaml b/base_images/src/pytorch_nvidia/config.vsh.yaml index 4290886..6009ccd 100644 --- a/base_images/src/pytorch_nvidia/config.vsh.yaml +++ b/base_images/src/pytorch_nvidia/config.vsh.yaml @@ -3,6 +3,8 @@ description: An nvcr.io pytorch with anndata preinstalled. test_resources: - type: python_script path: test_pytorch.py + - type: python_script + path: test_cmake.py - type: python_script path: ../python/test_anndata.py engines: @@ -13,6 +15,12 @@ engines: packages: - procps - git + - cmake + # The nvcr image pip-installs cmake, whose shims in /usr/local/bin shadow + # apt's cmake because /usr/local/bin comes first on PATH. Drop the package + # so builds pick up the working /usr/bin/cmake instead. + - type: docker + run: pip uninstall -y cmake - type: python packages: - anndata~=0.12.0 diff --git a/base_images/src/pytorch_nvidia/test_cmake.py b/base_images/src/pytorch_nvidia/test_cmake.py new file mode 100644 index 0000000..8ff0d38 --- /dev/null +++ b/base_images/src/pytorch_nvidia/test_cmake.py @@ -0,0 +1,40 @@ +import shutil +import subprocess +import tempfile + +## VIASH START +meta = { + "temp_dir": tempfile.gettempdir(), +} +## VIASH END + +# The nvcr pytorch image ships a pip-installed cmake whose shims land in +# /usr/local/bin and shadow apt's cmake. If a base image rebuild ever +# reintroduces them, components that compile from source break in confusing +# ways, so check that cmake resolves to the apt-provided binary and runs. +print("--- Checking cmake ---", flush=True) + +cmake = shutil.which("cmake") +print(f"cmake resolves to: {cmake}", flush=True) + +assert cmake is not None, "cmake not found on PATH" +assert cmake == "/usr/bin/cmake", ( + f"expected apt's /usr/bin/cmake on PATH, got {cmake} -- a pip-installed " + "cmake is probably shadowing it" +) + +out = subprocess.run([cmake, "--version"], capture_output=True, text=True) +print(out.stdout.strip(), flush=True) + +assert out.returncode == 0, f"`cmake --version` exited {out.returncode}: {out.stderr.strip()}" + +# The pip package ships cpack and ctest alongside cmake; removing only the +# cmake shim would leave those two broken. +for tool in ["cpack", "ctest"]: + path = shutil.which(tool) + print(f"{tool} resolves to: {path}", flush=True) + assert path is None or path.startswith("/usr/bin/"), ( + f"{tool} resolves to {path}, expected /usr/bin/{tool} or nothing" + ) + +print("\ncmake test passed!", flush=True)