From 84e900210b0ab370d7b973776a1de33dfa65e075 Mon Sep 17 00:00:00 2001 From: Rithika Narayan <93233069+rithikanarayan@users.noreply.github.com> Date: Fri, 3 Apr 2026 09:51:02 -0400 Subject: [PATCH] Revert "Add ability to use ddtrace_serverless wheels in layer build (#777)" This reverts commit 8051f4496fb841f6c2c92788bfc9a66d25992a7e. --- scripts/build_layers.sh | 57 ++++++++++------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/scripts/build_layers.sh b/scripts/build_layers.sh index b3f73385..7456a38b 100755 --- a/scripts/build_layers.sh +++ b/scripts/build_layers.sh @@ -91,7 +91,6 @@ trap cleanup EXIT # Helper: replace the multi-line ddtrace dependency in pyproject.toml. # Uses perl instead of sed -z for macOS/Linux portability. replace_ddtrace_dep() { - echo "Replacing dep with $1" perl -i -0777 -pe "s|ddtrace = \[[^\]]*\]|$1|gs" pyproject.toml } @@ -99,41 +98,22 @@ function make_path_absolute { echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" } -function search_wheel { - # Args: [wheel base name] [index] - - WHEEL_BASENAME=$1 - INDEX=$2 - - SEARCH_PATTERN="${WHEEL_BASENAME}-[^\"]*${PY_TAG}[^\"]*${PLATFORM}[^\"]*\.whl" - INDEX_URL="${S3_BASE}/index-${INDEX}.html" - echo "Searching for wheel ${SEARCH_PATTERN}" - export WHEEL_FILE=$(curl -sSfL ${INDEX_URL} | grep -o "$SEARCH_PATTERN" | head -n 1) - if [ ! -z "${WHEEL_FILE}" ]; then - curl -sSfL "${S3_BASE}/${WHEEL_FILE}" -o "${WHEEL_FILE}" - echo "Using S3 wheel: ${WHEEL_FILE}" - replace_ddtrace_dep "${WHEEL_BASENAME} = { file = \"${WHEEL_FILE}\" }" - fi -} - -function find_and_spec_wheel { - # Args: [python version] [wheel base name] [index] +function docker_build_zip { + # Args: [python version] [zip destination] - arch=$2 - wheel_basename=$3 - index=$4 + destination=$(make_path_absolute $2) + arch=$3 # Restore pyproject.toml to a clean state for each build iteration cp pyproject.toml.bak pyproject.toml # Replace ddtrace source if necessary if [ -n "$DD_TRACE_COMMIT" ]; then - replace_ddtrace_dep "${wheel_basename} = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }" + replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }" elif [ -n "$DD_TRACE_COMMIT_BRANCH" ]; then - replace_ddtrace_dep "${wheel_basename} = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }" + replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }" elif [ -n "$DD_TRACE_WHEEL" ]; then - wheel_basename=$(sed 's/^\.\///' <<< ${DD_TRACE_WHEEL%%-*}) - replace_ddtrace_dep "${wheel_basename} = { file = \"$DD_TRACE_WHEEL\" }" + replace_ddtrace_dep "ddtrace = { file = \"$DD_TRACE_WHEEL\" }" elif [ -n "$UPSTREAM_PIPELINE_ID" ]; then S3_BASE="https://dd-trace-py-builds.s3.amazonaws.com/${UPSTREAM_PIPELINE_ID}" if [ "${arch}" = "amd64" ]; then @@ -142,19 +122,18 @@ function find_and_spec_wheel { PLATFORM="manylinux2014_aarch64" fi PY_TAG="cp$(echo "$1" | tr -d '.')" - search_wheel ${wheel_basename} ${index} + WHEEL_FILE=$(curl -sSfL "${S3_BASE}/index-manylinux2014.html" \ + | grep -o "ddtrace-[^\"]*${PY_TAG}[^\"]*${PLATFORM}[^\"]*\.whl" \ + | head -n 1) if [ -z "${WHEEL_FILE}" ]; then echo "No S3 wheel found for ${PY_TAG} ${PLATFORM}, using default pyproject.toml version" - return 1 + else + curl -sSfL "${S3_BASE}/${WHEEL_FILE}" -o "${WHEEL_FILE}" + echo "Using S3 wheel: ${WHEEL_FILE}" + replace_ddtrace_dep "ddtrace = { file = \"${WHEEL_FILE}\" }" fi fi -} - -function docker_build_zip { - # Args: [python version] [zip destination] - destination=$(make_path_absolute $2) - arch=$3 # Install datadogpy in a docker container to avoid the mess from switching # between different python runtimes. temp_dir=$(mktemp -d) @@ -180,14 +159,6 @@ do for architecture in "${ARCHS[@]}" do echo "Building layer for Python ${python_version} arch=${architecture}" - set +e - find_and_spec_wheel ${python_version} ${architecture} "ddtrace_serverless" "serverless" - FAILURE=$? - if [ $FAILURE != 0 ]; then - echo "Attempting layer build again with package ddtrace" - find_and_spec_wheel ${python_version} ${architecture} "ddtrace" "manylinux2014" - fi - set -e docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} done done