Problem 2201

Summary: g4py installation error - Hep3Vector operator
Product: Environments Reporter: Ligia Diana Pinto de Almeida Amorim <LDianaAmorim>
Component: g4pyAssignee: Koichi Murakami <Koichi.Murakami>
Status: CLOSED FIXED    
Severity: normal CC: axelhuebl
Priority: P4    
Version: 2.0   
Hardware: Apple   
OS: Mac OS X   

Description Ligia Diana Pinto de Almeida Amorim 2019-11-13 20:13:27 CET
Hi,

I am new to Gean4 and trying to install the python interface of Geant4 (g4py) following instructions in (Geant4 GitLab)[https://gitlab.cern.ch/geant4/geant4/tree/master/environments/g4py].

Right now it seems that I can install Geant4 successfully, but not g4py.
When I reach the `make` phase of the installation of g4py, I get the error messages posted below.

I was wondering if you encountered these issues before or if you had any suggestion on how to fix them.
From the very first error message, it seems that the error comes from the definition of the operator of `Hep3Vector` from the `CLHEP` class.

I include below the environment and commands I used to (attempt to) install Geant4 and g4py.

Me and my colleague Axel Hübl (axelhuebl@lbl.gov) are further trying to make this recipe available by the package management `spack` in the PR:
https://github.com/spack/spack/pull/13639
but are also facing the same issues there and would appreciate your input on it.

Thank you in advance for all your help with this,
Diana

*Environment:*
- MacOS High Sierra
- clang 10.0.0
- conda 4.7.12
- cmake 3.15.5
- XQuartz 2.7.11
- python 3.7.5
- boost 1.67.0 
- xerces-c 3.2.2

*Installation log:*
1) ROOT
cd ~/Documents/opt
git clone https://github.com/root-project/root.git
cd root
mkdir build
cd build
cmake ..
make -j 4
source ~/Documents/opt/root/build/bin/thisroot.sh

2) BOOST and XercesC
conda install -c conda-forge boost
conda install -c conda-forge xerces-c

3) Geant4
git clone https://gitlab.cern.ch/geant4/geant4.git
cd geant4
mkdir build
cd build
cmake  -DGEANT4_USE_OPENGL_X11=ON $GEANT4_BUILD
make -j 4
make install

Initially when installing Geant4 itself, I was introducing an install path in the `cmake` command through `-DCMAKE_INSTALL_PREFIX=$GEANT4_INSTALL` (after setting the directory for `$GEANT4_INSTALL`). But this led to an error as the correct boost/python.hpp file would not be created.

4) g4py
cd ../environments/g4py/
mkdir build
cd build
cmake ..
make -j 4
(error occurred)


*Error Messages:*

