SIRF-SuperBuild icon indicating copy to clipboard operation
SIRF-SuperBuild copied to clipboard

Updated modules in find_package command for Python3

Open NicoleJurjew opened this issue 1 year ago • 5 comments

NicoleJurjew avatar Oct 02 '24 16:10 NicoleJurjew

https://cmake.org/cmake/help/latest/module/FindPythonInterp.html deprecated since 3.12, while we require 3.16.2.

Current change is minimal. We probably should pass Python_EXECUTABLE as opposed to PYTHON_EXECUTABLE to dependencies, but this needs a check which ones we use. Probably easiest to pass both. I think we should no longer attempt to pass include and other paths, and let CMake sort it out.

KrisThielemans avatar Oct 03 '24 08:10 KrisThielemans

Need to update how we look for cython I guess

[100%] Generating build/timestamp
Traceback (most recent call last):
  File "/home/runner/work/SIRF-SuperBuild/SIRF-SuperBuild/build/builds/TomoPhantom/build/Wrappers/Python/setup.py", line 19, in <module>
    from Cython.Distutils import build_ext
ModuleNotFoundError: No module named 'Cython'
gmake[5]: *** [Wrappers/Python/CMakeFiles/PythonWrapper.dir/build.make:76: Wrappers/Python/build/timestamp] Error 1
gmake[4]: *** [CMakeFiles/Makefile2:157: Wrappers/Python/CMakeFiles/PythonWrapper.dir/all] Error 2
gmake[3]: *** [Makefile:136: all] Error 2
gmake[2]: *** [CMakeFiles/TomoPhantom.dir/build.make:86: builds/TomoPhantom/stamp/TomoPhantom-build] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:755: CMakeFiles/TomoPhantom.dir/all] Error 2

This error is different from why I saw in #932 but it's possible that @NicoleJurjew only saw the Tomophantom error when using this branch I guess.

KrisThielemans avatar Oct 03 '24 09:10 KrisThielemans

With the suggested changes, the PYTHONPATH isn't exported correctly.

I think some changes need to be done here, as well: https://github.com/SyneRBI/SIRF-SuperBuild/blob/5f1a7f498bf6f41551c19eb53798b5d33af43eec/SuperBuild.cmake#L366C1-L386C8

NicoleJurjew avatar Oct 03 '24 14:10 NicoleJurjew

that's a bit strange. What is the content of env_sirf.sh etc then? Can you just do a

message(STATUS "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")

before those statement to check what it is?

KrisThielemans avatar Oct 04 '24 09:10 KrisThielemans

This is the content of env_sirf.sh: grafik

Where will that message be written to then? Thanks!

NicoleJurjew avatar Oct 04 '24 10:10 NicoleJurjew

  • See also #313

paskino avatar Feb 13 '25 10:02 paskino

Looks like a gadgetron build error related to https://groups.google.com/g/linux.debian.bugs.dist/c/JpHAw3GY0Bk

casperdcl avatar Mar 20 '25 14:03 casperdcl

This was all discussed in #937. I've contributed a PR to Gadgetron. However, moving on with Gadgetron created a lot of other problems. So @paskino and I decided to wait with that, and just fix Ubuntu 22.04. This is done in #943. So suggestion therefore is to finish #943, merge it, and merge that back on here.

KrisThielemans avatar Mar 20 '25 15:03 KrisThielemans

@casperdcl I've merged #943.

Note that we'll also need to update CHANGES.md here.

KrisThielemans avatar Mar 21 '25 09:03 KrisThielemans

There seem to be 2 different Python versions used in the CIL install, resulting in the cil not being found at import. There are 2 causes for this.

For the SB, CMake finds a surprising version (which is then passed on)

Found Python: /opt/hostedtoolcache/Python/3.10.12/x64/bin/python3.10 (found version "3.10.12") found components: Interpreter Development Development.Module Development.Embed
Found Python_EXECUTABLE=/opt/hostedtoolcache/Python/3.10.12/x64/bin/python3.10

The CMake strategy for selecting a python version is still far too complicated/error-prone. I suggest therefore to explicitly set Python_EXECUTABLE=${which python} in the Action.

In addition, it looks like the CIL version that is being built (I only checked with DEVEL_BUILD=OFF) uses old-style:

-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so (found version "3.10.12")
-- Found PYTHON_EXECUTABLE=/home/runner/virtualenv/bin/python

I think therefore we need to add PYTHON_EXECUTABLE to the PYTHONLIBS_CMAKE_ARGS variable. That's safest in any case.

KrisThielemans avatar Mar 21 '25 12:03 KrisThielemans

ModuleNotFoundError: No module named 'Cython'

when building TomoPhantom. Not sure why this happens now? Wrong python used? TBH, We shouldn't really build TomoPhantom as part of our CI I think. @paskino ?

Run actions/upload-artifact@v4
  with:
    name: build_log_files-ubuntu-22.04-gcc9-Release-DEVEL=OFF
...
Error: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run

I guess we have a problem with the naming somewhere.

KrisThielemans avatar Mar 21 '25 18:03 KrisThielemans

TomoPhantom v2.0.0 (and also the slightly more recent v3.0) doesn't specify build deps. Its setup.py needs Cython & numpy. Adding them to the build step works.

Current test failures due to lack of CIL deps... CIL:scripts/requirements-test.yml are not included in CIL:pyproject.toml and I think they should be. I've opened https://github.com/TomographicImaging/CIL/issues/2116

casperdcl avatar Mar 24 '25 12:03 casperdcl

For the SB, CMake finds a surprising version (which is then passed on)

Found Python: /opt/hostedtoolcache/Python/3.10.12/x64/bin/python3.10 (found version "3.10.12") found components: Interpreter Development Development.Module Development.Embed
Found Python_EXECUTABLE=/opt/hostedtoolcache/Python/3.10.12/x64/bin/python3.10

The CMake strategy for selecting a python version is still far too complicated/error-prone. I suggest therefore to explicitly set Python_EXECUTABLE=${which python} in the Action.

This is still the case, hence the failures.

KrisThielemans avatar Mar 24 '25 18:03 KrisThielemans

Ah I finally understood; you don't want to use the system Python.

TL;DR we need to unset the cmake helpers defined by actions/setup-python.

casperdcl avatar Mar 25 '25 12:03 casperdcl

Ah I finally understood; you don't want to use the system Python.

TL;DR we need to unset the cmake helpers defined by actions/setup-python.

pretty confusing... I don't care which python is being used here, but obviously we should always use the same. As we seem to be using setup-python with pip, and then create a venv, we should be using that one. I guess that's what you did now, so ... great.

Sadly, some zenodo download issues ATM.

KrisThielemans avatar Mar 25 '25 12:03 KrisThielemans

Success! Thanks @casperdcl . however, can you now have a different PR to update CHANGES.md, saying that we've switched to FindPython (maybe a link), and that they should use Python_EXECUTABLE or any other variables as indicated in the CMake doc? (Sorry, I shouldn't have approved the PR :-))

KrisThielemans avatar Mar 25 '25 17:03 KrisThielemans

Already updated the changelog; feel free to update further

casperdcl avatar Mar 25 '25 18:03 casperdcl

Sorry. Confused. Which changelog?

KrisThielemans avatar Mar 25 '25 19:03 KrisThielemans

https://github.com/SyneRBI/SIRF-SuperBuild/blob/master/CHANGES.md

casperdcl avatar Mar 25 '25 19:03 casperdcl