openfoam: set run environment by sourcing bashrc (#15949)

This commit is contained in:
Massimiliano Culpo 2020-04-15 12:21:02 +02:00 committed by GitHub
parent d41e366d0d
commit ff0ec9cf61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,6 +45,7 @@
from spack.pkg.builtin.openfoam import rewrite_environ_files from spack.pkg.builtin.openfoam import rewrite_environ_files
from spack.pkg.builtin.openfoam import mplib_content from spack.pkg.builtin.openfoam import mplib_content
from spack.pkg.builtin.openfoam import OpenfoamArch from spack.pkg.builtin.openfoam import OpenfoamArch
from spack.util.environment import EnvironmentModifications
class OpenfoamOrg(Package): class OpenfoamOrg(Package):
@ -138,15 +139,14 @@ def config(self):
return settings return settings
def setup_run_environment(self, env): def setup_run_environment(self, env):
# This should be similar to the openfoam package, bashrc = self.prefix.etc.bashrc
# but sourcing the etc/bashrc here seems to exit with an error. try:
# ... this needs to be examined in more detail. env.extend(EnvironmentModifications.from_sourcing_file(
# bashrc, clean=True
# Minimal environment only. ))
env.set('FOAM_PROJECT_DIR', self.projectdir) except Exception as e:
env.set('WM_PROJECT_DIR', self.projectdir) msg = 'unexpected error when sourcing OpenFOAM bashrc [{0}]'
for d in ['wmake', self.archbin]: # bin already added automatically tty.warn(msg.format(str(e)))
env.prepend_path('PATH', join_path(self.projectdir, d))
def setup_dependent_build_environment(self, env, dependent_spec): def setup_dependent_build_environment(self, env, dependent_spec):
"""Location of the OpenFOAM project directory. """Location of the OpenFOAM project directory.
@ -386,5 +386,3 @@ def install_links(self):
if os.path.isfile(f) if os.path.isfile(f)
]: ]:
os.symlink(f, os.path.basename(f)) os.symlink(f, os.path.basename(f))
# -----------------------------------------------------------------------------