From 7067c892ed2b06540a5e72344b041b4b09ccaaa9 Mon Sep 17 00:00:00 2001 From: Ezequiel Miravalles <149010233+dil-emiravalles@users.noreply.github.com> Date: Fri, 7 Feb 2025 19:47:19 -0300 Subject: [PATCH] chore(lambda-python-alpha): make pipenv version a parameter for bundling (#32594) Make pipenv version a parameter in the Dockerfile for python lambda bundling. It was originally hardcoded to 2022.4.8, which excluded newer features/fixes. ### Issue # (if applicable) None. ### Reason for this change Pipenv version was originally hardcoded to 2022.4.8, which excluded newer features/fixes. And that could not be changed without providing a new Dockerfile from scratch. ### Description of changes Just made the pipenv version a new ARG in the Dockerfile. So that it can be provided from the outside. It has the same default value as it used to have, so that the current behavior won't change. ### Describe any new or updated permissions being added None ### Description of how you validated changes Tested this same Dockerfile in my current project, providing the PIPENV_VERSION variable via CDK: ```typescript import * as python from '@aws-cdk/aws-lambda-python-alpha'; const lambdaProps: python.PythonFunctionProps = { runtime: lambda.Runtime.PYTHON_3_11, // ... bundling: { buildArgs: { 'PIPENV_VERSION': '2024.0.1', }, } }; ``` ### Checklist - [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-lambda-python-alpha/lib/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-lambda-python-alpha/lib/Dockerfile b/packages/@aws-cdk/aws-lambda-python-alpha/lib/Dockerfile index 334b2a80ac4d9..3152f0f30cf14 100644 --- a/packages/@aws-cdk/aws-lambda-python-alpha/lib/Dockerfile +++ b/packages/@aws-cdk/aws-lambda-python-alpha/lib/Dockerfile @@ -6,6 +6,8 @@ FROM $IMAGE ARG PIP_INDEX_URL ARG PIP_EXTRA_INDEX_URL ARG HTTPS_PROXY +# pipenv 2022.4.8 is the last version with Python 3.6 support +ARG PIPENV_VERSION=2022.4.8 ARG POETRY_VERSION=1.5.1 # Add virtualenv path @@ -31,8 +33,8 @@ RUN \ mkdir /tmp/poetry-cache && \ # Ensure all users can write to poetry cache chmod -R 777 /tmp/poetry-cache && \ -# pipenv 2022.4.8 is the last version with Python 3.6 support - pip install pipenv==2022.4.8 poetry==$POETRY_VERSION && \ +# Install pipenv and poetry + pip install pipenv==$PIPENV_VERSION poetry==$POETRY_VERSION && \ # Ensure no temporary files remain in the caches rm -rf /tmp/pip-cache/* /tmp/poetry-cache/*