summaryrefslogtreecommitdiffstats
path: root/setup.sh
blob: cf1d366859fbad2c852fc986fd3fa8e7f051e170 (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
#!/bin/sh

# @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 install_dir="${1}"; shift;
  local install_script_path="$(mktemp)";
  local env_dir="${install_dir}/env";

  wget 'https://bootstrap.pypa.io/get-pip.py' -O "${install_script_path}"
  mkdir -p "${env_dir}"
  
  PYTHONUSERBASE="${env_dir}" python "${install_script_path}" --user
  rm -f "${install_script_path}"

  PYTHONUSERBASE="${env_dir}" "${env_dir}/bin/pip" install --user virtualenv

  local python_pkg_dir="$(find "${env_dir}/lib" -type d -name "*-packages" | head -1)";
  PYTHONPATH="${python_pkg_dir}" env/bin/virtualenv env
}

install_virtualenv ${ARGS}
exit 0