Skip to content

Commit 8d4f511

Browse files
committed
ci: allow installing dd-trace-py pipeline artifacts
1 parent 64eba2f commit 8d4f511

1 file changed

Lines changed: 32 additions & 8 deletions

File tree

scripts/build_layers.sh

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
# DD_TRACE_COMMIT Specific dd-trace-py commit SHA to build from GitHub.
2121
# DD_TRACE_COMMIT_BRANCH dd-trace-py branch name to build from GitHub.
2222
# DD_TRACE_WHEEL Path to a pre-built ddtrace .whl file.
23+
# UPSTREAM_PIPELINE_ID GitLab pipeline ID from dd-trace-py. Downloads the
24+
# matching pre-built manylinux2014 wheel from S3 for
25+
# each python/arch combination.
2326
#
2427
# Examples:
2528
# # Build a single layer for Python 3.12 on arm64
@@ -91,14 +94,6 @@ replace_ddtrace_dep() {
9194
perl -i -0777 -pe "s|ddtrace = \[[^\]]*\]|$1|gs" pyproject.toml
9295
}
9396

94-
# Replace ddtrace source if necessary
95-
if [ -n "$DD_TRACE_COMMIT" ]; then
96-
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }"
97-
elif [ -n "$DD_TRACE_COMMIT_BRANCH" ]; then
98-
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }"
99-
elif [ -n "$DD_TRACE_WHEEL" ]; then
100-
replace_ddtrace_dep "ddtrace = { file = \"$DD_TRACE_WHEEL\" }"
101-
fi
10297
function make_path_absolute {
10398
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
10499
}
@@ -109,6 +104,35 @@ function docker_build_zip {
109104
destination=$(make_path_absolute $2)
110105
arch=$3
111106

107+
# Restore pyproject.toml to a clean state for each build iteration
108+
cp pyproject.toml.bak pyproject.toml
109+
110+
# Remove any previously downloaded wheels
111+
rm -f ddtrace-*.whl
112+
113+
# Replace ddtrace source if necessary
114+
if [ -n "$DD_TRACE_COMMIT" ]; then
115+
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }"
116+
elif [ -n "$DD_TRACE_COMMIT_BRANCH" ]; then
117+
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }"
118+
elif [ -n "$DD_TRACE_WHEEL" ]; then
119+
replace_ddtrace_dep "ddtrace = { file = \"$DD_TRACE_WHEEL\" }"
120+
elif [ -n "$UPSTREAM_PIPELINE_ID" ]; then
121+
S3_BASE="https://dd-trace-py-builds.s3.amazonaws.com/${UPSTREAM_PIPELINE_ID}"
122+
if [ "${arch}" = "amd64" ]; then
123+
PLATFORM="manylinux2014_x86_64"
124+
else
125+
PLATFORM="manylinux2014_aarch64"
126+
fi
127+
curl -sSfL "${S3_BASE}/download-manylinux2014.sh" | bash -s -- \
128+
--dest . \
129+
--python-version "$1" \
130+
--platform "${PLATFORM}"
131+
WHEEL_FILE=$(ls ddtrace-*.whl | head -n 1)
132+
echo "Using S3 wheel: ${WHEEL_FILE}"
133+
replace_ddtrace_dep "ddtrace = { file = \"${WHEEL_FILE}\" }"
134+
fi
135+
112136
# Install datadogpy in a docker container to avoid the mess from switching
113137
# between different python runtimes.
114138
temp_dir=$(mktemp -d)

0 commit comments

Comments
 (0)