Skip to content

Commit 332e731

Browse files
authored
more complete backward compatibility (#775)
1 parent c6c307e commit 332e731

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

scripts/build_layers.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,23 @@ function search_wheel {
116116
}
117117

118118
function docker_build_zip {
119-
# Args: [python version] [zip destination]
119+
# Args: [python version] [zip destination] [wheel base name] [index]
120120

121121
destination=$(make_path_absolute $2)
122122
arch=$3
123+
wheel_basename=$4
124+
index=$5
123125

124126
# Restore pyproject.toml to a clean state for each build iteration
125127
cp pyproject.toml.bak pyproject.toml
126128

127129
# Replace ddtrace source if necessary
128130
if [ -n "$DD_TRACE_COMMIT" ]; then
129-
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }"
131+
replace_ddtrace_dep "${wheel_basename} = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }"
130132
elif [ -n "$DD_TRACE_COMMIT_BRANCH" ]; then
131-
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }"
133+
replace_ddtrace_dep "${wheel_basename} = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }"
132134
elif [ -n "$DD_TRACE_WHEEL" ]; then
133-
replace_ddtrace_dep "ddtrace = { file = \"$DD_TRACE_WHEEL\" }"
135+
replace_ddtrace_dep "${wheel_basename} = { file = \"$DD_TRACE_WHEEL\" }"
134136
elif [ -n "$UPSTREAM_PIPELINE_ID" ]; then
135137
S3_BASE="https://dd-trace-py-builds.s3.amazonaws.com/${UPSTREAM_PIPELINE_ID}"
136138
if [ "${arch}" = "amd64" ]; then
@@ -139,10 +141,7 @@ function docker_build_zip {
139141
PLATFORM="manylinux2014_aarch64"
140142
fi
141143
PY_TAG="cp$(echo "$1" | tr -d '.')"
142-
search_wheel "ddtrace_serverless" "serverless"
143-
if [ -z "${WHEEL_FILE}" ]; then
144-
search_wheel "ddtrace" "manylinux2014"
145-
fi
144+
search_wheel ${wheel_basename} ${index}
146145
if [ -z "${WHEEL_FILE}" ]; then
147146
echo "No S3 wheel found for ${PY_TAG} ${PLATFORM}, using default pyproject.toml version"
148147
fi
@@ -163,6 +162,7 @@ function docker_build_zip {
163162

164163
rm -rf $temp_dir
165164
echo "Done creating archive $destination"
165+
rm pyproject.toml.bak
166166
}
167167

168168
rm -rf $LAYER_DIR
@@ -173,7 +173,10 @@ do
173173
for architecture in "${ARCHS[@]}"
174174
do
175175
echo "Building layer for Python ${python_version} arch=${architecture}"
176-
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture}
176+
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} "ddtrace_serverless" "serverless" || true
177+
if [ -f pyproject.toml.bak ]; then # true means the previous attempt failed
178+
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} "ddtrace" "manylinux2014"
179+
fi
177180
done
178181
done
179182

0 commit comments

Comments
 (0)