-
Notifications
You must be signed in to change notification settings - Fork 1
/
remote.sh
64 lines (54 loc) · 2.53 KB
/
remote.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
#!/bin/bash
# This script is uploaded to the builder VM, and executes as the 'ubuntu' user.
# It expects ~/build-info.json to contain an object with the following keys:
# repo_url: URL of a git repo to clone
# commit: the commit to check out from that repo (can be a tag)
# package_name: the python package import name, to pass to pytest --pyargs
#
# On successful exit, the wheels are in ~/wheelhouse
set -euxo pipefail
id
date
uname -a
env
# cloud-init modifies /etc/apt/sources.list, so make sure it's finished before we
# continue
cloud-init status --wait
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get -y update
sudo -E apt-get -y install jq git python3-pip python3-venv docker.io
REPO_URL="$(jq -r .repo_url ~/build-info.json)"
COMMIT="$(jq -r .commit ~/build-info.json)"
PACKAGE_NAME="$(jq -r .package_name ~/build-info.json)"
MODULE_NAME="${PACKAGE_NAME//-/_}"
git clone $REPO_URL checkout
cd checkout
git checkout $COMMIT
git submodule update --init
python3 -m venv ~/myenv
~/myenv/bin/pip install cibuildwheel
export CIBW_BEFORE_ALL="curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable"
export CIBW_ENVIRONMENT='PATH="$PATH:$HOME/.cargo/bin" SPACY_NUM_BUILD_JOBS=8'
export CIBW_BUILD_VERBOSITY=1
if [ -e build-constraints.txt ]; then
export CIBW_ENVIRONMENT="$CIBW_ENVIRONMENT PIP_CONSTRAINT=build-constraints.txt"
fi
# build constraints through PIP_CONSTRAINT only work with pip frontend,
# with the drawback that the pip builds aren't isolated
export CIBW_BUILD_FRONTEND=pip
export CIBW_SKIP="pp* *-musllinux* *i686* cp36-* cp37-* cp38-*"
# for spacy: clean cython-generated files between builds to handle profiling
# settings, since the builds aren't isolated; a cleaner/nicer version would
# install the build requirements from pyproject.toml instead, but it's a hassle
# to parse
if [ "$MODULE_NAME" = "spacy" ]; then
export CIBW_BEFORE_BUILD="pip install -r requirements.txt && python setup.py clean"
fi
export CIBW_BEFORE_TEST="unset PIP_CONSTRAINT && pip install -U -r requirements.txt"
export CIBW_TEST_COMMAND="unset PIP_CONSTRAINT && pip install 'urllib3<2' && pytest --tb=native --pyargs $MODULE_NAME"
# By default cibuildwheel doesn't strip debug info from libraries:
# https://github.com/pypa/cibuildwheel/issues/331
# But you pretty much always want this for production end-user releases, so we override
# this to add the --strip flag.
export CIBW_REPAIR_WHEEL_COMMAND_LINUX="auditwheel repair --strip -w {dest_dir} {wheel}"
~/myenv/bin/cibuildwheel --platform linux --output-dir ~/wheelhouse