forked from cloudfoundry/python-buildpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupply
More file actions
executable file
·117 lines (86 loc) · 3.49 KB
/
supply
File metadata and controls
executable file
·117 lines (86 loc) · 3.49 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
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
#!/usr/bin/env bash
# The Cloud Foundry Python Buildpack. This script accepts parameters for a build
# directory, a cache directory, and a directory for app environment variables.
#
# $ ./bin/supply <build_dir> <cache_dir> <deps_dir> <deps_index>
# Fail fast and fail hard.
set -euo pipefail
# Paths.
export BUILDPACK_PATH=$(dirname $(readlink -f ${BASH_SOURCE%/*}))
export BIN_DIR=$BUILDPACK_PATH/bin
export BUILD_DIR=$1
export CACHE_DIR=$2
export DEPS_DIR=$3
export DEPS_IDX=$4
source $BUILDPACK_PATH/compile-extensions/lib/common
source $BIN_DIR/utils
$BUILDPACK_PATH/compile-extensions/bin/check_stack_support
$BUILDPACK_PATH/compile-extensions/bin/check_buildpack_version $BUILDPACK_PATH $CACHE_DIR
env_vars=$($BUILDPACK_PATH/compile-extensions/bin/build_path_from_supply $DEPS_DIR)
for env_var in $env_vars; do
export $env_var
done
#setup directories
mkdir -p $DEPS_DIR/$DEPS_IDX/bin
mkdir -p $DEPS_DIR/$DEPS_IDX/env
mkdir -p $DEPS_DIR/$DEPS_IDX/include
mkdir -p $DEPS_DIR/$DEPS_IDX/lib
mkdir -p $DEPS_DIR/$DEPS_IDX/pkgconfig
mkdir -p $DEPS_DIR/$DEPS_IDX/profile.d
if [ -f $BUILD_DIR/environment.yml ]; then
echo "----------------- USING CONDA BUILDPACK -----------------"
# Experimental pre_compile hook.
pushd $BUILD_DIR >/dev/null
source $BIN_DIR/steps/hooks/pre_compile
popd >/dev/null
$BIN_DIR/steps/conda-supply
$BUILDPACK_PATH/compile-extensions/bin/write_config_yml $BUILDPACK_PATH $DEPS_DIR/$DEPS_IDX
exit 0
fi
# Prepend proper environment variables for Python use.
export PYTHONUNBUFFERED=1
export LANG=${LANG:-en_US.UTF-8}
set-env-prepend PATH $DEPS_DIR/$DEPS_IDX/bin
set-env-prepend LD_LIBRARY_PATH $DEPS_DIR/$DEPS_IDX/lib
# Switch to the repo's context.
cd $BUILD_DIR
# If no requirements.txt file given, assume `setup.py develop` is intended.
if [ ! -f requirements.txt ]; then
echo "-e ." > requirements.txt
fi
# Warn for lack of Procfile.
if [[ ! -f Procfile ]]; then
puts-warn 'Warning: Your application is missing a Procfile. This file tells Cloud Foundry how to run your application.'
puts-warn 'Learn more: https://docs.cloudfoundry.org/buildpacks/prod-server.html#procfile'
fi
# Restore old artifacts from the cache.
# (Move cache dirs to build dir (will copy back after build))
mv $CACHE_DIR/python $DEPS_DIR/$DEPS_IDX/python &> /dev/null || true
if [[ -d $CACHE_DIR/src ]]; then
mv $CACHE_DIR/src $DEPS_DIR/$DEPS_IDX/src &> /dev/null || true
fi
# Install pip-pop
cp -r $BUILDPACK_PATH/vendor/pip-pop $DEPS_DIR/$DEPS_IDX/pip-pop
pushd $DEPS_DIR/$DEPS_IDX/bin >/dev/null
ln -s ../pip-pop/* .
popd >/dev/null
# Experimental pre_compile hook.
source $BIN_DIR/steps/hooks/pre_compile
# Install Python,.
source $BIN_DIR/steps/python
source $BIN_DIR/steps/cryptography
source $BIN_DIR/steps/pylibmc
cp $BUILDPACK_PATH/vendor/python.gunicorn.sh $DEPS_DIR/$DEPS_IDX/profile.d/python.gunicorn.sh
set_default_profile_d PYTHONHASHSEED random
echo random > $DEPS_DIR/$DEPS_IDX/env/PYTHONHASHSEED
set_default_profile_d PYTHONPATH "\$DEPS_DIR/$DEPS_IDX"
echo "$DEPS_DIR/$DEPS_IDX" > $DEPS_DIR/$DEPS_IDX/env/PYTHONPATH
set_default_profile_d LANG en_US.UTF-8
echo $LANG > $DEPS_DIR/$DEPS_IDX/env/LANG
append_profile_d PYTHONHOME "\$DEPS_DIR/$DEPS_IDX/python"
echo $DEPS_DIR/$DEPS_IDX/python > $DEPS_DIR/$DEPS_IDX/env/PYTHONHOME
append_profile_d PYTHONUNBUFFERED 1
echo 1 > $DEPS_DIR/$DEPS_IDX/env/PYTHONUNBUFFERED
echo "$DEPS_DIR/$DEPS_IDX/lib" > $DEPS_DIR/$DEPS_IDX/env/LIBRARY_PATH
# Write config.yml
$BUILDPACK_PATH/compile-extensions/bin/write_config_yml $BUILDPACK_PATH $DEPS_DIR/$DEPS_IDX