From e9b60b46567035f2a801355278488a6fcdd528b0 Mon Sep 17 00:00:00 2001 From: Joey Zhao <5253430+joeyzhao2018@users.noreply.github.com> Date: Thu, 7 May 2026 23:03:19 -0400 Subject: [PATCH] build: fix dd-trace-py git overrides and filter publish layer check - build_layers.sh: force the `ddtrace` package name when overriding via DD_TRACE_COMMIT or DD_TRACE_COMMIT_BRANCH. Git source builds always produce the `ddtrace` package; the `ddtrace_serverless` variant only exists as pre-built S3 wheels from dd-trace-py CI, so the previous `${wheel_basename}` substitution caused pip to reject the install with a name/metadata mismatch. - publish_layers.sh: only require layer zips for the layers in LAYERS, rather than unconditionally requiring all 14 entries in LAYER_PATHS. When LAYERS is unset it still defaults to all layers, so release pipelines that build everything are unaffected. Co-Authored-By: Claude Opus 4.7 --- scripts/build_layers.sh | 7 ++++--- scripts/publish_layers.sh | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/scripts/build_layers.sh b/scripts/build_layers.sh index 8cdfc153..1f18f665 100755 --- a/scripts/build_layers.sh +++ b/scripts/build_layers.sh @@ -126,11 +126,12 @@ function find_and_spec_wheel { # Restore pyproject.toml to a clean state for each build iteration cp pyproject.toml.bak pyproject.toml - # Replace ddtrace source if necessary + # Source checkouts still publish project metadata as "ddtrace", even when + # this function is called while probing for ddtrace_serverless wheels. 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\" }" diff --git a/scripts/publish_layers.sh b/scripts/publish_layers.sh index 31a514d1..ada8e2d4 100755 --- a/scripts/publish_layers.sh +++ b/scripts/publish_layers.sh @@ -69,15 +69,6 @@ PIDS=() # Makes sure any subprocesses will be terminated with this process trap "pkill -P $$; exit 1;" INT -# Check that the layer files exist -for layer_file in "${LAYER_PATHS[@]}" -do - if [ ! -f $layer_file ]; then - echo "Could not find $layer_file." - exit 1 - fi -done - # Determine the target regions if [ -z "$REGIONS" ]; then echo "Region not specified, running for all available regions." @@ -116,6 +107,19 @@ else echo "Layer version specified: $VERSION" fi +# Check that the layer files exist for the layers we'll actually publish +for layer_name in "${LAYERS[@]}"; do + for i in "${!AVAILABLE_LAYERS[@]}"; do + if [[ "${AVAILABLE_LAYERS[$i]}" = "${layer_name}" ]]; then + layer_file="${LAYER_PATHS[$i]}" + if [ ! -f "$layer_file" ]; then + echo "Could not find $layer_file." + exit 1 + fi + fi + done +done + read -p "Ready to publish version $VERSION of layers ${LAYERS[*]} to regions ${REGIONS[*]} (y/n)?" CONT if [ "$CONT" != "y" ]; then echo "Exiting"