```bash
In file included from /anaconda3/include/boost/preprocessor/iteration/detail/iter/forward1.hpp:47:
/anaconda3/include/boost/python/detail/invoke.hpp:86:12: error: type 'const boost::python::detail::reference_existing_object_requires_a_pointer_or_reference_return_type<const
     CLHEP::Hep3Vector>' does not provide a call operator
   return rc( (tc().*f)(BOOST_PP_ENUM_BINARY_PARAMS_Z(1, N, ac, () BOOST_PP_INTERCEPT)) );
          ^~
/anaconda3/include/boost/python/detail/caller.hpp:216:40: note: in instantiation of function template specialization
     'boost::python::detail::invoke<boost::python::detail::reference_existing_object_requires_a_pointer_or_reference_return_type<const CLHEP::Hep3Vector>, const
     CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const, boost::python::arg_from_python<G4VPhysicalVolume &> >' requested here
           PyObject* result = detail::invoke(
                                      ^
/anaconda3/include/boost/python/object/py_function.hpp:38:16: note: in instantiation of member function 'boost::python::detail::caller_arity<1>::impl<const CLHEP::Hep3Vector
     (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector,
     G4VPhysicalVolume &> >::operator()' requested here
       return m_caller(args, kw);
              ^
/anaconda3/include/boost/python/object/py_function.hpp:32:5: note: in instantiation of member function
     'boost::python::objects::caller_py_function_impl<boost::python::detail::caller<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> > >::operator()'
     requested here
   caller_py_function_impl(Caller const& caller)
   ^
/anaconda3/include/boost/python/object/py_function.hpp:124:22: note: in instantiation of member function
     'boost::python::objects::caller_py_function_impl<boost::python::detail::caller<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> >
::caller_py_function_impl' requested here
       : m_impl(new caller_py_function_impl<Caller>(caller))
                    ^
/anaconda3/include/boost/python/make_function.hpp:61:11: note: in instantiation of function template specialization
     'boost::python::objects::py_function::py_function<boost::python::detail::caller<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> > >' requested here
         detail::caller<F,CallPolicies,Sig>(f, p)
         ^
/anaconda3/include/boost/python/make_function.hpp:140:20: note: in instantiation of function template specialization 'boost::python::detail::make_function_aux<const
     CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const
     CLHEP::Hep3Vector, G4VPhysicalVolume &>, mpl_::int_<0> >' requested here
   return detail::make_function_aux(
                  ^
/anaconda3/include/boost/python/class.hpp:493:13: note: in instantiation of function template specialization 'boost::python::make_function<const CLHEP::Hep3Vector
     (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::python::detail::keywords<0>,
     boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> >' requested here
         , make_function(
           ^
/anaconda3/include/boost/python/class.hpp:562:15: note: in instantiation of function template specialization 'boost::python::class_<G4VPhysicalVolume, G4VPhysicalVolume *,
     boost::noncopyable_::noncopyable, boost::python::detail::not_specified>::def_impl<G4VPhysicalVolume, const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::detail::def_helper<boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::python::detail::not_specified,
     boost::python::detail::not_specified, boost::python::detail::not_specified> >' requested here
       this->def_impl(
             ^
/anaconda3/include/boost/python/class.hpp:240:15: note: in instantiation of function template specialization 'boost::python::class_<G4VPhysicalVolume, G4VPhysicalVolume *,
     boost::noncopyable_::noncopyable, boost::python::detail::not_specified>::def_maybe_overloads<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies> >' requested here
       this->def_maybe_overloads(name, a1, a2, &a2);
             ^
/Users/diana/Documents/opt/geant4/environments/g4py/source/geometry/pyG4VPhysicalVolume.cc:63:6: note: in instantiation of function template specialization
     'boost::python::class_<G4VPhysicalVolume, G4VPhysicalVolume *, boost::noncopyable_::noncopyable, boost::python::detail::not_specified>::def<const CLHEP::Hep3Vector
     (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies> >' requested here
   .def("GetTranslation",       &G4VPhysicalVolume::GetTranslation,
    ^
In file included from /Users/diana/Documents/opt/geant4/environments/g4py/source/geometry/pyG4VPhysicalVolume.cc:31:
In file included from /anaconda3/include/boost/python.hpp:11:
In file included from /anaconda3/include/boost/python/args.hpp:22:
In file included from /anaconda3/include/boost/python/object_core.hpp:14:
In file included from /anaconda3/include/boost/python/call.hpp:15:
In file included from /anaconda3/include/boost/python/converter/arg_to_python.hpp:19:
In file included from /anaconda3/include/boost/python/object/function_handle.hpp:8:
/anaconda3/include/boost/python/detail/caller.hpp:100:98: error: no member named 'get_pytype' in
     'boost::python::detail::reference_existing_object_requires_a_pointer_or_reference_return_type<const CLHEP::Hep3Vector>'
       return create_result_converter((PyObject*)0, (ResultConverter *)0, (ResultConverter *)0).get_pytype();
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/anaconda3/include/boost/python/detail/caller.hpp:238:69: note: in instantiation of member function
     'boost::python::detail::converter_target_type<boost::python::detail::reference_existing_object_requires_a_pointer_or_reference_return_type<const CLHEP::Hep3Vector>
::get_pytype' requested here
               , &detail::converter_target_type<result_converter>::get_pytype
                                                                   ^
/anaconda3/include/boost/python/object/py_function.hpp:48:25: note: in instantiation of member function 'boost::python::detail::caller_arity<1>::impl<const CLHEP::Hep3Vector
     (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector,
     G4VPhysicalVolume &> >::signature' requested here
       return m_caller.signature();
                       ^
/anaconda3/include/boost/python/object/py_function.hpp:32:5: note: in instantiation of member function
     'boost::python::objects::caller_py_function_impl<boost::python::detail::caller<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> > >::signature'
     requested here
   caller_py_function_impl(Caller const& caller)
   ^
/anaconda3/include/boost/python/object/py_function.hpp:124:22: note: in instantiation of member function
     'boost::python::objects::caller_py_function_impl<boost::python::detail::caller<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> >
::caller_py_function_impl' requested here
       : m_impl(new caller_py_function_impl<Caller>(caller))
                    ^
/anaconda3/include/boost/python/make_function.hpp:61:11: note: in instantiation of function template specialization
     'boost::python::objects::py_function::py_function<boost::python::detail::caller<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> > >' requested here
         detail::caller<F,CallPolicies,Sig>(f, p)
         ^
/anaconda3/include/boost/python/make_function.hpp:140:20: note: in instantiation of function template specialization 'boost::python::detail::make_function_aux<const
     CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::mpl::vector2<const
     CLHEP::Hep3Vector, G4VPhysicalVolume &>, mpl_::int_<0> >' requested here
   return detail::make_function_aux(
                  ^
/anaconda3/include/boost/python/class.hpp:493:13: note: in instantiation of function template specialization 'boost::python::make_function<const CLHEP::Hep3Vector
     (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::python::detail::keywords<0>,
     boost::mpl::vector2<const CLHEP::Hep3Vector, G4VPhysicalVolume &> >' requested here
         , make_function(
           ^
/anaconda3/include/boost/python/class.hpp:562:15: note: in instantiation of function template specialization 'boost::python::class_<G4VPhysicalVolume, G4VPhysicalVolume *,
     boost::noncopyable_::noncopyable, boost::python::detail::not_specified>::def_impl<G4VPhysicalVolume, const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::detail::def_helper<boost::python::return_internal_reference<1, boost::python::default_call_policies>, boost::python::detail::not_specified,
     boost::python::detail::not_specified, boost::python::detail::not_specified> >' requested here
       this->def_impl(
             ^
/anaconda3/include/boost/python/class.hpp:240:15: note: in instantiation of function template specialization 'boost::python::class_<G4VPhysicalVolume, G4VPhysicalVolume *,
     boost::noncopyable_::noncopyable, boost::python::detail::not_specified>::def_maybe_overloads<const CLHEP::Hep3Vector (G4VPhysicalVolume::*)() const,
     boost::python::return_internal_reference<1, boost::python::default_call_policies> >' requested here
       this->def_maybe_overloads(name, a1, a2, &a2);
             ^
/Users/diana/Documents/opt/geant4/environments/g4py/source/geometry/pyG4VPhysicalVolume.cc:63:6: note: in instantiation of function template specialization
     'boost::python::class_<G4VPhysicalVolume, G4VPhysicalVolume *, boost::noncopyable_::noncopyable, boost::python::detail::not_specified>::def<const CLHEP::Hep3Vector
     (G4VPhysicalVolume::*)() const, boost::python::return_internal_reference<1, boost::python::default_call_policies> >' requested here
   .def("GetTranslation",       &G4VPhysicalVolume::GetTranslation,
    ^
2 errors generated.
make[2]: *** [source/geometry/CMakeFiles/pyG4geometry.dir/pyG4VPhysicalVolume.cc.o] Error 1
make[1]: *** [source/geometry/CMakeFiles/pyG4geometry.dir/all] Error 2
make: *** [all] Error 2
```