CMake: ROOT component PyROOT is not found

I have a python/C++ project that depends on ROOT and uses PyROOT. CMake is ised to configure, build and install.
Currently the version of ROOT is 6.20, and everythnig is fine - I am able to buid my library, ictionary and run the project with no problems.
As a kind of test I’ve just tried to use ROOT from LCG–nightlies build form cvmfs

source  /cvmfs/$CMTCONFIG/

It used ROOT version

root.exe --version

 ROOT Version: 6.22/01   
 Built for linuxx8664gcc on Jun 16 2020, 02:33:00
 From heads/v6-22-00-patches@v6-22-00-9-g0d3d449

And when I try to configure/build my project, CMake complains in PyROOT component:

cmake … -GNinja

CMake Error at /cvmfs/ (message):
ROOT component PyROOT not found

Does it mean that something is changed in CMake structure/configuration for ROOT?
Is there documentation and/or examples how CMake-fiels shoudl be updated for the projects that use ROOT ?

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

@oshadura should be able to help here.


Yes. there are multiple changes especially in PyROOT build system, starting from ROOT 6.22, there are two different PyROOT shipped with ROOT (for both Python 2 and Python 3) (cc @etejedor )
Can you please give an example of how are you using ROOT in your build system of your project?


More details here:

Dear Oksana,

For my project I use the following CMakeList.txt,

that in turn includes this one (the actual worker)

and this configuration works for all ROOT versions including 6.20 and it breaks for 6.22

(I am sorry - the example is a bit too complicated - but it includes C++ code, that uses ROOT and python and PyROOT)

cheers, Vanya

Hi Vanya,

For example find_package(ROOT 6 CONFIG REQUIRED COMPONENTS Smatrix Core MathCore MathMore Minuit2 GenVector Hist Matrix RIO TMVA Tree Thread TreePlayer RooFit RooFitCore PyROOT), we don’t have anymore component PyROOT but instead you need to use cppyy_backend2_7 cppyy2_7 ROOTPythonizations2_7 ROOTTPython JupyROOT2_7

Here: instead of ROOT::PyROOT should be used ROOT::cppyy_backend2_7 ROOT::cppyy2_7 ROOT::ROOTPythonizations2_7 ROOT::ROOTTPython ROOT::JupyROOT2_7

You only need ROOT::ROOTPythonizations2_7 / ROOT::ROOTPythonizations3_x. We should be able to wrap cppyy_backend2_7 cppyy2_7 ROOTPythonizations2_7 into a component called ROOT::PyROOT2 (as an alias for ROOT::ROOTPythonizations2_7), same for ROOT::PyROOT3. Along these lines we should “rename” root-config's --python-version to --python2-version and --python3-version. If only one of python2 or python3 is available, we could make --python-version print that, instead of erroring out.

Btw, I could imagine a future where LCG builds have both python2 and python3 “libraries”.

Dear Oksana,
Thank you very much.
what is the list of targets for python3?
currently i use separate builds for python2 and python3.
am I right that new system allows to have a kind of “multypython” build?
cheers, Vanya

Dear Axel,
thank you very much!
cheers, Vanya

Dear Axel,
am I right that now CMake logic for clinent project is

  • find python, and depending of available python versions load “pyroot-2” or “pyroot-3” set of targets from ROOT ?
    (previosly I used the opposite logic - findroot, check python version via the root-config and then find python
    cheers, Vanya

@ibelyaev yes now ROOT supports both builds: python2 and python3 at the same time.

I opened PR that will help you to have two new components PyROOT2 and PyROOT3 to search for both ROOT components and add dependencies.

I also added special output for python2/python3:

 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ●  root-config --python-version
It is a multi-python build, please check --python2-version or --python3-version output
 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ●  root-config --python2-version
 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ●  root-config --python3-version
 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ● 

It will help you to use the same logic you used before.

(cc: @etejedor @Axel)

Why can’t “root-config --python-version” simply return the “2.7.18 3.8.3” string with two versions, which would also be easy to “parse”?

Dear Oksana,
thank you very much!
cheers, Vanya

because it will break user scripts?

User’s scripts will anyhow need to be modified.
The old ROOT versions do not provide “--python2-version” nor “--python3-version”.
If “--python-version” returns both versions (ordered, first any 2.x then any 3.x) then the required modifications would be trivial, try e.g.:
P="2.7.18 3.8.3"; echo "${P%% *}"; echo "${P##* }"
If a user is just interested in python2, instead of “${P}” one just needs to use “${P%% *}”.
If a user is just interested in python3, instead of “${P}” one just needs to use “${P##* }”.
This trivial modification will make the script work in any ROOT version, also in any old one (in which “--python-version” returns just one python version, if any).

Hi Vanya,

Update, we merged PR fixing output of --python-version and adding new meta-targets easier build PyROOT related targets.

Final result is:

 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ●  root-config --python-version
 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ●  root-config --python2-version
 oksana@oksana-dellxps  ~/CERN_sources/root/builds   fix-python-output ●  root-config --python3-version

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