From 872ffe17ad8ae935df07539af609aacad445feb5 Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Thu, 11 Aug 2022 13:21:13 +0200
Subject: [PATCH] DDSim: use python executable based on what the system has

---
 DDG4/CMakeLists.txt                             | 4 +++-
 DDG4/python/DDSim/bin/{ddsim.py => ddsim.in.py} | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
 rename DDG4/python/DDSim/bin/{ddsim.py => ddsim.in.py} (94%)
 mode change 100755 => 100644

diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt
index 459a81001..c57166b36 100644
--- a/DDG4/CMakeLists.txt
+++ b/DDG4/CMakeLists.txt
@@ -149,7 +149,9 @@ target_link_libraries(g4FromXML DDG4)
 file(GLOB DDG4_python python/*.py python/*.C)
 install(FILES ${DDG4_python} DESTINATION ${DD4HEP_PYTHON_INSTALL_DIR})
 
-install(PROGRAMS python/DDSim/bin/ddsim.py DESTINATION bin RENAME ddsim)
+get_filename_component(PYTHON_INTERPRETER_BINARY ${Python_EXECUTABLE} NAME)
+configure_file(python/DDSim/bin/ddsim.in.py ${CMAKE_BINARY_DIR}/bin/ddsim @ONLY)
+install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/ddsim DESTINATION bin)
 
 install(PROGRAMS python/bin/checkOverlaps.py DESTINATION bin RENAME checkOverlaps)
 install(PROGRAMS python/bin/checkGeometry.py DESTINATION bin RENAME checkGeometry)
diff --git a/DDG4/python/DDSim/bin/ddsim.py b/DDG4/python/DDSim/bin/ddsim.in.py
old mode 100755
new mode 100644
similarity index 94%
rename from DDG4/python/DDSim/bin/ddsim.py
rename to DDG4/python/DDSim/bin/ddsim.in.py
index 20b9b5284..ce20d73b7
--- a/DDG4/python/DDSim/bin/ddsim.py
+++ b/DDG4/python/DDSim/bin/ddsim.in.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env @PYTHON_INTERPRETER_BINARY@
 """
 
 DD4hep simulation with some argument parsing
-- 
GitLab