Skip to content

Commit

Permalink
Add arg for specifying spack temp. directory
Browse files Browse the repository at this point in the history
This is useful if the default (`/tmp`) tends to run out of space.
  • Loading branch information
xylar committed Mar 22, 2022
1 parent d7ce808 commit 73a7b2c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion mache/spack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,
machine=None, include_e3sm_hdf5_netcdf=False,
yaml_template=None):
yaml_template=None, tmpdir=None):
"""
Clone the ``spack_for_mache_{{version}}`` branch from
`E3SM's spack clone <https://github.com/E3SM-Project/spack>`_ and build
Expand Down Expand Up @@ -46,6 +46,9 @@ def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,
A jinja template for a yaml file to be used for the environment instead
of the mache template. This allows you to use compilers and other
modules that differ from E3SM.
tmpdir : str, optional
A temporary directory for building spack packages
"""

if machine is None:
Expand Down Expand Up @@ -94,6 +97,10 @@ def make_spack_env(spack_path, env_name, spack_specs, compiler, mpi,

template = Template(
resources.read_text('mache.spack', 'build_spack_env.template'))
if tmpdir is not None:
modules = f'{modules}\n' \
f'export TMPDIR={tmpdir}'

build_file = template.render(modules=modules, version=__version__,
spack_path=spack_path, env_name=env_name,
yaml_filename=yaml_filename)
Expand Down

0 comments on commit 73a7b2c

Please sign in to comment.