Skip to content

Commit c6c307e

Browse files
authored
use serverless-specific wheel in layer (#762)
* use serverless-specific wheel in layer * missing underscore * change index * use proper wheel name * print search pattern * backward compatibility * backward compatibility * wrong copypasta * silly typo * debug output
1 parent d8a2565 commit c6c307e

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

scripts/build_layers.sh

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ function make_path_absolute {
9898
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
9999
}
100100

101+
function search_wheel {
102+
# Args: [wheel base name] [index]
103+
104+
WHEEL_BASENAME=$1
105+
INDEX=$2
106+
107+
SEARCH_PATTERN="${WHEEL_BASENAME}-[^\"]*${PY_TAG}[^\"]*${PLATFORM}[^\"]*\.whl"
108+
INDEX_URL="${S3_BASE}/index-${INDEX}.html"
109+
echo "Searching for wheel ${SEARCH_PATTERN}"
110+
export WHEEL_FILE=$(curl -sSfL ${INDEX_URL} | grep -o "$SEARCH_PATTERN" | head -n 1)
111+
if [ ! -z "${WHEEL_FILE}" ]; then
112+
curl -sSfL "${S3_BASE}/${WHEEL_FILE}" -o "${WHEEL_FILE}"
113+
echo "Using S3 wheel: ${WHEEL_FILE}"
114+
replace_ddtrace_dep "${WHEEL_BASENAME} = { file = \"${WHEEL_FILE}\" }"
115+
fi
116+
}
117+
101118
function docker_build_zip {
102119
# Args: [python version] [zip destination]
103120

@@ -122,15 +139,12 @@ function docker_build_zip {
122139
PLATFORM="manylinux2014_aarch64"
123140
fi
124141
PY_TAG="cp$(echo "$1" | tr -d '.')"
125-
WHEEL_FILE=$(curl -sSfL "${S3_BASE}/index-manylinux2014.html" \
126-
| grep -o "ddtrace-[^\"]*${PY_TAG}[^\"]*${PLATFORM}[^\"]*\.whl" \
127-
| head -n 1)
142+
search_wheel "ddtrace_serverless" "serverless"
143+
if [ -z "${WHEEL_FILE}" ]; then
144+
search_wheel "ddtrace" "manylinux2014"
145+
fi
128146
if [ -z "${WHEEL_FILE}" ]; then
129147
echo "No S3 wheel found for ${PY_TAG} ${PLATFORM}, using default pyproject.toml version"
130-
else
131-
curl -sSfL "${S3_BASE}/${WHEEL_FILE}" -o "${WHEEL_FILE}"
132-
echo "Using S3 wheel: ${WHEEL_FILE}"
133-
replace_ddtrace_dep "ddtrace = { file = \"${WHEEL_FILE}\" }"
134148
fi
135149
fi
136150

0 commit comments

Comments
 (0)