@@ -91,49 +91,29 @@ trap cleanup EXIT
9191# Helper: replace the multi-line ddtrace dependency in pyproject.toml.
9292# Uses perl instead of sed -z for macOS/Linux portability.
9393replace_ddtrace_dep () {
94- echo " Replacing dep with $1 "
9594 perl -i -0777 -pe " s|ddtrace = \[[^\]]*\]|$1 |gs" pyproject.toml
9695}
9796
9897function make_path_absolute {
9998 echo " $( cd " $( dirname " $1 " ) " ; pwd) /$( basename " $1 " ) "
10099}
101100
102- function search_wheel {
103- # Args: [wheel base name] [index]
104-
105- WHEEL_BASENAME=$1
106- INDEX=$2
107-
108- SEARCH_PATTERN=" ${WHEEL_BASENAME} -[^\" ]*${PY_TAG} [^\" ]*${PLATFORM} [^\" ]*\.whl"
109- INDEX_URL=" ${S3_BASE} /index-${INDEX} .html"
110- echo " Searching for wheel ${SEARCH_PATTERN} "
111- export WHEEL_FILE=$( curl -sSfL ${INDEX_URL} | grep -o " $SEARCH_PATTERN " | head -n 1)
112- if [ ! -z " ${WHEEL_FILE} " ]; then
113- curl -sSfL " ${S3_BASE} /${WHEEL_FILE} " -o " ${WHEEL_FILE} "
114- echo " Using S3 wheel: ${WHEEL_FILE} "
115- replace_ddtrace_dep " ${WHEEL_BASENAME} = { file = \" ${WHEEL_FILE} \" }"
116- fi
117- }
118-
119- function find_and_spec_wheel {
120- # Args: [python version] [wheel base name] [index]
101+ function docker_build_zip {
102+ # Args: [python version] [zip destination]
121103
122- arch=$2
123- wheel_basename=$3
124- index=$4
104+ destination=$( make_path_absolute $2 )
105+ arch=$3
125106
126107 # Restore pyproject.toml to a clean state for each build iteration
127108 cp pyproject.toml.bak pyproject.toml
128109
129110 # Replace ddtrace source if necessary
130111 if [ -n " $DD_TRACE_COMMIT " ]; then
131- replace_ddtrace_dep " ${wheel_basename} = { git = \" https://github.com/DataDog/dd-trace-py.git\" , rev = \" $DD_TRACE_COMMIT \" }"
112+ replace_ddtrace_dep " ddtrace = { git = \" https://github.com/DataDog/dd-trace-py.git\" , rev = \" $DD_TRACE_COMMIT \" }"
132113 elif [ -n " $DD_TRACE_COMMIT_BRANCH " ]; then
133- replace_ddtrace_dep " ${wheel_basename} = { git = \" https://github.com/DataDog/dd-trace-py.git\" , branch = \" $DD_TRACE_COMMIT_BRANCH \" }"
114+ replace_ddtrace_dep " ddtrace = { git = \" https://github.com/DataDog/dd-trace-py.git\" , branch = \" $DD_TRACE_COMMIT_BRANCH \" }"
134115 elif [ -n " $DD_TRACE_WHEEL " ]; then
135- wheel_basename=$( sed ' s/^\.\///' <<< ${DD_TRACE_WHEEL%% -* } )
136- replace_ddtrace_dep " ${wheel_basename} = { file = \" $DD_TRACE_WHEEL \" }"
116+ replace_ddtrace_dep " ddtrace = { file = \" $DD_TRACE_WHEEL \" }"
137117 elif [ -n " $UPSTREAM_PIPELINE_ID " ]; then
138118 S3_BASE=" https://dd-trace-py-builds.s3.amazonaws.com/${UPSTREAM_PIPELINE_ID} "
139119 if [ " ${arch} " = " amd64" ]; then
@@ -142,19 +122,18 @@ function find_and_spec_wheel {
142122 PLATFORM=" manylinux2014_aarch64"
143123 fi
144124 PY_TAG=" cp$( echo " $1 " | tr -d ' .' ) "
145- search_wheel ${wheel_basename} ${index}
125+ WHEEL_FILE=$( curl -sSfL " ${S3_BASE} /index-manylinux2014.html" \
126+ | grep -o " ddtrace-[^\" ]*${PY_TAG} [^\" ]*${PLATFORM} [^\" ]*\.whl" \
127+ | head -n 1)
146128 if [ -z " ${WHEEL_FILE} " ]; then
147129 echo " No S3 wheel found for ${PY_TAG} ${PLATFORM} , using default pyproject.toml version"
148- return 1
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} \" }"
149134 fi
150135 fi
151- }
152-
153- function docker_build_zip {
154- # Args: [python version] [zip destination]
155136
156- destination=$( make_path_absolute $2 )
157- arch=$3
158137 # Install datadogpy in a docker container to avoid the mess from switching
159138 # between different python runtimes.
160139 temp_dir=$( mktemp -d)
180159 for architecture in " ${ARCHS[@]} "
181160 do
182161 echo " Building layer for Python ${python_version} arch=${architecture} "
183- set +e
184- find_and_spec_wheel ${python_version} ${architecture} " ddtrace_serverless" " serverless"
185- FAILURE=$?
186- if [ $FAILURE != 0 ]; then
187- echo " Attempting layer build again with package ddtrace"
188- find_and_spec_wheel ${python_version} ${architecture} " ddtrace" " manylinux2014"
189- fi
190- set -e
191162 docker_build_zip ${python_version} $LAYER_DIR /${LAYER_FILES_PREFIX} -${architecture} -${python_version} .zip ${architecture}
192163 done
193164done
0 commit comments