From fb9a0c55a76bbf79bb53dfcacb89c1ad53b98696 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 9 Mar 2020 14:36:23 -0400 Subject: [PATCH 1/3] hepmc3: 3.1.2 -> 3.2.0 --- .../libraries/physics/hepmc3/default.nix | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/development/libraries/physics/hepmc3/default.nix b/pkgs/development/libraries/physics/hepmc3/default.nix index d8aff555e55630..ceb0669d855b82 100644 --- a/pkgs/development/libraries/physics/hepmc3/default.nix +++ b/pkgs/development/libraries/physics/hepmc3/default.nix @@ -2,27 +2,31 @@ stdenv.mkDerivation rec { pname = "hepmc3"; - version = "3.1.2"; + version = "3.2.0"; src = fetchurl { url = "http://hepmc.web.cern.ch/hepmc/releases/HepMC3-${version}.tar.gz"; - sha256 = "1izcldnjbyn6myr7nv7b4jivf2vmdi64ng9gk1vjh998755hfcs1"; + sha256 = "1z491x3blqs0a2jxmhzhmh4kqdw3ddcbvw69gidg4w6icdvkhcpi"; }; - buildInputs = [ cmake root ]; + nativeBuildInputs = [ cmake ]; + buildInputs = [ root ]; + + cmakeFlags = [ + "-DHEPMC3_ENABLE_PYTHON=OFF" + ]; postInstall = '' substituteInPlace "$out"/bin/HepMC3-config \ - --replace 'greadlink' '${coreutils}/bin/readlink' + --replace 'greadlink' '${coreutils}/bin/readlink' \ + --replace 'readlink' '${coreutils}/bin/readlink' ''; - enableParallelBuilding = true; - meta = with stdenv.lib; { description = "The HepMC package is an object oriented, C++ event record for High Energy Physics Monte Carlo generators and simulation"; - license = licenses.gpl3; - homepage = http://hepmc.web.cern.ch/hepmc/; - platforms = platforms.unix; + license = licenses.gpl3; + homepage = "http://hepmc.web.cern.ch/hepmc/"; + platforms = platforms.unix; maintainers = with maintainers; [ veprbl ]; }; } From 621b18917c9cf4eed936633c894e9116268db6c2 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 9 Mar 2020 14:37:20 -0400 Subject: [PATCH 2/3] hepmc3: add python support --- .../libraries/physics/hepmc3/default.nix | 15 ++++++++++++--- pkgs/top-level/all-packages.nix | 4 +++- pkgs/top-level/python-packages.nix | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/physics/hepmc3/default.nix b/pkgs/development/libraries/physics/hepmc3/default.nix index ceb0669d855b82..a07c3c19a1bb6b 100644 --- a/pkgs/development/libraries/physics/hepmc3/default.nix +++ b/pkgs/development/libraries/physics/hepmc3/default.nix @@ -1,4 +1,9 @@ -{ stdenv, fetchurl, cmake, coreutils, root }: +{ stdenv, fetchurl, cmake, coreutils, python, root }: + +let + pythonVersion = with stdenv.lib.versions; "${major python.version}${minor python.version}"; + withPython = python != null; +in stdenv.mkDerivation rec { pname = "hepmc3"; @@ -10,10 +15,14 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ cmake ]; - buildInputs = [ root ]; + buildInputs = [ root ] + ++ stdenv.lib.optional withPython python; cmakeFlags = [ - "-DHEPMC3_ENABLE_PYTHON=OFF" + "-DHEPMC3_ENABLE_PYTHON=${if withPython then "ON" else "OFF"}" + ] ++ stdenv.lib.optionals withPython [ + "-DHEPMC3_PYTHON_VERSIONS=${if python.isPy3k then "3.X" else "2.X"}" + "-DHEPMC3_Python_SITEARCH${pythonVersion}=${placeholder "out"}/${python.sitePackages}" ]; postInstall = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 34040871511718..ead46fda60ebdd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -24799,7 +24799,9 @@ in hepmc2 = callPackage ../development/libraries/physics/hepmc2 { }; - hepmc3 = callPackage ../development/libraries/physics/hepmc3 { }; + hepmc3 = callPackage ../development/libraries/physics/hepmc3 { + python = null; + }; herwig = callPackage ../development/libraries/physics/herwig { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 1e3510d004b09a..39577c27ba5ee8 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2236,6 +2236,10 @@ in { jsonrpc-websocket = callPackage ../development/python-modules/jsonrpc-websocket { }; + hepmc3 = toPythonModule (pkgs.hepmc3.override { + inherit python; + }); + onkyo-eiscp = callPackage ../development/python-modules/onkyo-eiscp { }; tablib = callPackage ../development/python-modules/tablib { }; From 666d662d0f82a07613e4af26b57853e7d2cdf240 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinkin Date: Mon, 9 Mar 2020 14:54:34 -0400 Subject: [PATCH 3/3] remove pythonPackages.pyhepmc pythonPackages.hepmc3 should cover this functionality --- .../python-modules/pyhepmc/default.nix | 59 ----- .../pyhepmc/pyhepmc_export_edges.patch | 204 ------------------ .../pyhepmc/pyhepmc_export_flow.patch | 20 -- pkgs/top-level/python-packages.nix | 2 - 4 files changed, 285 deletions(-) delete mode 100644 pkgs/development/python-modules/pyhepmc/default.nix delete mode 100644 pkgs/development/python-modules/pyhepmc/pyhepmc_export_edges.patch delete mode 100644 pkgs/development/python-modules/pyhepmc/pyhepmc_export_flow.patch diff --git a/pkgs/development/python-modules/pyhepmc/default.nix b/pkgs/development/python-modules/pyhepmc/default.nix deleted file mode 100644 index 26a91a313ee446..00000000000000 --- a/pkgs/development/python-modules/pyhepmc/default.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ stdenv -, buildPythonPackage -, fetchPypi -, fetchFromBitbucket -, isPy3k -, pkgs -, python -}: - -buildPythonPackage rec { - pname = "pyhepmc"; - version = "1.0.1"; - disabled = isPy3k; - - src = fetchPypi { - inherit pname version; - sha256 = "1210fd7e20d4abc1d9166147a9f7645a2a58b655fe030ad54ab3ea0d0c6e0834"; - }; - - srcMissing = fetchFromBitbucket { - owner = "andybuckley"; - repo = "pyhepmc"; - rev = "pyhepmc-1.0.0"; - sha256 = "0vxad143pz45q94w5p0dycpk24insdsv1m5k867y56xy24bi0d4w"; - }; - - prePatch = '' - cp -r $srcMissing/hepmc . - chmod +w hepmc - ''; - - patches = [ - # merge PR https://bitbucket.org/andybuckley/pyhepmc/pull-requests/1/add-incoming-outgoing-generators-for/diff - ./pyhepmc_export_edges.patch - # add bindings to Flow class - ./pyhepmc_export_flow.patch - ]; - - # regenerate python wrapper - preConfigure = '' - swig -c++ -I${pkgs.hepmc}/include -python hepmc/hepmcwrap.i - ''; - - nativeBuildInputs = [ pkgs.swig ]; - buildInputs = [ pkgs.hepmc2 ]; - - HEPMCPATH = pkgs.hepmc2; - - checkPhase = '' - ${python.interpreter} test/test1.py - ''; - - meta = with stdenv.lib; { - description = "A simple wrapper on the main classes of the HepMC event simulation representation, making it possible to create, read and manipulate HepMC events from Python code"; - license = licenses.gpl2; - maintainers = with maintainers; [ veprbl ]; - }; - -} diff --git a/pkgs/development/python-modules/pyhepmc/pyhepmc_export_edges.patch b/pkgs/development/python-modules/pyhepmc/pyhepmc_export_edges.patch deleted file mode 100644 index 5c6e56566a34df..00000000000000 --- a/pkgs/development/python-modules/pyhepmc/pyhepmc_export_edges.patch +++ /dev/null @@ -1,204 +0,0 @@ -# HG changeset patch -# User Lukas Heinrich -# Date 1430606843 14400 -# Node ID 325f89b7b72922e9add9ca9dd0f7ca4a6c83bf00 -# Parent e4fd953257e0d38511f2177de7ffaef662358af2 -add incoming/outgoing generators for GenVertex - -diff --git a/hepmc/generators.i b/hepmc/generators.i -new file mode 100644 ---- /dev/null -+++ b/hepmc/generators.i -@@ -0,0 +1,171 @@ -+/*! -+ * \file generators.i -+ * \author Seth R. Johnson -+ * \brief Define generator/iterator for any type -+ -+Example: -+\code -+ SETUP_GENERATOR( std::vector::const_iterator ) -+ ADD_GENERATOR( Mesh, cells, -+ std::vector::const_iterator, Cell, beginCells, endCells) -+\endcode -+would be a method to add a \c cells generator method method to the Python class -+\c Mesh, when the C++ class \c Mesh has a \c std::vector accessed through -+methods \c beginCells and \c endCells. -+ -+The macro \c ADD_GENERATOR_P would be if the underlying storage were \c -+std::vector instead. -+ -+Alternatively, for containers of regular objects that provide \c begin(), \c end(), and \c const_iterator, you can use the \c ADD_CONTAINER_ITERATOR macro: -+\code -+ADD_CONTAINER_ITERATOR( QuadratureSet ) -+\endcode -+ -+\section License -+ -+Copyright (c) 2010, Seth R. Johnson -+All rights reserved. -+ -+Redistribution and use in source and binary forms, with or without -+modification, are permitted provided that the following conditions are met: -+ * Redistributions of source code must retain the above copyright notice, this -+ list of conditions and the following disclaimer. -+ * Redistributions in binary form must reproduce the above copyright notice, -+ this list of conditions and the following disclaimer in the documentation -+ and/or other materials provided with the distribution. -+ * Neither the name of the this project nor the names of its contributors -+ may be used to endorse or promote products derived from this software -+ without specific prior written permission. -+ -+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ -+ This material is based upon work supported under a National Science -+ Foundation Graduate Research Fellowship. Any opinions, findings, conclusions -+ or recommendations expressed in this publication are those of the author -+ and do not necessarily reflect the views of the National Science -+ Foundation. -+*/ -+#ifndef tools_SWIG_generators_i -+#define tools_SWIG_generators_i -+/*----------------------------------------------------------------------------*/ -+ -+// Add a Python class to provide iterator objects -+%insert("python") %{ -+class GenericIterator: -+ def __init__(self, begin_iter_method, deref_method, incr_method): -+ self.it = begin_iter_method() -+ self.incr = incr_method -+ self.deref = deref_method -+ -+ def __iter__(self): -+ return self -+ -+ def next(self): -+ obj = self.deref( self.it ) -+ if obj is not None: -+ self.incr( self.it ) -+ return obj -+ else: -+ raise StopIteration -+%} -+ -+//============== GENERIC GENERATOR/ITERATOR WRAPPER SUPPORT ============ -+//! Thin wrapper for incrementing a certain type of iterator -+// only need to define once per iterator type, and we can use the same name -+// thanks to overloading (even though this may decrease efficiency) -+%define SETUP_GENERATOR( ITERATOR... ) -+%inline %{ -+void _iter_incr( ITERATOR* iter ) -+{ -+ ++(*iter); -+} -+%} -+%enddef -+ -+/*----------------------------------------------------------------------------*/ -+// Internal method for adding common parts of the generator -+%define PYTRT_BASE_ADD_GENERATOR( CLASS, PYMETHOD, ITERATOR, CBEGIN ) -+ %extend CLASS { -+%insert("python") %{ -+ def PYMETHOD(self): -+ "Returns an iterator for PYMETHOD." -+ return GenericIterator( -+ self._begin_ ## PYMETHOD, -+ self._deref_ ## PYMETHOD, -+ _iter_incr -+ ) -+%} -+// get the first element in the vector -+ITERATOR* _begin_ ## PYMETHOD() -+{ -+ return new ITERATOR( ($self)->CBEGIN() ); -+} -+ } -+%enddef -+/*----------------------------------------------------------------------------*/ -+// If the dereferenced iterator is an object -+%define ADD_GENERATOR( CLASS, PYMETHOD, ITERATOR, RVALUE, CBEGIN, CEND ) -+ -+// add the python and begin method -+PYTRT_BASE_ADD_GENERATOR( CLASS, PYMETHOD, ITERATOR, CBEGIN ) -+ -+ %extend CLASS { -+//! Dereference the iterator; return NULL if at the end -+const RVALUE* _deref_ ## PYMETHOD ## ( const ITERATOR* iter ) -+{ -+ // if at the end, return NULL -+ if (*iter == ($self)->CEND() ) { -+ return NULL; -+ } -+ // otherwise, return the POINTER to the dereferenced iterator -+ return &(**iter); -+} -+ } -+%enddef -+/*----------------------------------------------------------------------------*/ -+// If the dereferenced iterator is a pointer -+%define ADD_GENERATOR_P( CLASS, PYMETHOD, ITERATOR, RVALUE, CBEGIN, CEND ) -+ -+// add the python and begin method -+PYTRT_BASE_ADD_GENERATOR( CLASS, PYMETHOD, ITERATOR, CBEGIN ) -+ -+ %extend CLASS { -+//! Dereference the iterator; return NULL if at the end -+const RVALUE* _deref_ ## PYMETHOD ## ( const ITERATOR* iter ) -+{ -+ // if at the end, return NULL -+ if (*iter == ($self)->CEND() ) { -+ return NULL; -+ } -+ // otherwise, return the dereferenced iterator (a pointer) -+ return **iter; -+} -+ } -+%enddef -+/*----------------------------------------------------------------------------*/ -+//! For a regular container with "begin" and "end" and "size" -+%define ADD_CONTAINER_ITERATOR( CLASS ) -+ SETUP_GENERATOR( CLASS::const_iterator ); -+ ADD_GENERATOR( CLASS, __iter__, -+ CLASS ## ::const_iterator, CLASS ## ::value_type, -+ begin, end) -+ %extend CLASS { -+ %insert("python") %{ -+ def __len__(self): -+ return self.size() -+ %} -+ } -+%enddef -+ -+/*============================================================================*/ -+#endif -+ -diff --git a/hepmc/hepmcwrap.i b/hepmc/hepmcwrap.i ---- a/hepmc/hepmcwrap.i -+++ b/hepmc/hepmcwrap.i -@@ -1,5 +1,7 @@ - %module hepmcwrap - -+%include generators.i -+ - %{ - #include "HepMC/GenEvent.h" - #include "HepMC/GenVertex.h" -@@ -251,3 +253,9 @@ - return ss.str(); - } - } -+ -+SETUP_GENERATOR( std::vector< HepMC::GenParticle* >::const_iterator ) -+ADD_GENERATOR_P( HepMC::GenVertex, incoming, -+std::vector< HepMC::GenParticle* >::const_iterator, HepMC::GenParticle, particles_in_const_begin, particles_in_const_end) -+ADD_GENERATOR_P( HepMC::GenVertex, outgoing, -+std::vector< HepMC::GenParticle* >::const_iterator, HepMC::GenParticle, particles_out_const_begin, particles_out_const_end) diff --git a/pkgs/development/python-modules/pyhepmc/pyhepmc_export_flow.patch b/pkgs/development/python-modules/pyhepmc/pyhepmc_export_flow.patch deleted file mode 100644 index 85e26a1a16077a..00000000000000 --- a/pkgs/development/python-modules/pyhepmc/pyhepmc_export_flow.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/hepmc/hepmcwrap.i b/hepmc/hepmcwrap.i -index cf35c1b..b94fbe2 100644 ---- a/hepmc/hepmcwrap.i -+++ b/hepmc/hepmcwrap.i -@@ -1,6 +1,7 @@ - %module hepmcwrap - - %{ -+ #include "HepMC/Flow.h" - #include "HepMC/GenEvent.h" - #include "HepMC/GenVertex.h" - #include "HepMC/GenParticle.h" -@@ -93,6 +94,7 @@ namespace HepMC { - // headers before importing headers that use those classes. - // Result is that headers should probably be %included in an order - // which sees "contents before containers" -+%include "HepMC/Flow.h" - %include "HepMC/HepMCDefs.h" - %include "HepMC/SimpleVector.h" - // #ifdef HEPMC_HAS_ITERATOR_RANGES diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 39577c27ba5ee8..c449f1e1fb840b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2331,8 +2331,6 @@ in { pyhcl = callPackage ../development/python-modules/pyhcl { }; - pyhepmc = callPackage ../development/python-modules/pyhepmc { }; - pytest = if isPy3k then self.pytest_5 else self.pytest_4; pytest_5 = callPackage ../development/python-modules/pytest {