From fd609776130d8ddc3d6bee0cdec9fe88653670b3 Mon Sep 17 00:00:00 2001 From: iarspider Date: Sun, 23 Feb 2020 19:07:00 +0100 Subject: Separate HepMC2 and HepMC3 build recipes; Python3 support for HepMC3 (#15147) * Fixes & additional variant(s) for HepMC3 * Syntax * Restore recipe for HepMC2 * Remove FIXME * Update package.py * Apply suggestions from code review Co-Authored-By: Adam J. Stewart Co-authored-by: Adam J. Stewart --- var/spack/repos/builtin/packages/hepmc/package.py | 34 +++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/hepmc/package.py b/var/spack/repos/builtin/packages/hepmc/package.py index 2828a179ff..d208e7ecde 100644 --- a/var/spack/repos/builtin/packages/hepmc/package.py +++ b/var/spack/repos/builtin/packages/hepmc/package.py @@ -28,24 +28,46 @@ class Hepmc(CMakePackage): variant('python', default=False, description='Enable Python bindings') variant('rootio', default=False, description='Enable ROOT I/O') + variant('interfaces', default=False, description='Install interfaces for some Monte-Carlo Event Gens') depends_on('cmake@2.8.9:', type='build') - # FIXME: Officially supports Python3, but the build system doesn't find it - depends_on('python@:2.99.99', when='+python') + depends_on('python', when='+python') depends_on('root', when='+rootio') - conflicts('+python', when='@:3.1.99') - conflicts('+rootio', when='@:2.99.99') + conflicts('+python', when='@:3.1') + conflicts('+rootio', when='@:2') + conflicts('+interfaces', when='@:2') + @when('@:2') + def cmake_args(self): + return ['-Dmomentum:STRING=GEV', '-Dlength:STRING=MM'] + + @when('@3:') def cmake_args(self): spec = self.spec - return [ + args = [ '-Dmomentum:STRING=GEV', '-Dlength:STRING=MM', '-DHEPMC3_ENABLE_PYTHON={0}'.format(spec.satisfies('+python')), - '-DHEPMC3_ENABLE_ROOTIO={0}'.format(spec.satisfies('+rootio')) + '-DHEPMC3_ENABLE_ROOTIO={0}'.format(spec.satisfies('+rootio')), + '-DHEPMC3_INSTALL_INTERFACES={0}'.format( + spec.satisfies('+interfaces')), ] + if self.spec.satisfies('+python'): + py_ver = spec['python'].version.up_to(2) + py_sitepkg = join_path(self.prefix, site_packages_dir) + args.extend([ + '-DHEPMC3_PYTHON_VERSIONS={0}'.format(py_ver), + '-DHEPMC3_Python_SITEARCH{0}={1}'.format( + py_ver.joined, py_sitepkg) + ]) + + if self.spec.satisfies('+rootio'): + args.append('-DROOT_DIR={0}'.format(self.spec['root'].prefix)) + + return args + def url_for_version(self, version): if version > Version("3.0.0"): url = "http://hepmc.web.cern.ch/hepmc/releases/HepMC3-{0}.tar.gz" -- cgit v1.2.3-70-g09d2