diff options
author | Nicolas Richart <nicolas.richart@epfl.ch> | 2016-06-27 00:55:26 +0200 |
---|---|---|
committer | Nicolas Richart <nicolas.richart@epfl.ch> | 2016-06-27 00:55:26 +0200 |
commit | 7cf1313572b24917ff77018424d77991312e6f5f (patch) | |
tree | 972514059a50759d4ddbcdcf4088b38f7ecbe53a /var/spack/repos/builtin/packages/foam-extend/package.py | |
parent | 97feca0888076f3cb673652f6fefe433b6aa4f3f (diff) | |
download | spack-7cf1313572b24917ff77018424d77991312e6f5f.tar.gz spack-7cf1313572b24917ff77018424d77991312e6f5f.tar.bz2 spack-7cf1313572b24917ff77018424d77991312e6f5f.tar.xz spack-7cf1313572b24917ff77018424d77991312e6f5f.zip |
changes to use from_sourcing_file
Diffstat (limited to 'var/spack/repos/builtin/packages/foam-extend/package.py')
-rw-r--r-- | var/spack/repos/builtin/packages/foam-extend/package.py | 42 |
1 files changed, 6 insertions, 36 deletions
diff --git a/var/spack/repos/builtin/packages/foam-extend/package.py b/var/spack/repos/builtin/packages/foam-extend/package.py index 9043896863..ca1a0e1710 100644 --- a/var/spack/repos/builtin/packages/foam-extend/package.py +++ b/var/spack/repos/builtin/packages/foam-extend/package.py @@ -39,20 +39,6 @@ class FoamExtend(Package): depends_on('paraview', when='+paraview') - def _get_env(self, command): - proc = subprocess.Popen(['bash', '-c', command], - stdout=subprocess.PIPE) - env = {} - for line in proc.stdout: - try: - key, val = line.split('=', 1) - env[key] = val.strip() - except: - # it may fail due to some bash functions that are on - # multiple lines - pass - return env - def set_arch(self): (sysname, nodename, release, version, machine) = os.uname() @@ -78,26 +64,11 @@ class FoamExtend(Package): return (arch, foam_compiler) - def get_openfoam_environment(self, env_openfoam): - env_before = self._get_env('env') - # This gets the environment set in case the etc/bashrc file is - # sourced - with working_dir(self.stage.source_path): - env_after = self._get_env('source etc/bashrc && env') - - # Removes some PATH to not add useless information in the - # environment later on - if 'PATH' in env_after: - del env_after['PATH'] - - if 'LD_LIBRARY_PATH' in env_after: - del env_after['LD_LIBRARY_PATH'] - - # Checks what was set in addition to the current environment, - # that should be the variables set by the bashrc - for key, value in env_after.iteritems(): - if key not in env_before or not value == env_before[key]: - env_openfoam.set(key, value) + def get_openfoam_environment(self): + return EnvironmentModifications.from_sourcing_files( + join_path(self.stage.source_path, + 'etc/bashrc') + ) def patch(self): # change names to match the package and not the one patch in @@ -242,8 +213,7 @@ class FoamExtend(Package): run_env.set('FOAM_INST_DIR', self.prefix) def install(self, spec, prefix): - env_openfoam = EnvironmentModifications() - self.get_openfoam_environment(env_openfoam) + env_openfoam = self.get_openfoam_environment() env_openfoam.apply_modifications() if self.parallel: |