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
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/sft-nightlies.cern.ch/lcg/nightlies/dev3/Tue/ROOT/v6-22-00-patches/x86_64-centos7-gcc9-opt/cmake/ROOTConfig.cmake:159 (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 ?
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?
For example https://github.com/OstapHEP/ostap/blob/master/source/CMakeROOT_6_14.cmake#L5: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
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,
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
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).