summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2020-04-15 12:21:02 +0200
committerGitHub <noreply@github.com>2020-04-15 12:21:02 +0200
commitff0ec9cf6151eaa7b5e478f5c305102506c8852e (patch)
tree54a575f7cde7a09c51b17a0d96f5d249b231f9b2 /var
parentd41e366d0d1347f7adda769926ad0c4c2bce640d (diff)
downloadspack-ff0ec9cf6151eaa7b5e478f5c305102506c8852e.tar.gz
spack-ff0ec9cf6151eaa7b5e478f5c305102506c8852e.tar.bz2
spack-ff0ec9cf6151eaa7b5e478f5c305102506c8852e.tar.xz
spack-ff0ec9cf6151eaa7b5e478f5c305102506c8852e.zip
openfoam: set run environment by sourcing bashrc (#15949)
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/openfoam-org/package.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/var/spack/repos/builtin/packages/openfoam-org/package.py b/var/spack/repos/builtin/packages/openfoam-org/package.py
index 42c5b0e015..dc9b5673ee 100644
--- a/var/spack/repos/builtin/packages/openfoam-org/package.py
+++ b/var/spack/repos/builtin/packages/openfoam-org/package.py
@@ -45,6 +45,7 @@ from spack.pkg.builtin.openfoam import write_environ
from spack.pkg.builtin.openfoam import rewrite_environ_files
from spack.pkg.builtin.openfoam import mplib_content
from spack.pkg.builtin.openfoam import OpenfoamArch
+from spack.util.environment import EnvironmentModifications
class OpenfoamOrg(Package):
@@ -138,15 +139,14 @@ class OpenfoamOrg(Package):
return settings
def setup_run_environment(self, env):
- # This should be similar to the openfoam package,
- # but sourcing the etc/bashrc here seems to exit with an error.
- # ... this needs to be examined in more detail.
- #
- # Minimal environment only.
- env.set('FOAM_PROJECT_DIR', self.projectdir)
- env.set('WM_PROJECT_DIR', self.projectdir)
- for d in ['wmake', self.archbin]: # bin already added automatically
- env.prepend_path('PATH', join_path(self.projectdir, d))
+ bashrc = self.prefix.etc.bashrc
+ try:
+ env.extend(EnvironmentModifications.from_sourcing_file(
+ bashrc, clean=True
+ ))
+ except Exception as e:
+ msg = 'unexpected error when sourcing OpenFOAM bashrc [{0}]'
+ tty.warn(msg.format(str(e)))
def setup_dependent_build_environment(self, env, dependent_spec):
"""Location of the OpenFOAM project directory.
@@ -386,5 +386,3 @@ class OpenfoamOrg(Package):
if os.path.isfile(f)
]:
os.symlink(f, os.path.basename(f))
-
-# -----------------------------------------------------------------------------