From b11e95b34acc2d46238238d5d8e1d45e5dfdf28e Mon Sep 17 00:00:00 2001 From: Sean O Brien Date: Thu, 13 Jul 2023 23:18:13 +0100 Subject: [PATCH 1/2] Add python3.11. (#473) * Add python3.11. * fix failing without docker test cases --------- Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Co-authored-by: Mohamed ElAsmar --- samcli/commands/build/command.py | 2 +- samcli/lib/build/workflow_config.py | 2 ++ samcli/lib/utils/architecture.py | 1 + samcli/lib/utils/preview_runtimes.py | 2 +- samcli/local/common/runtime_template.py | 5 ++++- samcli/local/docker/lambda_debug_settings.py | 4 ++++ samcli/local/docker/lambda_image.py | 1 + tests/integration/buildcmd/test_build_cmd.py | 2 ++ tests/unit/local/docker/test_lambda_container.py | 1 + tests/unit/local/docker/test_lambda_debug_settings.py | 1 + 10 files changed, 18 insertions(+), 3 deletions(-) diff --git a/samcli/commands/build/command.py b/samcli/commands/build/command.py index 86327d411d..80463d9d6b 100644 --- a/samcli/commands/build/command.py +++ b/samcli/commands/build/command.py @@ -51,7 +51,7 @@ \b Supported Runtimes ------------------ - 1. Python 3.7, 3.8, 3.9, 3.10 using PIP\n + 1. Python 3.7, 3.8, 3.9, 3.10, 3.11 using PIP\n 2. Nodejs 18.x, 16.x, 14.x, 12.x using NPM\n 3. Ruby 2.7, 3.2 using Bundler\n 4. Java 8, Java 11, Java 17 using Gradle and Maven\n diff --git a/samcli/lib/build/workflow_config.py b/samcli/lib/build/workflow_config.py index b9ac751aed..713c57a751 100644 --- a/samcli/lib/build/workflow_config.py +++ b/samcli/lib/build/workflow_config.py @@ -89,6 +89,7 @@ def get_layer_subfolder(build_workflow: str) -> str: "python3.8": "python", "python3.9": "python", "python3.10": "python", + "python3.11": "python", "nodejs4.3": "nodejs", "nodejs6.10": "nodejs", "nodejs8.10": "nodejs", @@ -155,6 +156,7 @@ def get_workflow_config( "python3.8": BasicWorkflowSelector(PYTHON_PIP_CONFIG), "python3.9": BasicWorkflowSelector(PYTHON_PIP_CONFIG), "python3.10": BasicWorkflowSelector(PYTHON_PIP_CONFIG), + "python3.11": BasicWorkflowSelector(PYTHON_PIP_CONFIG), "nodejs12.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG), "nodejs14.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG), "nodejs16.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG), diff --git a/samcli/lib/utils/architecture.py b/samcli/lib/utils/architecture.py index a8025d8b3f..0121d5d8f0 100644 --- a/samcli/lib/utils/architecture.py +++ b/samcli/lib/utils/architecture.py @@ -22,6 +22,7 @@ "python3.8": [ARM64, X86_64], "python3.9": [ARM64, X86_64], "python3.10": [ARM64, X86_64], + "python3.11": [ARM64, X86_64], "ruby2.7": [ARM64, X86_64], "ruby3.2": [ARM64, X86_64], "java8": [X86_64], diff --git a/samcli/lib/utils/preview_runtimes.py b/samcli/lib/utils/preview_runtimes.py index c17ae95cf8..cffd6b2338 100644 --- a/samcli/lib/utils/preview_runtimes.py +++ b/samcli/lib/utils/preview_runtimes.py @@ -4,4 +4,4 @@ """ from typing import Set -PREVIEW_RUNTIMES: Set[str] = set() +PREVIEW_RUNTIMES: Set[str] = {"python3.11"} diff --git a/samcli/local/common/runtime_template.py b/samcli/local/common/runtime_template.py index 697631adea..707ea0f3f3 100644 --- a/samcli/local/common/runtime_template.py +++ b/samcli/local/common/runtime_template.py @@ -16,7 +16,7 @@ RUNTIME_DEP_TEMPLATE_MAPPING = { "python": [ { - "runtimes": ["python3.10", "python3.9", "python3.8", "python3.7"], + "runtimes": ["python3.11", "python3.10", "python3.9", "python3.8", "python3.7"], "dependency_manager": "pip", "init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"), "build": True, @@ -113,6 +113,7 @@ def get_local_lambda_images_location(mapping, runtime): "provided.al2", "provided", # python runtimes in descending order + "python3.11", "python3.10", "python3.9", "python3.8", @@ -135,6 +136,7 @@ def get_local_lambda_images_location(mapping, runtime): "nodejs16.x": "amazon/nodejs16.x-base", "nodejs14.x": "amazon/nodejs14.x-base", "nodejs12.x": "amazon/nodejs12.x-base", + "python3.11": "amazon/python3.11-base", "python3.10": "amazon/python3.10-base", "python3.9": "amazon/python3.9-base", "python3.8": "amazon/python3.8-base", @@ -156,6 +158,7 @@ def get_local_lambda_images_location(mapping, runtime): "python3.8": "Python36", "python3.9": "Python36", "python3.10": "Python36", + "python3.11": "Python36", "dotnet6": "dotnet6", "go1.x": "Go1", } diff --git a/samcli/local/docker/lambda_debug_settings.py b/samcli/local/docker/lambda_debug_settings.py index 8bffc6a3e2..a5e378dea1 100644 --- a/samcli/local/docker/lambda_debug_settings.py +++ b/samcli/local/docker/lambda_debug_settings.py @@ -179,6 +179,10 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime entry + ["/var/lang/bin/python3.10"] + debug_args_list + ["/var/runtime/bootstrap.py"], container_env_vars=_container_env_vars, ), + Runtime.python311.value: lambda: DebugSettings( + entry + ["/var/lang/bin/python3.11"] + debug_args_list + ["/var/runtime/bootstrap.py"], + container_env_vars=_container_env_vars, + ), } try: return entrypoint_mapping[runtime]() diff --git a/samcli/local/docker/lambda_image.py b/samcli/local/docker/lambda_image.py index 4dff0d820f..72ad813de9 100644 --- a/samcli/local/docker/lambda_image.py +++ b/samcli/local/docker/lambda_image.py @@ -40,6 +40,7 @@ class Runtime(Enum): python38 = "python3.8" python39 = "python3.9" python310 = "python3.10" + python311 = "python3.11" ruby27 = "ruby2.7" ruby32 = "ruby3.2" java8 = "java8" diff --git a/tests/integration/buildcmd/test_build_cmd.py b/tests/integration/buildcmd/test_build_cmd.py index b45d2a2418..6e7787381e 100644 --- a/tests/integration/buildcmd/test_build_cmd.py +++ b/tests/integration/buildcmd/test_build_cmd.py @@ -440,6 +440,7 @@ def _validate_skipped_built_function( ("template.yaml", "Function", True, "python3.8", "Python", False, "CodeUri"), ("template.yaml", "Function", True, "python3.9", "Python", False, "CodeUri"), ("template.yaml", "Function", True, "python3.10", "Python", False, "CodeUri"), + ("template.yaml", "Function", True, "python3.11", "Python", False, "CodeUri"), ("template.yaml", "Function", True, "python3.7", "PythonPEP600", False, "CodeUri"), ("template.yaml", "Function", True, "python3.8", "PythonPEP600", False, "CodeUri"), ], @@ -479,6 +480,7 @@ def test_with_default_requirements(self): ("template.yaml", "Function", True, "python3.8", "Python", False, "CodeUri"), ("template.yaml", "Function", True, "python3.9", "Python", False, "CodeUri"), ("template.yaml", "Function", True, "python3.10", "Python", False, "CodeUri"), + ("template.yaml", "Function", True, "python3.11", "Python", False, "CodeUri"), ], ) class TestBuildCommand_PythonFunctions_WithDocker(BuildIntegPythonBase): diff --git a/tests/unit/local/docker/test_lambda_container.py b/tests/unit/local/docker/test_lambda_container.py index 90893e4e49..bffa8bc1cc 100644 --- a/tests/unit/local/docker/test_lambda_container.py +++ b/tests/unit/local/docker/test_lambda_container.py @@ -23,6 +23,7 @@ Runtime.python38.value, Runtime.python39.value, Runtime.python310.value, + Runtime.python311.value, Runtime.dotnet6.value, ] diff --git a/tests/unit/local/docker/test_lambda_debug_settings.py b/tests/unit/local/docker/test_lambda_debug_settings.py index 1dd024ebc2..a72a9722a9 100644 --- a/tests/unit/local/docker/test_lambda_debug_settings.py +++ b/tests/unit/local/docker/test_lambda_debug_settings.py @@ -20,6 +20,7 @@ Runtime.python38, Runtime.python39, Runtime.python310, + Runtime.python311, ] From 554bf0709f794f257bb94d83603cc2e154e5b090 Mon Sep 17 00:00:00 2001 From: Mohamed ElAsmar Date: Sat, 15 Jul 2023 02:47:55 -0700 Subject: [PATCH 2/2] add py3.11 to docker-disabled job --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03e29508fe..d9af2f5e4a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -210,6 +210,7 @@ jobs: with: # These are the versions of Python that correspond to the supported Lambda runtimes python-version: | + 3.11 3.10 3.9 3.8