Skip to content

Commit

Permalink
update method and location to install custom_ctypes
Browse files Browse the repository at this point in the history
  • Loading branch information
truib committed Jun 5, 2024
1 parent 8c1daf1 commit a92de97
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 110 deletions.
5 changes: 3 additions & 2 deletions EESSI-install-software.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ fi

# Install extra software that is needed (e.g., for providing a custom ctypes
# library when needed)
echo "Location of host_injections: $(ls -l ${EESSI_CVMFS_REPO}/host_injections)"
${EESSI_PREFIX}/scripts/extra/install_custom_ctypes.sh --temp-dir /tmp/temp
cd ${TOPDIR}/scripts/extra
./install_extra_packages.sh --temp-dir /tmp/temp --easystack eessi-2023.06-extra-packages.yml
cd ${TOPDIR}

# use PR patch file to determine in which easystack files stuff was added
changed_easystacks=$(cat ${pr_diff} | grep '^+++' | cut -f2 -d' ' | sed 's@^[a-z]/@@g' | grep '^easystacks/.*yml$' | egrep -v 'known-issues|missing')
Expand Down
8 changes: 2 additions & 6 deletions eb_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,7 @@ def parse_hook_librosa_custom_ctypes(ec, *args, **kwargs):
if ec.name == 'librosa' and ec.version in ('0.10.1',):
ec_dict = ec.asdict()
eessi_software_path = get_eessi_envvar('EESSI_SOFTWARE_PATH')
custom_ctypes_path = eessi_software_path.replace('versions', 'host_injections', 1)
custom_ctypes_path = custom_ctypes_path.replace('software', 'extra', 1)
custom_ctypes_path = os.path.join(custom_ctypes_path, "custom_ctypes")
custom_ctypes_path = os.path.join(eessi_software_path, "software", "custom_ctypes", "1.2")
ebpythonprefixes = "EBPYTHONPREFIXES=%s" % custom_ctypes_path
exts_list_new = []
for item in ec_dict['exts_list']:
Expand Down Expand Up @@ -891,9 +889,7 @@ def pre_module_hook_librosa_augment_modluafooter(self, *args, **kwargs):
"""
if self.name == 'librosa' and self.version == '0.10.1':
eessi_software_path = get_eessi_envvar('EESSI_SOFTWARE_PATH')
custom_ctypes_path = eessi_software_path.replace('versions', 'host_injections', 1)
custom_ctypes_path = custom_ctypes_path.replace('software', 'extra', 1)
custom_ctypes_path = os.path.join(custom_ctypes_path, 'custom_ctypes')
custom_ctypes_path = os.path.join(eessi_software_path, "software", "custom_ctypes", "1.2")
key = 'modluafooter'
values = ['prepend_path("EBPYTHONPREFIXES","%s")' % (custom_ctypes_path)]
print_msg("Adding '%s' to modluafooter", values[0])
Expand Down
6 changes: 0 additions & 6 deletions install_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ nvidia_files=(
)
copy_files_by_list ${TOPDIR}/scripts/gpu_support/nvidia ${INSTALL_PREFIX}/scripts/gpu_support/nvidia "${nvidia_files[@]}"

# Copy files for the scripts/extra directory
extra_files=(
install_custom_ctypes.sh
)
copy_files_by_list ${TOPDIR}/scripts/extra ${INSTALL_PREFIX}/scripts/extra "${extra_files[@]}"

# Copy over EasyBuild hooks file used for installations
hook_files=(
eb_hooks.py
Expand Down
29 changes: 29 additions & 0 deletions scripts/extra/custom_ctypes-1.2.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##
# This is a contribution from the NESSI project
# Homepage: https://documentation.sigma2.no
#
# Authors:: Thomas Roeblitz <[email protected]>
# License:: GPL-2.0-only
#
##

easyblock = 'Tarball'

name = 'custom_ctypes'
version = '1.2'

homepage = 'https://github.com/ComputeCanada/custom_ctypes'
description = """custum_ctypes is a small Python package to fix the discovery of libraries with Python's ctypes module. It changes the behavior of find_library to return absolute paths to shared objects rather than just the names."""

toolchain = SYSTEM

source_urls = ['https://github.com/ComputeCanada/custom_ctypes/archive/refs/tags']
sources = ['%(version)s.tar.gz']
checksums = ['3b30ce633c6a329169f2b10ff24b8eaaeef3fa208a66cdacdb53c22f02a88d9b']

sanity_check_paths = {
'files': ['README.md'],
'dirs': ['lib'],
}

moduleclass = 'lib'
2 changes: 2 additions & 0 deletions scripts/extra/eessi-2023.06-extra-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
easyconfigs:
- custom_ctypes-1.2.eb
96 changes: 0 additions & 96 deletions scripts/extra/install_custom_ctypes.sh

This file was deleted.

95 changes: 95 additions & 0 deletions scripts/extra/install_extra_packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env bash

# This script can be used to install extra packages under ${EESSI_SOFTWARE_PATH}

# some logging
echo ">>> Running ${BASH_SOURCE}"

# Initialise our bash functions
TOPDIR=$(dirname $(realpath ${BASH_SOURCE}))
source "${TOPDIR}"/../utils.sh

# Function to display help message
show_help() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --help Display this help message"
echo " -e, --easystack EASYSTACKFILE Easystack file which specifies easyconfigs to be installed."
echo " -t, --temp-dir /path/to/tmpdir Specify a location to use for temporary"
echo " storage during the installation"
}

# Initialize variables
TEMP_DIR=
EASYSTACK_FILE=

# Parse command-line options
while [[ $# -gt 0 ]]; do
case "$1" in
--help)
show_help
exit 0
;;
-e|--easystack)
if [ -n "$2" ]; then
EASYSTACK_FILE="$2"
shift 2
else
echo "Error: Argument required for $1"
show_help
exit 1
fi
;;
-t|--temp-dir)
if [ -n "$2" ]; then
TEMP_DIR="$2"
shift 2
else
echo "Error: Argument required for $1"
show_help
exit 1
fi
;;
*)
show_help
fatal_error "Error: Unknown option: $1"
;;
esac
done

if [[ -z ${EASYSTACK_FILE} ]]; then
show_help
fatal_error "Error: need to specify easystack file"
fi

# Make sure NESSI is initialised
check_eessi_initialised

# As an installation location just use $EESSI_SOFTWARE_PATH
export NESSI_CVMFS_INSTALL=${EESSI_SOFTWARE_PATH}

# we need a directory we can use for temporary storage
if [[ -z "${TEMP_DIR}" ]]; then
tmpdir=$(mktemp -d)
else
mkdir -p ${TEMP_DIR}
tmpdir=$(mktemp -d --tmpdir=${TEMP_DIR} extra.XXX)
if [[ ! -d "$tmpdir" ]] ; then
fatal_error "Could not create directory ${tmpdir}"
fi
fi
echo "Created temporary directory '${tmpdir}'"
export WORKING_DIR=${tmpdir}

# load EasyBuild
ml EasyBuild

# load NESSI-extend/2023.06-easybuild
ml NESSI-extend/2023.06-easybuild

eb --show-config

eb --easystack ${EASYSTACK_FILE} --robot

# clean up tmpdir
rm -rf "${tmpdir}"

0 comments on commit a92de97

Please sign in to comment.