Cmake error when trying to compile ROOT with Python 3 support


ROOT Version: 6-20-04
Platform: Scientific Linux 6.10 x86_64
Compiler: gcc (GCC) 6.3.1 20170216 (Red Hat 6.3.1-3)
Python: Python 3.5.7


Hello!
I am trying to compile ROOT in a cluster computing server where I have no root access (pun not intended).

I already succeeded in compiling ROOT without Python support but now I need it so I am recompiling.
There is an error during the CMake configuration step that I was not able to solve. It might even be a bug but I still do not know for sure.

I have compiled Python 3 from source and it is working fine (tested). So now I would like to point ROOT to this custom Python installation.

I have already made sure that the python command redirects to the custom python

$ python --version
Python 3.5.7
$ which python
~/python-3.5.7/bin/python

Moreover, I am passing all the relevant options to CMake

$ source scl_source enable devtoolset-6
$ export ROOTVERS=6-20-04
$ export ROOTSYS=$HOME/ROOT
$ export PATH=/home/nu/giorgio/python-3.5.7/bin:$PATH
$ export PYTHONHOME=/home/nu/giorgio/python-3.5.7
$ export LD_LIBRARY_PATH=/home/nu/giorgio/python-3.5.7/lib:$LD_LIBRARY_PATH

$ cmake -Dbuiltin_xrootd=ON \
  -Dminuit2=On \
  -DCMAKE_INSTALL_PREFIX="${ROOTSYS}/${ROOTVERS}" \
  -DCMAKE_C_COMPILER=$(which gcc) \
  -DCMAKE_CXX_COMPILER=$(which g++) \
  -Dsqlite=OFF \
  -Dpython3=ON \
  -DPYTHON_EXECUTABLE=$(which python3.5) \
  -DPYTHON_INCLUDE_DIR=$HOME/python-3.5.7/include/python3.5m \
  -DPYTHON_LIBRARY=$HOME/python-3.5.7/lib/libpython3.5m.a \
  -Dfortran=ON \
  ../sources

The error is:

-- Enabled support for:  asimage builtin_afterimage builtin_clang builtin_ftgl builtin_gl2ps builtin_glew builtin_llvm builtin_lz4 builtin_lzma builtin_pcre builtin_tbb builtin_vdt builtin_xrootd builtin_xxhash builtin_zstd clad dataframe exceptions fftw3 fortran gdml http imt mathmore mlp minuit2 mysql opengl pgsql python roofit runtime_cxxmodules shared ssl tmva tmva-cpu spectrum vdt x11 xml xrootd
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
/home/nu/giorgio/ROOT/sources/bindings/pyroot/_Python_INCLUDE_DIR
   used as include directory in directory /home/nu/giorgio/ROOT/sources/bindings/pyroot

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

You can find the full log here: https://pastebin.com/QpHX9sqK

What should I do?
Thanks

@maxgalli can you please verify that it works for 6.20 branch? Thank you so much!

Hi Giorgio, can you try to change these lines

-DPYTHON_INCLUDE_DIR=$HOME/python-3.5.7/include/python3.5m
-DPYTHON_LIBRARY=$HOME/python-3.5.7/lib/libpython3.5m.a \

to

-DPYTHON_INCLUDE_DIRS=$HOME/python-3.5.7/include/python3.5m
-DPYTHON_LIBRARIES=$HOME/python-3.5.7/lib/libpython3.5m.a \

1 Like

I am currently trying to build the branch v6.20.04. Do you mean another branch?

VERSION="v6-20-00-patches"; git clone -b ${VERSION} http://github.com/root-project/root.git ${VERSION}

This has been removed a long time ago. Please use only -Dpython=ON when configuring, although that is already the default (in current master that is now called -Dpyroot=ON though). Also, you might have better luck with -DCMAKE_PREFIX_PATH=$HOME/python-3.5.7 instead of setting other variables. It’s also recommended to only set PYTHON_EXECUTABLE and leave the library and include paths for CMake to figure out. Another thing is that you are trying to use a static library for python and that likely won’t work with ROOT. You need to recompile your Python with --enable-shared or similar to use it with ROOT. You should make sure to use the same GCC for ROOT and your custom Python as well, just in case.

BTW, if you have no network, you should add -Dimt=OFF, otherwise ROOT will try to download TBB by default. Same for the xrootd option (which may require network to download the bultin xrootd).

I have recompiled Python enabling the shared libraries and that did the trick.
To be a little more future-proof, this time I have chosen Python 3.8.2 because Python 3.5 is close to EOL.
I can now build PyROOT in both the branches v6-20-00-patches and v6-20-04. By the way, is there any reason to prefer v6-20-00-patches over v6-20-04?
Just as @amadio suggested, I have only specified the PYTHON_EXECUTABLE and let cmake figure out the rest.
Thank you very much for your help.

On an unrelated subject, there was an error about VDT during compilation, so I had to build ROOT with -Dvdt=OFF. The error was something like:

CMake No SOURCES given to target VDT

This was on both branches. Is VDT an essential component of ROOT?

No, vdt is not required. It adds some better performing math functions that will be used if available by RooFit and others. However, you might get rid of the error by updating CMake.

I do not think that the problem is Cmake because I am using Cmake 3.17.2 (latest version) … or maybe ROOT is calling another version of cmake present on the system internally …

Not sure, but libraries with no sources were a problem in older versions of CMake. Maybe you need to use external VDT if you use builtin_vdt. But just disabling it will probably cause no harm to you if you’re not using it directly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.