From f0ceeac0a8a1a8630c65ec6b1f090b30da719a1f Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Tue, 19 Apr 2022 18:08:26 +0200 Subject: serialbox: setup the run and dependent build environments (#29892) * serialbox: setup the run and dependent build environments * Update var/spack/repos/builtin/packages/serialbox/package.py Co-authored-by: Adam J. Stewart Co-authored-by: Adam J. Stewart --- var/spack/repos/builtin/packages/serialbox/package.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/var/spack/repos/builtin/packages/serialbox/package.py b/var/spack/repos/builtin/packages/serialbox/package.py index 49f57249d3..cf04ca2b71 100644 --- a/var/spack/repos/builtin/packages/serialbox/package.py +++ b/var/spack/repos/builtin/packages/serialbox/package.py @@ -48,6 +48,9 @@ class Serialbox(CMakePackage): depends_on('netcdf-c', when='+netcdf') + # The preprocessor can be run with Python 2: + depends_on('python', type='run') + # The Python interface is compatible only with Python 3: depends_on('python@3.4:', when='+python', type=('build', 'run')) depends_on('py-numpy', when='+python', type=('build', 'run')) @@ -153,6 +156,20 @@ class Serialbox(CMakePackage): return flags, None, (cmake_flags or None) + def setup_run_environment(self, env): + # Allow for running the preprocessor directly: + env.prepend_path('PATH', self.prefix.python.pp_ser) + # Allow for running the preprocessor as a Python module, as well as + # enable the Python interface in a non-standard directory: + env.prepend_path('PYTHONPATH', self.prefix.python) + + def setup_dependent_build_environment(self, env, dependent_spec): + self.setup_run_environment(env) + + def setup_dependent_package(self, module, dependent_spec): + # Simplify the location of the preprocessor by dependent packages: + self.spec.pp_ser = join_path(self.prefix.python.pp_ser, 'pp_ser.py') + def cmake_args(self): args = [ '-DBOOST_ROOT:PATH=%s' % self.spec['boost'].prefix, -- cgit v1.2.3-70-g09d2