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 <ajstewart426@gmail.com>

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
This commit is contained in:
Sergey Kosukhin 2022-04-19 18:08:26 +02:00 committed by GitHub
parent 2965a7a7e9
commit f0ceeac0a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,6 +48,9 @@ class Serialbox(CMakePackage):
depends_on('netcdf-c', when='+netcdf') 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('python@3.4:', when='+python', type=('build', 'run'))
depends_on('py-numpy', when='+python', type=('build', 'run')) depends_on('py-numpy', when='+python', type=('build', 'run'))
@ -153,6 +156,20 @@ def flag_handler(self, name, flags):
return flags, None, (cmake_flags or None) 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): def cmake_args(self):
args = [ args = [
'-DBOOST_ROOT:PATH=%s' % self.spec['boost'].prefix, '-DBOOST_ROOT:PATH=%s' % self.spec['boost'].prefix,