-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·115 lines (92 loc) · 3.56 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·115 lines (92 loc) · 3.56 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
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$ROOT_DIR"
if [[ $# -gt 0 ]]; then
echo "usage: MANYLINUX=1 ./build.sh" >&2
exit 2
fi
USE_MANYLINUX="${MANYLINUX:-0}"
if [[ -z "${BUILD_SH_IN_MANYLINUX:-}" ]] && ! command -v uv >/dev/null 2>&1; then
./setup.sh
fi
if [[ "$USE_MANYLINUX" == "1" && -z "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
UV_BIN="$(command -v uv)"
docker run --rm \
-e BUILD_SH_IN_MANYLINUX=1 \
-e BUILD_SH_REUSE_MANYLINUX_ARTIFACTS="${BUILD_SH_REUSE_MANYLINUX_ARTIFACTS:-}" \
-e BUILD_SH_HOST_UID="$(id -u)" \
-e BUILD_SH_HOST_GID="$(id -g)" \
-e HOME=/tmp \
-e UV_CACHE_DIR=/work/.uv-cache \
-e CCACHE_DIR=/work/.ccache \
-e UV_PYTHON=/opt/python/cp312-cp312/bin/python3 \
-v "$ROOT_DIR:/work" \
-v "$UV_BIN:/usr/local/bin/uv:ro" \
-w /work \
"quay.io/pypa/manylinux_2_28_$(uname -m)" \
bash build.sh
exit 0
fi
if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
export PATH="/opt/python/cp312-cp312/bin:$PATH"
# cached *-src repos may be owned by the host runner user; tell git to trust them
git config --global --add safe.directory '*'
./setup.sh
if [[ -z "${BUILD_SH_REUSE_MANYLINUX_ARTIFACTS:-}" ]]; then
for toml in */pyproject.toml; do
pkg="${toml%/pyproject.toml}"
module="${pkg//-/_}"
rm -rf "$pkg/$module/install" "$pkg/$module/toolchain" "$pkg/$module/bin"
done
fi
# Install all manylinux system deps upfront — individual build.sh scripts
# run in parallel via uv, so concurrent dnf calls would race on the cache.
if command -v dnf &>/dev/null; then
dnf install -y -q \
libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel libXi-devel \
mesa-libGL-devel mesa-libEGL-devel mesa-libGLES-devel bison flex \
wayland-devel wayland-protocols-devel libxkbcommon-devel
fi
fi
export CMAKE_C_COMPILER_LAUNCHER=ccache
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export CCACHE_DIR="${CCACHE_DIR:-$ROOT_DIR/.ccache}"
restore_build_versions() {
python3 build_versions.py restore */pyproject.toml
}
trap restore_build_versions EXIT
echo "Building workspace packages into dist"
START_SECS=$SECONDS
mkdir -p dist/
rm -rf dist/*
# PyPI files are immutable, so each build gets a fresh .postN version. The
# committed pyproject.toml files keep the clean upstream version; the suffix
# only exists while the wheels are built.
POST_N="${DEPENDENCIES_POST_VERSION_N:-$(git rev-list --count HEAD)}"
echo "Applying .post$POST_N package versions for this build"
python3 build_versions.py apply "$POST_N" */pyproject.toml
uv build --all-packages --wheel --out-dir dist --no-create-gitignore
restore_build_versions
if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" ]]; then
VENV_DIR="$ROOT_DIR/.venv-manylinux"
else
VENV_DIR="$ROOT_DIR/.venv"
fi
echo
echo "Running smoketests"
uv venv --allow-existing --quiet "$VENV_DIR"
uv pip install --python "$VENV_DIR/bin/python" --quiet "cffi>=1.17.1" >/dev/null
uv pip install --python "$VENV_DIR/bin/python" --reinstall --no-deps --quiet dist/*.whl >/dev/null
for toml in */pyproject.toml; do
module="$(basename "$(dirname "$toml")" | tr '-' '_')"
"$VENV_DIR/bin/python" -c "import $module; $module.smoketest()" >/dev/null
done
du -hs dist/* | sort -hr
echo
echo "Done in $((SECONDS - START_SECS))s"
# Hand workspace ownership back to the host runner so actions/cache can
# tar everything we just produced (manylinux runs as root).
if [[ -n "${BUILD_SH_IN_MANYLINUX:-}" && -n "${BUILD_SH_HOST_UID:-}" ]]; then
chown -R "$BUILD_SH_HOST_UID:${BUILD_SH_HOST_GID:-0}" "$ROOT_DIR"
fi