-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathactivate_venv
136 lines (108 loc) · 4.39 KB
/
activate_venv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
# Bootstrap a new VEnv in ./_illuminatus_venv suitable for running Illuminatus.
# This seemed easier than using setup.py but maybe I just lack imagination.
# As of illuminatus 1.5 this will also install Snakemake as part of the VEnv.
if [[ "$0" == "$BASH_SOURCE" ]] ; then
echo "You need to source this file, not run it."
exit 1
fi
activate_venv() {
#We need to ensure -u is not set but then put the old value back.
local reset=`set +o | grep -w nounset` ; set +o nounset
source ./_illuminatus_venv/bin/activate
$reset
}
pip_install() {
# Send all output to stdout
pip3 --disable-pip-version-check install "$@" 2>&1
}
upgrade_multiqc() {
# Install/upgrade MultiQC from GIT
# $ ./_illuminatus_venv/bin/pip install --force-reinstall --no-deps --no-binary ':all:' \
# 'git+https://github.com/EdinburghGenomics/MultiQC.git@tim_branch#egg=multiqc'
# For now, use the dev branch
# Also note that leaving out "--no-binary ':all:'" currently triggers a weird bug where the interpreter is
# not properly munged and you get the error "python: bad interpreter"
# For now we need specific older versions of these modules:
pip_install 'networkx<2' 'spectra==0.0.8' 'colormath<3' \
'Jinja2<3' 'kiwisolver<1.4' 'pillow<9' \
'Markdown<3.4' 'python-dateutil<3' 'pyparsing<3.1' \
'matplotlib<3.4' 'simplejson<4'
for url in \
'git+https://github.com/EdinburghGenomics/MultiQC.git@tim_branch#egg=multiqc' \
'git+https://github.com/EdinburghGenomics/MultiQC_EdGen.git@master#egg=multiqc_edgen'
do
if [ "${1:-}" == 'initial' ] ; then
pip_install --no-binary ':all:' "$url"
else
pip_install --force-reinstall --no-deps --no-binary ':all:' "$url"
fi
done
# Quick check that it's (maybe) working:
python -c "from multiqc.utils import config ; config.avail_modules['fastqc'].load()"
}
post_activate() {
# If the toolbox has a post_activate_venv.sh then run it.
_pav="${TOOLBOX:-`dirname $BASH_SOURCE`/toolbox}"/post_activate_venv.sh
if [ -e "$_pav" ] ; then
echo "Running commands in $_pav"
source "$_pav"
fi
}
install_wheels() {
if [ -d "${1:-}" ] ; then
echo "Installing pre-built wheel files from $1"
pip_install -- "$1"/*.whl
fi
}
if [ -e ./_illuminatus_venv/bin/activate ] ; then
# We already got one!
activate_venv
else
( _toolbox="${TOOLBOX:-`dirname $BASH_SOURCE`/toolbox}"
_py3="$_toolbox"/bootstrap_python3
_py3_real="$(readlink -m "$_py3")"
echo "Bootstrapping new VEnv from $_py3 ($_py3_real)"
set -e
"$_py3_real" -mvenv ./_illuminatus_venv
activate_venv
pip_install --upgrade pip wheel
# Install any pre-built wheels
install_wheels "${WHEELS:-${_toolbox}/wheels}"
# My test helper
pip_install bashmocker==0.3.0
pip_install packaging coverage
pip_install pyyaml==6.0.1
pip_install 'yamlloader<2'
pip_install rt==2.2.2
# For access the Clarity
pip_install pyclarity_lims==0.4.8
pip_install psycopg2-binary==2.9.5 || pip_install 'psycopg2-binary<2.10'
pip_install chevron # Only needed for PDF states report
pip_install pyflakes
# InterOP is now on PyPI so no pre-build needed :-)
pip_install 'numpy<2'
pip_install interop==1.3.2
# Needed if well_dups runs in the local VEnv, which it currently does.
pip_install python-Levenshtein==0.12.1
# snakemake and drmaa (note the settings/wrapper in shell_helper_functions.sh)
pip_install snakemake==5.5.3
pip_install drmaa==0.7.9
# My own MultiQC and MultiQC_EdGen. Pip installs directly from GIT so
# why not? Assume the master branch is always good, since it's simpler than
# searching for the last release tag (though that is possible).
# see https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support
upgrade_multiqc initial
post_activate
)
if [ $? = 0 ] ; then
echo "VEnv provisioned OK"
unset -f post_activate
# We need this since we quit the subshell
activate_venv
else
unset -f post_activate upgrade_multiqc pip_install
echo "Provisioning VEnv Failed!"
false
fi
fi