-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpythonw
More file actions
69 lines (57 loc) · 1.72 KB
/
pythonw
File metadata and controls
69 lines (57 loc) · 1.72 KB
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
#!/usr/bin/env bash
## downloads URl to file OUTPUT
## download is skipped if file SIZE is supplied and file exists and size matches
function download() {
URL=$1
OUTPUT=$2
SIZE=$3
if [ -n "$SIZE" -a -f "$OUTPUT" ]; then
if [ $(stat -c%s "$OUTPUT") == "$SIZE" ]; then
echo "$OUTPUT already downloaded, size matched"
return 0
else
echo "$OUTPUT size differs redownloading from $URL..."
fi
fi
mkdir -p $(dirname "$OUTPUT")
if which curl; then
curl --location --output "$OUTPUT" "$URL"
elif which wget; then
wget "--output-document=$OUTPUT" "$URL"
else
echo "unable to download $1 neither wget nor curl found"
exit 1
fi
if [ -n "$SIZE" ]; then
if [ $(stat -c%s "$OUTPUT") != $SIZE ]; then
echo "size differs after download, it was unsuccessfull"
return 1
fi
fi
}
#
SELFDIR=$(dirname "$0")
ROOT="$SELFDIR/.python/linux"
PYTHON_HOME="$ROOT/miniconda/envs/default"
# requirements
if [ ! -f "$PYTHON_HOME/bin/activate" ]; then
# install
if [ ! -d "$ROOT/miniconda" ]; then
mkdir -p "$ROOT/temp"
download https://repo.continuum.io/miniconda/Miniconda3-4.2.12-Linux-x86.sh "$ROOT/temp/miniconda-installer.sh" 29051880
echo "miniconda is to be installed into $ROOT/miniconda"
bash "$ROOT/temp/miniconda-installer.sh" -b -p "$ROOT/miniconda"
fi
echo "virtual environment is to be installed into $PYTHON_HOME"
echo y | "$ROOT/miniconda/bin/conda" create --name default pip
fi
source "$ROOT/miniconda/bin/activate" default
if [ -f requirements.txt ]; then
PIP_INSTALL_OUTPUT=$("$PYTHON_HOME/bin/pip" install -r ./requirements.txt)
RESULT_CODE=$?
if [ 0 != $RESULT_CODE ]; then
echo "$PIP_INSTALL_OUTPUT"
exit $RESULT_CODE
fi
fi
"$PYTHON_HOME/bin/python" "$@"