How To Install G4 Python Environment for Mac (g4py)

Sorry, got side tracked with meetings and ran into a few issues with the build. Still WIP, but will update when ready!

Hi @bmorgan,

Any update on the g4py modules?

Error

$ cmake ..

CMake Warning (dev) in CMakeLists.txt:
  No project() command is present.  The top-level CMakeLists.txt file must
  contain a literal, direct call to the project() command.  Add a line of
  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first
  line.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/pranto/miniconda3/envs/geant4/bin/x86_64-conda-linux-gnu-cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/pranto/miniconda3/envs/geant4/bin/x86_64-conda-linux-gnu-c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:3 (g4py_add_module):
  Unknown CMake command "g4py_add_module".
Call Stack (most recent call first):
  ExN01geom/CMakeLists.txt:3 (g4pytest_add_module)


CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 3.19)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!

Apologies, but I haven’t (and don’t at present) had the time to look at this

Hello,

I just wanted to iterate on the g4py examples. I am new to Geant4 and would really like to be able to use the python scripting functionalities, but could not find any working (and educational) examples on the forums. (Regarding my application, I am just trying to compute the energy loss dEdx in a uniform layer of a thin film material excited by X-Rays.)

That would be very helpful.

Best,

Charles

Hi,
I’ am getting this error message as I am trying to “configure” by setting “GEANT4_BUILD_MULTITHREAD=ON” and “GEANT4_USE_PYTHON=ON”, which is:

“Geant4Py only supports ‘global-dynamic’ thread local storage, but ‘initial-exec’ selected by GEANT4_BUILD_TLS_MODEL option”.

@bmorgan was talking about this in a way that, in order to remove this error, I need to set “GEANT4_BUILD_TLS_MODEL=global-dynamic”.
However, I don’t see any variable called “GEANT4_BUILD_TLS_MODEL” in the cmake variable list.

One more thing: I did not source the geant4.sh script before starting python3 and importing Geant4py. Is this why I don’t see the mentioned variable?
If it is, then how to source the .sh script?

[ I’m using
Geant4 version 10.7.02,
macOS Big Sur 11.6,
Xcode version 13.0,
python 3.9.2,
boost 1.76.0. ]

Fortunately, I’ve managed to solve my problem.
I was reading through the GEANT4 Installation Guide Documentaion.
The way I solved the problem is by clicking the advanced option on the CMake GUI.
And then the “GEANT4_BUILD_TLS_MODEL” variable appeared.