-
Notifications
You must be signed in to change notification settings - Fork 87
/
travis_linux_steps.sh
151 lines (144 loc) · 5.02 KB
/
travis_linux_steps.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
# Wheel build, install, run test steps on Linux
#
# In fact the main work is to wrap up the real functions in docker commands.
# The real work is in the BUILD_SCRIPT (which builds the wheel) and
# `docker_install_run.sh`, which can be configured with `config.sh`.
#
# Must define
# before_install
# build_wheel
# install_run
set -e
# Get our own location on this filesystem
MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
# Allow travis Python version as proxy for multibuild Python version
MB_PYTHON_VERSION=${MB_PYTHON_VERSION:-$TRAVIS_PYTHON_VERSION}
function before_install {
# Install a virtualenv to work in.
virtualenv --python=$PYTHON_EXE venv
source venv/bin/activate
python --version # just to check
pip install --upgrade pip wheel
}
function build_wheel {
# Builds wheel, puts into $WHEEL_SDIR
#
# In fact wraps the actual work which happens in the container.
#
# Depends on
# REPO_DIR (or via input argument)
# PLAT (can be passed in as argument)
# MB_PYTHON_VERSION
# BUILD_COMMIT
# UNICODE_WIDTH (optional)
# BUILD_DEPENDS (optional)
# MANYLINUX_URL (optional)
# WHEEL_SDIR (optional)
local repo_dir=${1:-$REPO_DIR}
[ -z "$repo_dir" ] && echo "repo_dir not defined" && exit 1
local plat=${2:-${PLAT:-x86_64}}
build_multilinux $plat "build_wheel $repo_dir"
}
function build_index_wheel {
# Builds wheel from an index (e.g pypi), puts into $WHEEL_SDIR
#
# In fact wraps the actual work which happens in the container.
#
# Depends on
# PLAT (can be passed in as argument)
# MB_PYTHON_VERSION
# UNICODE_WIDTH (optional)
# BUILD_DEPENDS (optional)
# MANYLINUX_URL (optional)
# WHEEL_SDIR (optional)
local project_spec=$1
[ -z "$project_spec" ] && echo "project_spec not defined" && exit 1
local plat=${2:-${PLAT:-x86_64}}
build_multilinux $plat "build_index_wheel $project_spec"
}
function build_multilinux {
# Runs passed build commands in manylinux container
#
# Depends on
# MB_PYTHON_VERSION
# MB_ML_VER
# MB_ML_LIBC (optional)
# UNICODE_WIDTH (optional)
# BUILD_DEPENDS (optional)
# DOCKER_IMAGE (optional)
# MANYLINUX_URL (optional)
# WHEEL_SDIR (optional)
local plat=$1
[ -z "$plat" ] && echo "plat not defined" && exit 1
local build_cmds="$2"
local libc=${MB_ML_LIBC:-manylinux}
local docker_image=${DOCKER_IMAGE:-quay.io/pypa/${libc}${MB_ML_VER}_\$plat}
docker_image=$(eval echo "$docker_image")
retry docker pull $docker_image
docker run --rm \
-e BUILD_COMMANDS="$build_cmds" \
-e PYTHON_VERSION="$MB_PYTHON_VERSION" \
-e MB_PYTHON_VERSION="$MB_PYTHON_VERSION" \
-e UNICODE_WIDTH="$UNICODE_WIDTH" \
-e BUILD_COMMIT="$BUILD_COMMIT" \
-e CONFIG_PATH="$CONFIG_PATH" \
-e ENV_VARS_PATH="$ENV_VARS_PATH" \
-e WHEEL_SDIR="$WHEEL_SDIR" \
-e MANYLINUX_URL="$MANYLINUX_URL" \
-e BUILD_DEPENDS="$BUILD_DEPENDS" \
-e USE_CCACHE="$USE_CCACHE" \
-e REPO_DIR="$repo_dir" \
-e PLAT="$PLAT" \
-e MB_ML_VER="$MB_ML_VER" \
-e MB_ML_LIBC="$libc" \
-v $PWD:/io \
-v $HOME:/parent-home \
$docker_image /io/$MULTIBUILD_DIR/docker_build_wrap.sh
}
function install_run {
# Install wheel, run tests
#
# In fact wraps the actual work which happens in the container.
#
# Depends on
# PLAT (can be passed in as argument)
# MB_PYTHON_VERSION
# MB_ML_LIBC (optional)
# UNICODE_WIDTH (optional)
# WHEEL_SDIR (optional)
# MANYLINUX_URL (optional)
# TEST_DEPENDS (optional)
# MB_TEST_VER (optional)
local plat=${1:-${PLAT:-x86_64}}
if [ -z "$DOCKER_TEST_IMAGE" ]; then
if [ "$MB_ML_LIBC" == "musllinux" ]; then
# PLAT is the same as $plat,
# unless $plat is "aarch64", in which case it becomes "arm64v8"
local docker_image="multibuild/alpine3.17_{PLAT}"
elif [ "$plat" == i686 ]; then
local docker_image="matthewbrett/trusty:32"
else
# PLAT is the same as $plat,
# unless $plat is "aarch64", in which case it becomes "arm64v8"
local docker_image="multibuild/focal_{PLAT}"
fi
else
local docker_image="$DOCKER_TEST_IMAGE"
fi
# aarch64 is called arm64v8 in Ubuntu
local plat_subst=$([ "$plat" == aarch64 ] && echo arm64v8 || echo $plat)
docker_image="${docker_image/\{PLAT\}/$plat_subst}"
docker pull $docker_image
docker run --rm \
-e PYTHON_VERSION="$MB_PYTHON_VERSION" \
-e MB_PYTHON_VERSION="$MB_PYTHON_VERSION" \
-e UNICODE_WIDTH="$UNICODE_WIDTH" \
-e CONFIG_PATH="$CONFIG_PATH" \
-e WHEEL_SDIR="$WHEEL_SDIR" \
-e MANYLINUX_URL="$MANYLINUX_URL" \
-e MB_ML_LIBC="$MB_ML_LIBC" \
-e TEST_DEPENDS="$TEST_DEPENDS" \
-v $PWD:/io \
$docker_image /io/$MULTIBUILD_DIR/docker_test_wrap.sh
}