Skip to content
Open
20 changes: 1 addition & 19 deletions easybuild/easyblocks/generic/juliabundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

@author: Alex Domingo (Vrije Universiteit Brussel)
"""
import os

from easybuild.easyblocks.generic.bundle import Bundle
from easybuild.easyblocks.generic.juliapackage import EXTS_FILTER_JULIA_PACKAGES, JuliaPackage

Expand Down Expand Up @@ -76,23 +74,7 @@ def __init__(self, *args, **kwargs):

self.log.info("exts_default_options: %s", self.cfg['exts_default_options'])

def prepare_step(self, *args, **kwargs):
"""Prepare for installing bundle of Julia packages."""
super().prepare_step(*args, **kwargs)

def install_step(self):
"""Prepare installation environment and dd all dependencies to project environment."""
"""Prepare installation environment and add all dependencies to project environment."""
self.prepare_julia_env()
self.include_pkg_dependencies()

def sanity_check_step(self, *args, **kwargs):
"""Custom sanity check for bundle of Julia packages"""
custom_paths = {
'files': [],
'dirs': [os.path.join('packages', self.name)],
}
super().sanity_check_step(custom_paths=custom_paths)

def make_module_extra(self, *args, **kwargs):
"""Custom module environment from JuliaPackage"""
return super().make_module_extra(*args, **kwargs)
33 changes: 28 additions & 5 deletions easybuild/easyblocks/generic/juliapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import glob
import os
import re
import tempfile

from easybuild.tools import LooseVersion

Expand Down Expand Up @@ -118,6 +119,18 @@ def get_julia_env(env_var):

return parsed_var

def __init__(self, *args, **kwargs):
"""Initialize JuliaPackage easyblock."""
super().__init__(*args, **kwargs)
self._tmp_depot_path = None

@property
def tmp_depot_path(self):
"""Temporary path to be used as top DEPOT_PATH during module load."""
if not self._tmp_depot_path:
self._tmp_depot_path = tempfile.mkdtemp(suffix='-julia_depot')
return self._tmp_depot_path

def julia_env_path(self, absolute=True, base=True):
"""
Return path to installation environment file.
Expand Down Expand Up @@ -259,6 +272,7 @@ def install_pkg(self):
def prepare_step(self, *args, **kwargs):
"""Prepare for Julia package installation."""
super().prepare_step(*args, **kwargs)
print("Julia prepare")
Comment thread
Flamefire marked this conversation as resolved.
Outdated

if get_software_root('Julia') is None:
raise EasyBuildError("Julia not included as dependency!")
Expand Down Expand Up @@ -294,18 +308,27 @@ def install_extension(self):
self.prepare_julia_env()
self.install_pkg()

def load_module(self, *args, **kwargs):
"""Set JULIA_DEPOT_PATH to a temporary directory and exclude the users depot path to avoid writing to $HOME

Required for e.g. sanity checks that run a julia command.
"""
super().load_module(*args, **kwargs)

depot_path = os.environ['JULIA_DEPOT_PATH'].strip(':') # Always set by module
# Append a colon at the end to exclude the users depot path (in $HOME)
env.setvar('JULIA_DEPOT_PATH', f"{self.tmp_depot_path}:{depot_path}:")
Comment thread
Crivella marked this conversation as resolved.
Outdated

def sanity_check_step(self, *args, **kwargs):
"""Custom sanity check for JuliaPackage"""

pkg_dir = os.path.join('packages', self.name)

custom_paths = {
'files': [],
'dirs': [pkg_dir],
'dirs': [os.path.join('packages', self.name)],
}
kwargs.update({'custom_paths': custom_paths})
kwargs.setdefault('custom_paths', custom_paths)
Comment thread
Crivella marked this conversation as resolved.

return ExtensionEasyBlock.sanity_check_step(self, EXTS_FILTER_JULIA_PACKAGES, *args, **kwargs)
return super().sanity_check_step(EXTS_FILTER_JULIA_PACKAGES, *args, **kwargs)

def make_module_extra(self, *args, **kwargs):
"""
Expand Down
Loading