blob: c92e7c53d19c2cf7ac71495031ef446d7b43d463 (
plain)
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
|
#!/bin/bash
# @author: <sylvain.herledan@hrafnagud.info>
# @date: 2017-06-06
set -o nounset
set -o errexit
set -o pipefail
readonly PROGNAME="$(basename "${0}")";
readonly PROGDIR="$(readlink -f "$(dirname "${0}")")";
readonly ARGS="${@}";
install_virtualenv()
{
local python="${1}"; shift;
local env_dir="${1}"; shift;
local install_script_path="$(mktemp)";
wget 'https://bootstrap.pypa.io/get-pip.py' -O "${install_script_path}"
mkdir -p "${env_dir}"
PYTHONUSERBASE="${env_dir}" \
"${python}" "${install_script_path}" --user --ignore-installed --no-cache
rm -f "${install_script_path}"
PYTHONUSERBASE="${env_dir}" \
"${env_dir}/bin/pip" install --user --ignore-installed --no-cache virtualenv
local virtualenv_path="$(find "${env_dir}/lib" -name 'virtualenv.py')";
local python_pkg_dir="$(readlink -f "$(dirname "${virtualenv_path}")")";
mkdir -p "${env_dir}/cache"
PIP_CACHE_DIR="${env_dir}/cache" \
PIP_IGNORE_INSTALLED=true \
PYTHONPATH="${python_pkg_dir}" \
"${python}" -m virtualenv "${env_dir}"
cat > "${env_dir}/pip.conf" << EOF
[global]
cache-dir=${env_dir}/cache
EOF
echo 'Environment ready'
}
main()
{
local python="${1}"; shift;
local _install_dir="${1}"; shift;
local install_dir="$(readlink -f "${_install_dir}")";
local env_dir="${install_dir}/env";
install_virtualenv "${python}" "${env_dir}"
}
main ${ARGS}
exit 0
|