Compiling PyROOT from Anaconda3/Python 3.6

Dear Rooters,

I am trying to compile ROOT with the python support, python (version 3.6.1) being taken from an Anaconda3 installation.

I tried to compile it using both the classic configure/make/make install procedure and using cmake.

In both cases, the compilation failed at the very end (when linking the PyROOT.so). Here is below a short example of the message obtained [*].

Searching a bit the internet I found this:

But in this case, the missing symbols were found in the conda libs (so setting up a dedicated Python env or adding LDFLAGS make sense), and in my case they are from the PyROOT bindings. How could I be missing the symbols?

According to nm, the symbols I am missing are global symbols (checking against ROOT compiled with another python):

$ nm libPyROOT.so |grep PyType_IsSubtype
U PyType_IsSubtype

To give more information, digging into the bindings/pyroot directory, I found the failing command line [**]. But I still do not get what I am missing here… Any idea?

Thanks,

Cheers,

Sébastien

[*]:

/scratch/root/bindings/pyroot/src/MethodProxy.h:81: undefined reference to PyType_IsSubtype' CMakeFiles/PyROOT.dir/src/Utility.cxx.o: In function PyROOT::Utility::AddUsingToClass(_object*, char const*)’:
/scratch/root/bindings/pyroot/src/Utility.cxx:289: undefined reference to PyErr_Clear' CMakeFiles/PyROOT.dir/src/Utility.cxx.o: In function PyROOT::Utility::BuildTemplateName(_object*&, _object*, int)’:
/scratch/root/bindings/pyroot/src/Utility.cxx:421: undefined reference to PyUnicode_FromString' /scratch/root/bindings/pyroot/src/Utility.cxx:421: undefined reference to PyUnicode_AppendAndDel’
/scratch/root/bindings/pyroot/src/Utility.cxx:428: undefined reference to PyUnicode_Append' CMakeFiles/PyROOT.dir/src/Utility.cxx.o: In function PyROOT::Utility::InitProxy(_object*, _typeobject*, char const*)’:
/scratch/root/bindings/pyroot/src/Utility.cxx:470: undefined reference to PyType_Ready' /scratch/root/bindings/pyroot/src/Utility.cxx:475: undefined reference to PyModule_AddObject’
CMakeFiles/PyROOT.dir/src/Utility.cxx.o: In function `PyROOT::Utility::GetBuffer(_object*, char, int, void*&, bool)’:

[**] command in bindings/pyroot/CMakeFiles/PyROOT.dir/link.txt and objects are in the src/ directory:

/bin/c++ -fPIC -pipe -m64 -Wall -W -Woverloaded-virtual -fPIC -pthread -Wno-deprecated-declarations -DRHAVE_CONFIG -O2 -g -DNDEBUG -Wl,–no-undefined -shared -Wl, -rpath, -l/pbs/software/cl7/anaconda/anaconda3/lib/, -soname,libPyROOT.so -o …/…/lib/libPyROOT.so CMakeFiles/PyROOT.dir/GPyROOT.cxx.o CMakeFiles/PyROOT.dir/src/Adapters.cxx.o CMakeFiles/PyROOT.dir/src/ClassMethodHolder.cxx.o CMakeFiles/PyROOT.dir/src/ConstructorHolder.cxx.o CMakeFiles/PyROOT.dir/src/Converters.cxx.o CMakeFiles/PyROOT.dir/src/Executors.cxx.o CMakeFiles/PyROOT.dir/src/FunctionHolder.cxx.o CMakeFiles/PyROOT.dir/src/MemoryRegulator.cxx.o CMakeFiles/PyROOT.dir/src/MethodHolder.cxx.o CMakeFiles/PyROOT.dir/src/MethodProxy.cxx.o CMakeFiles/PyROOT.dir/src/ObjectProxy.cxx.o CMakeFiles/PyROOT.dir/src/PropertyProxy.cxx.o CMakeFiles/PyROOT.dir/src/PyBufferFactory.cxx.o CMakeFiles/PyROOT.dir/src/PyRootType.cxx.o CMakeFiles/PyROOT.dir/src/PyStrings.cxx.o CMakeFiles/PyROOT.dir/src/Pythonize.cxx.o CMakeFiles/PyROOT.dir/src/RootModule.cxx.o CMakeFiles/PyROOT.dir/src/RootWrapper.cxx.o CMakeFiles/PyROOT.dir/src/TCustomPyTypes.cxx.o CMakeFiles/PyROOT.dir/src/TPyClassGenerator.cxx.o CMakeFiles/PyROOT.dir/src/TPyDispatcher.cxx.o CMakeFiles/PyROOT.dir/src/TPyException.cxx.o CMakeFiles/PyROOT.dir/src/TPyFitFunction.cxx.o CMakeFiles/PyROOT.dir/src/TPyROOTApplication.cxx.o CMakeFiles/PyROOT.dir/src/TPyReturn.cxx.o CMakeFiles/PyROOT.dir/src/TPySelector.cxx.o CMakeFiles/PyROOT.dir/src/TPython.cxx.o CMakeFiles/PyROOT.dir/src/TRflxCallback.cxx.o CMakeFiles/PyROOT.dir/src/TSetItemHolder.cxx.o CMakeFiles/PyROOT.dir/src/TemplateProxy.cxx.o CMakeFiles/PyROOT.dir/src/Utility.cxx.o -Wl,-rpath,/scratch/gadrat/build_root_v5.34.36/lib: …/…/lib/libGraf3d.so …/…/lib/libGpad.so …/…/lib/libTree.so -lpython3 …/…/lib/libGraf.so …/…/lib/libHist.so …/…/lib/libMatrix.so …/…/lib/libNet.so …/…/lib/libRIO.so …/…/lib/libMathCore.so …/…/lib/libThread.so …/…/lib/libCore.so …/…/lib/libCint.so

Seb,

I do see a path to the directory holding (presumably) the libpython.so library against wich libPyROOT.so should be compiled, but I don’t see any -lpython3 (or -lpython3.6 or …) in your command.

-s

(also, I don’t remember when python-3 support was added to PyROOT, but ROOT-5.34.36 may be too early a release to have it. dunno.)

The linking with -lpython3 is right there in between libTree and libGraf …

However, there is on the contrary no path pointing to it …

Yes, you can use v5.34 with p3 (that’s why all those PyUnicode_XYZ symbols show up from PyROOT …), with some minor limitations (I forget the details): there were only one or two p3 users at the time, and I made things work for them, but not all of roottest.

However, you’d have to use a p3 that was concurrent in time with v5.34, which would be p3.2 or so. at best.

1 Like

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