pythonPackages.geant4: init at 10.6.2

Starting geant4 10.6.2 g4py can not be built separately
http://geant4-data.web.cern.ch/geant4-data/ReleaseNotes/Patch4.10.6-2.txt

Also, it appears that g4py itself is now deprecated, it was moved
to environments/g4py/tests/g4pytest in the source distribution.  The only
remaining imported module is Geant4, hence python package name
`pythonPackages.geant4`, the capitalization matches the one of the non-python
attribute.
This commit is contained in:
Dmitry Kalinkin 2020-06-06 14:24:13 -04:00
parent dfbc6b3a26
commit 6fa6decded
6 changed files with 30 additions and 69 deletions

View file

@ -5,6 +5,7 @@
, enableQT ? false
, enableXM ? false
, enableOpenGLX11 ? true
, enablePython ? false
, enableRaytracerX11 ? false
# Standard build environment with cmake.
@ -33,8 +34,16 @@
, libGLU, libGL
, xlibsWrapper
, libXmu
# For enablePython
, boost
, python3
}:
let
boost_python = boost.override { enablePython = true; python = python3; };
in
stdenv.mkDerivation rec {
version = "10.6.2";
pname = "geant4";
@ -44,6 +53,16 @@ stdenv.mkDerivation rec {
sha256 = "0vznm3pjlbihjy1wsxc4gj229k0dzc283wvil2xghyl08vwdpnpc";
};
boost_python_lib = "python${builtins.replaceStrings ["."] [""] python3.pythonVersion}";
postPatch = ''
# Fix for boost 1.67+
substituteInPlace environments/g4py/CMakeLists.txt \
--replace "find_package(Boost REQUIRED python)" \
"find_package(Boost REQUIRED COMPONENTS $boost_python_lib)"
substituteInPlace environments/g4py/G4PythonHelpers.cmake \
--replace "Boost::python" "Boost::$boost_python_lib"
'';
cmakeFlags = [
"-DGEANT4_INSTALL_DATA=OFF"
"-DGEANT4_USE_GDML=${if enableGDML then "ON" else "OFF"}"
@ -52,11 +71,14 @@ stdenv.mkDerivation rec {
"-DGEANT4_USE_XM=${if enableXM then "ON" else "OFF"}"
"-DGEANT4_USE_OPENGL_X11=${if enableOpenGLX11 then "ON" else "OFF"}"
"-DGEANT4_USE_INVENTOR=${if enableInventor then "ON" else "OFF"}"
"-DGEANT4_USE_PYTHON=${if enablePython then "ON" else "OFF"}"
"-DGEANT4_USE_RAYTRACER_X11=${if enableRaytracerX11 then "ON" else "OFF"}"
"-DGEANT4_USE_SYSTEM_CLHEP=${if clhep != null then "ON" else "OFF"}"
"-DGEANT4_USE_SYSTEM_EXPAT=${if expat != null then "ON" else "OFF"}"
"-DGEANT4_USE_SYSTEM_ZLIB=${if zlib != null then "ON" else "OFF"}"
"-DGEANT4_BUILD_MULTITHREADED=${if enableMultiThreading then "ON" else "OFF"}"
] ++ stdenv.lib.optionals (enableMultiThreading && enablePython) [
"-DGEANT4_BUILD_TLS_MODEL=global-dynamic"
] ++ stdenv.lib.optionals enableInventor [
"-DINVENTOR_INCLUDE_DIR=${coin3d}/include"
"-DINVENTOR_LIBRARY_RELEASE=${coin3d}/lib/libCoin.so"
@ -66,7 +88,8 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ cmake ];
buildInputs = [ libGLU xlibsWrapper libXmu ]
++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt motif ];
++ stdenv.lib.optionals enableInventor [ libXpm coin3d soxt motif ]
++ stdenv.lib.optionals enablePython [ boost_python python3 ];
propagatedBuildInputs = [ clhep expat zlib libGL ]
++ stdenv.lib.optionals enableGDML [ xercesc ]

View file

@ -1,65 +0,0 @@
{ stdenv, cmake, xercesc
# The target version of Geant4
, geant4
# Python (obviously) and boost::python for wrapping.
, python
, boost
}:
let
# g4py does not support MT and will fail to build against MT geant
geant4_nomt = geant4.override { enableMultiThreading = false; };
boost_python = boost.override { enablePython = true; inherit python; };
in
stdenv.mkDerivation {
inherit (geant4_nomt) version src;
pname = "g4py";
nativeBuildInputs = [ cmake ];
buildInputs = [ geant4_nomt xercesc boost_python python ];
GEANT4_INSTALL = geant4_nomt;
postPatch = ''
cd environments/g4py
'';
preConfigure = ''
# Fix for boost 1.67+
substituteInPlace CMakeLists.txt \
--replace "find_package(Boost)" "find_package(Boost 1.40 REQUIRED COMPONENTS python${builtins.replaceStrings ["."] [""] python.pythonVersion})"
for f in `find . -name CMakeLists.txt`; do
substituteInPlace "$f" \
--replace "boost_python" "\''${Boost_LIBRARIES}"
done
'';
enableParallelBuilding = true;
setupHook = ./setup-hook.sh;
# Make sure we set PYTHONPATH
shellHook = ''
source $out/nix-support/setup-hook
'';
meta = {
description = "Python bindings and utilities for Geant4";
longDescription = ''
Geant4 is a toolkit for the simulation of the passage of particles
through matter. Its areas of application include high energy,
nuclear and accelerator physics, as well as studies in medical and
space science. The two main reference papers for Geant4 are
published in Nuclear Instruments and Methods in Physics Research A
506 (2003) 250-303, and IEEE Transactions on Nuclear Science 53 No. 1
(2006) 270-278.
'';
homepage = "http://www.geant4.org";
license = stdenv.lib.licenses.g4sl;
maintainers = [ ];
platforms = stdenv.lib.platforms.all;
};
}

View file

@ -1 +0,0 @@
export PYTHONPATH=$PYTHONPATH:@out@/lib

View file

@ -153,6 +153,7 @@ mapAliases ({
fuseki = apache-jena-fuseki; # added 2018-04-25
fusesmb = throw "fusesmb is abandoned by upstream"; # added 2019-10-15
fwupdate = throw "fwupdate was merged into fwupd"; # added 2020-05-19
g4py = python3Packages.geant4; # added 2020-06-06
gccApple = throw "gccApple is no longer supported"; # added 2018-04-25
gdb-multitarget = gdb; # added 2017-11-13
gdk_pixbuf = gdk-pixbuf; # added 2019-05-22

View file

@ -25344,8 +25344,6 @@ in
cernlib = callPackage ../development/libraries/physics/cernlib { };
g4py = callPackage ../development/libraries/physics/geant4/g4py { };
hepmc2 = callPackage ../development/libraries/physics/hepmc2 { };
hepmc3 = callPackage ../development/libraries/physics/hepmc3 {

View file

@ -3886,6 +3886,11 @@ in {
gdrivefs = callPackage ../development/python-modules/gdrivefs { };
geant4 = disabledIf (!isPy3k) (toPythonModule (pkgs.geant4.override {
enablePython = true;
python3 = python;
}));
genshi = callPackage ../development/python-modules/genshi { };
gentools = callPackage ../development/python-modules/gentools { };