Skip to content

Commit d595501

Browse files
Build & publish Lambda layers and ECR images for Python3.13 Lambda runtime (#293)
* build and publish layer & images for python 3.13
1 parent 89b5308 commit d595501

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

.github/workflows/publish-python.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
13+
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
1414
steps:
1515
- uses: actions/checkout@v4
1616
- name: Check Tag

libBuild.sh

+6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ function layer_name_str() {
119119
"python3.12")
120120
rt_part="Python312"
121121
;;
122+
"python3.13")
123+
rt_part="Python313"
124+
;;
122125
"nodejs18.x")
123126
rt_part="NodeJS18X"
124127
;;
@@ -176,6 +179,9 @@ function s3_prefix() {
176179
"python3.12")
177180
name="nr-python3.12"
178181
;;
182+
"python3.13")
183+
name="nr-python3.13"
184+
;;
179185
"nodejs18.x")
180186
name="nr-nodejs18.x"
181187
;;

python/publish-layers.sh

+60-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ PY39_DIST_ARM64=$DIST_DIR/python39.arm64.zip
1010
PY310_DIST_ARM64=$DIST_DIR/python310.arm64.zip
1111
PY311_DIST_ARM64=$DIST_DIR/python311.arm64.zip
1212
PY312_DIST_ARM64=$DIST_DIR/python312.arm64.zip
13+
PY313_DIST_ARM64=$DIST_DIR/python313.arm64.zip
1314

1415
PY38_DIST_X86_64=$DIST_DIR/python38.x86_64.zip
1516
PY39_DIST_X86_64=$DIST_DIR/python39.x86_64.zip
1617
PY310_DIST_X86_64=$DIST_DIR/python310.x86_64.zip
1718
PY311_DIST_X86_64=$DIST_DIR/python311.x86_64.zip
1819
PY312_DIST_X86_64=$DIST_DIR/python312.x86_64.zip
19-
20+
PY313_DIST_X86_64=$DIST_DIR/python313.x86_64.zip
2021

2122
source ../libBuild.sh
2223

@@ -275,6 +276,56 @@ function publish-python312-x86 {
275276
done
276277
}
277278

279+
function build-python313-arm64 {
280+
echo "Building New Relic layer for python3.13 (arm64)"
281+
rm -rf $BUILD_DIR $PY313_DIST_ARM64
282+
mkdir -p $DIST_DIR
283+
pip install --no-cache-dir -qU newrelic -t $BUILD_DIR/lib/python3.13/site-packages
284+
cp newrelic_lambda_wrapper.py $BUILD_DIR/lib/python3.13/site-packages/newrelic_lambda_wrapper.py
285+
cp -r newrelic_lambda $BUILD_DIR/lib/python3.13/site-packages/newrelic_lambda
286+
find $BUILD_DIR -name '__pycache__' -exec rm -rf {} +
287+
download_extension arm64
288+
zip -rq $PY313_DIST_ARM64 $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
289+
rm -rf $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
290+
echo "Build complete: ${PY313_DIST_ARM64}"
291+
}
292+
293+
function build-python313-x86 {
294+
echo "Building New Relic layer for python3.13 (x86_64)"
295+
rm -rf $BUILD_DIR $PY313_DIST_X86_64
296+
mkdir -p $DIST_DIR
297+
pip install --no-cache-dir -qU newrelic -t $BUILD_DIR/lib/python3.13/site-packages
298+
cp newrelic_lambda_wrapper.py $BUILD_DIR/lib/python3.13/site-packages/newrelic_lambda_wrapper.py
299+
cp -r newrelic_lambda $BUILD_DIR/lib/python3.13/site-packages/newrelic_lambda
300+
find $BUILD_DIR -name '__pycache__' -exec rm -rf {} +
301+
download_extension x86_64
302+
zip -rq $PY313_DIST_X86_64 $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
303+
rm -rf $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
304+
echo "Build complete: ${PY313_DIST_X86_64}"
305+
}
306+
307+
function publish-python313-arm64 {
308+
if [ ! -f $PY313_DIST_ARM64 ]; then
309+
echo "Package not found: ${PY313_DIST_ARM64}"
310+
exit 1
311+
fi
312+
313+
for region in "${REGIONS_ARM[@]}"; do
314+
publish_layer $PY313_DIST_ARM64 $region python3.13 arm64
315+
done
316+
}
317+
318+
function publish-python313-x86 {
319+
if [ ! -f $PY313_DIST_X86_64 ]; then
320+
echo "Package not found: ${PY313_DIST_X86_64}"
321+
exit 1
322+
fi
323+
324+
for region in "${REGIONS_X86[@]}"; do
325+
publish_layer $PY313_DIST_X86_64 $region python3.13 x86_64
326+
done
327+
}
328+
278329
case "$1" in
279330
"python3.8")
280331
build-python38-arm64
@@ -316,6 +367,14 @@ case "$1" in
316367
publish-python312-x86
317368
publish_docker_ecr $PY312_DIST_X86_64 python3.12 x86_64
318369
;;
370+
"python3.13")
371+
build-python313-arm64
372+
publish-python313-arm64
373+
publish_docker_ecr $PY313_DIST_ARM64 python3.13 arm64
374+
build-python313-x86
375+
publish-python313-x86
376+
publish_docker_ecr $PY313_DIST_X86_64 python3.13 x86_64
377+
;;
319378
*)
320379
usage
321380
;;

0 commit comments

Comments
 (0)