Error with python.hpp for MacOS (clang/anaconda3)

I am new to Geant4 and wish to install its python G4py version. I tried to follow the instructions that I found online for installing both on MacOS High Sierra (clang and anaconda3).
However, I came across an issue when I <make> G4py, which starts with:

[  0%] Building CXX object source/intercoms/CMakeFiles/pyG4intercoms.dir/
/Users/diana/Documents/opt/geant4/environments/g4py/source/intercoms/  fatal errorfatal error: : 'boost/python.hpp' file not found
'boost/python.hpp' file not found
#include <boost/python.hpp>
#include <boost/python.hpp>
1 error generated.
make[2]: *** [source/intercoms/CMakeFiles/pyG4intercoms.dir/] Error 1

Attached is a text file with the commands I used to install all the dependencies for Geant4 and G4py Install_log.txt (1.4 KB)

Have you ever encountered this issue before? Do you have any recommendation on how to fix it?
Thank you for your time and sorry in advance in case I missed this issue being reported elsewhere,

Don’t have much experience with this part of geant4 but some things to investigate:

  • In the cmake command you use “Boost” for the include directory and “BOOST” for all the others is this correct?
  • If you go to the location of $BOOST_DIR/include can you see the python.hpp file?
  • Running make VERBOSE=1 will show you the full compiler command and you can see what values are actually being used for the include location.

Thank you for your reply.

  • Yes, in the cmake command used to compile g4py I used “Boost” for the include directory and “BOOST” for the root and lib directories:
  • There are python.hpp files in $BOOST_DIR/include/boost/mpi/python.hpp and $BOOST_DIR/include/boost/parameter/python.hpp. Should I copy one of them directly to $BOOST_DIR/include?

  • Thank you for the suggestion of using verbose, it really helps to see where make is looking for the file (which I think is $BOOST_DIR/include only and not its sub-directories mpi or parameter).

Do you think that the absence of a python.hpp file in the $BOOST_DIR/include directory mean that the Geant4 installation was not successful?

The file /anaconda3/share/cmake-3.15/Modules/FindBoost.cmake is looking for the python.hpp file in $Boost_INCLUDE_DIR/boost.
I tried to change it to point to the mpi directory location by changing line 1619 to:
set(_Boost_PYTHON_HEADERS "boost/mpi/python.hpp")
But I still get the same error.

It looks like your conda install of boost may be missing a file, or you need an additional package that provides the necessary file. I used my systems package mananger to do a full install of boost and see the following instances of a python.hpp file

$ locate "/python.hpp"
$ ll /usr/include/boost/mpi/python.hpp /usr/include/boost/parameter/python.hpp /usr/include/boost/python.hpp
-rw-r--r-- 1 root root  2803 Feb  4  2019 /usr/include/boost/mpi/python.hpp
-rw-r--r-- 1 root root 19092 Feb  4  2019 /usr/include/boost/parameter/python.hpp
-rw-r--r-- 1 root root  2950 Feb  4  2019 /usr/include/boost/python.hpp

They are all different sizes so I don’t think copying one of the ones you currently have into $BOOST_DIR/include will work.

This will not solve what is currently going wrong, but you could try installing boost globally on you system then rerunning the cmake command without any of the boost options.

What is the output of the cmake command? Does it recognise that you have boost installed? I get the following:

$ cmake -DCMAKE_INSTALL_PREFIX=$GEANT4_INSTALL/g4py  ../../geant4/environments/g4py/
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Geant4: /usr/local/share/geant4/10.5.1/install/debug/bin/.. (10.5.1)
-- Found PythonInterp: /usr/bin/python (found version "2.7.16") 
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/ (found version "2.7.16") 
-- Boost version: 1.67.0
-- Found XercesC: /usr/lib/x86_64-linux-gnu/  
-- NOT Found ROOT.
-- --------------------------------------------------------
-- Parameters for building
-- CMAKE_CXX_COMPILER: /usr/bin/c++
-- CMAKE_INSTALL_PREFIX: /usr/local/share/geant4/10.5.1/install/debug/g4py
-- --------------------------------------------------------
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/local/share/geant4/10.5.1/g4py_build

and this compiles.