Skip to content

Commit

Permalink
fix error when no spack
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Ejarque committed Feb 29, 2024
1 parent a5c1c8b commit 27da89f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
12 changes: 2 additions & 10 deletions files/Dockerfile.spack
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ COPY %APPDIR% /%APPDIR%
COPY software-catalog /software-catalog
COPY .spack /.spack
COPY packages /packages
COPY build_spack.sh /.spack/build_spack.sh

WORKDIR /packages

RUN echo "Installing apt-get packages" && %APTGET_INSTALL%

RUN [ ! /%APPDIR%/spack.yaml ] && echo "No spack environment to install" || echo "Installing spack packages" && spack -C /.spack find && cat /%APPDIR%/spack.yaml \
&& spack -C /.spack compiler find && spack -C /.spack external find && spack -C /.spack -e /%APPDIR% install --fail-fast --no-checksum --keep-stage -j2 \
&& [ -f /%APPDIR%/post_inst.sh ] && sh /%APPDIR%/post_inst.sh || echo "Nothing else to do"; spack gc -y
# && spack -C /.spack mirror add binary_mirror_dev https://binaries.spack.io/develop \
# && spack -C /.spack buildcache keys --install --trust \


RUN spack -C /.spack env activate /%APPDIR% --sh >> /etc/profile.d/z10_spack_environment.sh && \
echo "export PYTHONPATH=/opt/view/local/lib/python3.10/site-packages/:\$PYTHONPATH" >> /etc/profile.d/z10_spack_environment.sh && \
echo "export PATH=/usr/local/bin/:\$PATH" >> /etc/profile.d/z10_spack_environment.sh
RUN sh /.spack/build_spack.sh /%APPDIR% 3.10

SHELL ["/bin/bash", "--login", "-c"]

Expand Down
10 changes: 5 additions & 5 deletions image_builder/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def __init__(self, repositories_cfg, builder_cfg, registry_cfg):
builder_cfg["builder_home"], "files", "run_build.sh")
self.get_workflow_script = os.path.join(
builder_cfg["builder_home"], "files", "get_workflow.sh")
self.spack_build_script = os.path.join(
builder_cfg["builder_home"], "files", "build_spack.sh")
self.singularity_sudo = builder_cfg['singularity_sudo']

def _update_dockerfile(self, tmp_folder, step_id, machine, debs, pips):
Expand Down Expand Up @@ -128,11 +130,8 @@ def _update_configuration(self, workflow_folder_path, machine):
environment['spack']['config'] = {
'shared_linking': {'type': 'runpath'}}
environment['spack']['view'] = "/opt/view"
else:
raise Exception(
"Incorrect spack environment. Not containing the spack tag.")
with open(os.path.join(workflow_folder_path, "spack.yaml"), 'w') as file:
yaml.dump(environment, file, default_flow_style=False)
with open(os.path.join(workflow_folder_path, "spack.yaml"), 'w') as file:
yaml.dump(environment, file, default_flow_style=False)
return debs, pips

def _generate_build_environment(self, logger, tmp_folder, workflow, machine, path):
Expand All @@ -142,6 +141,7 @@ def _generate_build_environment(self, logger, tmp_folder, workflow, machine, pat
debs, pips = self._update_configuration(workflow_folder_path, machine)
software_repo_path = os.path.join(
tmp_folder, os.path.basename(self.software_repository))
shutil.copy2(self.spack_build_script, tmp_folder)
shutil.copytree(self.software_repository, software_repo_path)
spack_cfg_path = os.path.join(tmp_folder, ".spack")
shutil.copytree(self.spack_cfg, spack_cfg_path)
Expand Down

0 comments on commit 27da89f

Please sign in to comment.