changes to use from_sourcing_file
This commit is contained in:
parent
97feca0888
commit
7cf1313572
@ -39,20 +39,6 @@ class FoamExtend(Package):
|
|||||||
|
|
||||||
depends_on('paraview', when='+paraview')
|
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):
|
def set_arch(self):
|
||||||
(sysname, nodename, release, version, machine) = os.uname()
|
(sysname, nodename, release, version, machine) = os.uname()
|
||||||
|
|
||||||
@ -78,26 +64,11 @@ def set_arch(self):
|
|||||||
|
|
||||||
return (arch, foam_compiler)
|
return (arch, foam_compiler)
|
||||||
|
|
||||||
def get_openfoam_environment(self, env_openfoam):
|
def get_openfoam_environment(self):
|
||||||
env_before = self._get_env('env')
|
return EnvironmentModifications.from_sourcing_files(
|
||||||
# This gets the environment set in case the etc/bashrc file is
|
join_path(self.stage.source_path,
|
||||||
# sourced
|
'etc/bashrc')
|
||||||
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 patch(self):
|
def patch(self):
|
||||||
# change names to match the package and not the one patch in
|
# change names to match the package and not the one patch in
|
||||||
@ -242,8 +213,7 @@ def setup_environment(self, spack_env, run_env):
|
|||||||
run_env.set('FOAM_INST_DIR', self.prefix)
|
run_env.set('FOAM_INST_DIR', self.prefix)
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
env_openfoam = EnvironmentModifications()
|
env_openfoam = self.get_openfoam_environment()
|
||||||
self.get_openfoam_environment(env_openfoam)
|
|
||||||
env_openfoam.apply_modifications()
|
env_openfoam.apply_modifications()
|
||||||
|
|
||||||
if self.parallel:
|
if self.parallel:
|
||||||
|
Loading…
Reference in New Issue
Block a user