-
Notifications
You must be signed in to change notification settings - Fork 163
/
build.sh
executable file
·107 lines (91 loc) · 2.46 KB
/
build.sh
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
#!/bin/bash
#
# Script to build cryptography and/or related python packages for lambda.
#
# Requires two arguments: package and version.
#
# You can use it to build inside an Amazon Linux AMI (default) or with docker
# with --docker (you need docker installed and network access to reach lambci's
# docker-lambda image).
#
# Defaults to building both python2.7 and python3.6 packages. If you only want
# one of them use either --py2-only or --py3-only.
#
set -e
DOCKER=0
PY2=1
PY3=1
SUDO=sudo
while [[ $# -gt 2 ]]
do
key="$1"
case $key in
--docker)
DOCKER=1
SUDO=""
shift
;;
--py2-only)
PY2=1
PY3=0
shift
;;
--py3-only)
PY2=0
PY3=1
shift
;;
*)
shift
;;
esac
done
PACKAGE=${1}
VERSION=${2}
echo DOCKER = "${DOCKER}"
echo PY2 = "${PY2}"
echo PY3 = "${PY3}"
echo PACKAGE = "${PACKAGE}"
echo VERSION = "${VERSION}"
function build_package {
PACKAGE=${1}
VERSION=${2}
PYTHON=${3}
PIP=${4}
VIRTUALENV=${5}
TMP_DIR="${PYTHON}_${PACKAGE}_${VERSION}"
mkdir ${TMP_DIR}
cd ${TMP_DIR}
echo "install dependencies"
${SUDO} yum install -y yum-plugin-ovl
${SUDO} yum update -y
${SUDO} yum groupinstall -y "Development Tools"
${SUDO} yum install -y libffi libffi-devel openssl openssl-devel
if [ "${VIRTUALENV}" == "virtualenv" ]; then
${SUDO} ${PIP} install virtualenv
fi
echo "make virtualenv"
ENV="env-${PYTHON}-${PACKAGE}-${VERSION}"
echo ${VIRTUALENV} "${ENV}"
${VIRTUALENV} "${ENV}"
echo "activate env in `pwd`"
echo source "${ENV}/bin/activate"
source "${ENV}/bin/activate"
# https://github.com/pypa/pip/issues/3056
echo '[install]' > ./setup.cfg
echo 'install-purelib=$base/lib64/python' >> ./setup.cfg
echo "install pips"
TARGET_DIR=${ENV}/packaged
echo ${PIP} install --verbose --no-dependencies --target ${TARGET_DIR} "${PACKAGE}==${VERSION}"
${PIP} install --verbose --no-dependencies --target ${TARGET_DIR} "${PACKAGE}==${VERSION}"
deactivate
TARGET_DIR=${ENV}/packaged
cd ${TARGET_DIR} && tar -zcvf ../../../${PYTHON}-${PACKAGE}-${VERSION}.tar.gz * && cd ../../..
rm -r ${TMP_DIR}
}
if [ ${PY2} == 1 ]; then
build_package ${PACKAGE} ${VERSION} python2.7 pip virtualenv
fi
if [ ${PY3} == 1 ]; then
build_package ${PACKAGE} ${VERSION} python3.6 pip3.6 "python3.6 -m venv "
fi