Skip to content

Commit ffb9fd1

Browse files
committed
Setup pyyaml on singularity
Signed-off-by: Afonso Oliveira <[email protected]>
1 parent ea22ce2 commit ffb9fd1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

bin/python

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
ROOT=$(dirname $(dirname $(realpath $BASH_SOURCE[0])))
4+
CONTAINER_TAG=$(cat ${ROOT}/bin/.container-tag)
5+
CONTAINER_PATH=${ROOT}/.singularity/image-${CONTAINER_TAG}.sif
6+
HOME_OPT="--bind ${ROOT}/.home:${HOME}"
7+
8+
# Create virtual environment using absolute path
9+
echo "Creating virtual environment..."
10+
singularity exec ${HOME_OPT} ${CONTAINER_PATH} /usr/bin/python3 -m venv ${ROOT}/.home/.venv
11+
12+
# Install packages
13+
echo "Installing packages..."
14+
singularity exec ${HOME_OPT} ${CONTAINER_PATH} bash -c "source ${ROOT}/.home/.venv/bin/activate && pip install pyyaml"

bin/setup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,16 @@ if [ ! -d ${ROOT}/node_modules ]; then
8686
singularity run ${HOME_OPT} ${CONTAINER_PATH} npm i
8787
fi
8888

89+
if [ ! -d ${ROOT}/.home/.venv ]; then
90+
singularity run ${HOME_OPT} ${CONTAINER_PATH} python3 -m venv ${ROOT}/.home/.venv
91+
singularity run ${HOME_OPT} ${CONTAINER_PATH} bash -c "source ${ROOT}/.home/.venv/bin/activate && pip install pyyaml"
92+
fi
93+
8994
BUNDLE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle"
9095
RUBY="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec ruby"
9196
RAKE="singularity run ${HOME_OPT} ${CONTAINER_PATH} bundle exec rake"
9297
NPM="singularity run ${HOME_OPT} ${CONTAINER_PATH} npm"
9398
NPX="singularity run ${HOME_OPT} ${CONTAINER_PATH} npx"
9499
NODE="singularity run ${HOME_OPT} ${CONTAINER_PATH} node"
100+
PYTHON="singularity run ${HOME_OPT} ${CONTAINER_PATH} bash -c 'source ${ROOT}/.home/.venv/bin/activate && python'"
101+

0 commit comments

Comments
 (0)