forked from cloudfoundry/python-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython
More file actions
executable file
·84 lines (66 loc) · 2.33 KB
/
python
File metadata and controls
executable file
·84 lines (66 loc) · 2.33 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
PYTHON_VERSION=$(cat runtime.txt)
# Install Python.
if [ -f .heroku/python-version ]; then
if [ ! $(cat .heroku/python-version) = $PYTHON_VERSION ]; then
bpwatch start uninstall_python
puts-step "Found $(cat .heroku/python-version), removing"
rm -fr .heroku/python
bpwatch stop uninstall_python
else
SKIP_INSTALL=1
fi
fi
if [ ! $STACK = $CACHED_PYTHON_STACK ]; then
bpwatch start uninstall_python
rm -fr .heroku/python .heroku/python-stack .heroku/vendor
unset SKIP_INSTALL
bpwatch stop uninstall_python
fi
if [ ! "$SKIP_INSTALL" ]; then
bpwatch start install_python
puts-step "Installing $PYTHON_VERSION"
# Prepare destination directory.
mkdir -p .heroku/python
exit_code=0
url="https://lang-python.s3.amazonaws.com/$STACK/runtimes/$PYTHON_VERSION.tar.gz"
filtered_url=$($ROOT_DIR/compile-extensions/bin/download_dependency $url /tmp) || exit_code=$?
if [ $exit_code -ne 0 ]; then
$ROOT_DIR/compile-extensions/bin/recommend_dependency $url
exit 1
fi
$ROOT_DIR/compile-extensions/bin/warn_if_newer_patch $url "$ROOT_DIR/manifest.yml"
downloaded_file=/tmp/$PYTHON_VERSION.tar.gz
tar zxvf $downloaded_file -C .heroku/python &> /dev/null
rm $downloaded_file
echo "Downloaded [$filtered_url]"
bpwatch stop install_python
# Record for future reference.
echo $PYTHON_VERSION > .heroku/python-version
echo $STACK > .heroku/python-stack
FRESH_PYTHON=true
hash -r
fi
# If Pip isn't up to date:
if [ "$FRESH_PYTHON" ] || [[ ! $(pip --version) == *$PIP_VERSION* ]]; then
WORKING_DIR=$(pwd)
bpwatch start prepare_environment
TMPTARDIR=$(mktemp -d)
trap "rm -rf $TMPTARDIR" RETURN
bpwatch start install_setuptools
# Prepare it for the real world
# puts-step "Installing Setuptools ($SETUPTOOLS_VERSION)"
tar zxf $ROOT_DIR/vendor/setuptools-$SETUPTOOLS_VERSION.tar.gz -C $TMPTARDIR
cd $TMPTARDIR/setuptools-$SETUPTOOLS_VERSION/
python setup.py install &> /dev/null
cd $WORKING_DIR
bpwatch stop install_setuptoools
bpwatch start install_pip
# puts-step "Installing Pip ($PIP_VERSION)"
tar zxf $ROOT_DIR/vendor/pip-$PIP_VERSION.tar.gz -C $TMPTARDIR
cd $TMPTARDIR/pip-$PIP_VERSION/
python setup.py install &> /dev/null
cd $WORKING_DIR
bpwatch stop install_pip
bpwatch stop prepare_environment
fi
hash -r