Skip to content

Commit

Permalink
feat: Add python3.13 runtime support
Browse files Browse the repository at this point in the history
  • Loading branch information
hnnasit committed Oct 12, 2024
1 parent 334c570 commit 92aad59
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ jobs:
3.10
3.11
3.12
3.13
${{ matrix.python }}
- uses: actions/setup-go@v5
with:
Expand Down Expand Up @@ -249,6 +250,7 @@ jobs:
3.10
3.11
3.12
3.13
- name: Stop Docker Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
\b
Supported Runtimes
------------------
1. Python 3.8, 3.9, 3.10, 3.11, 3.12 using PIP\n
1. Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 using PIP\n
2. Nodejs 20.x, 18.x, 16.x, 14.x, 12.x using NPM\n
3. Ruby 3.2, 3.3 using Bundler\n
4. Java 8, Java 11, Java 17, Java 21 using Gradle and Maven\n
Expand Down
2 changes: 2 additions & 0 deletions samcli/lib/build/workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def get_layer_subfolder(build_workflow: str) -> str:
"python3.10": "python",
"python3.11": "python",
"python3.12": "python",
"python3.13": "python",
"nodejs4.3": "nodejs",
"nodejs6.10": "nodejs",
"nodejs8.10": "nodejs",
Expand Down Expand Up @@ -157,6 +158,7 @@ def get_workflow_config(
"python3.10": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.11": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.12": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"python3.13": BasicWorkflowSelector(PYTHON_PIP_CONFIG),
"nodejs16.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs18.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
"nodejs20.x": BasicWorkflowSelector(NODEJS_NPM_CONFIG),
Expand Down
1 change: 1 addition & 0 deletions samcli/lib/utils/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"python3.10": [ARM64, X86_64],
"python3.11": [ARM64, X86_64],
"python3.12": [ARM64, X86_64],
"python3.13": [ARM64, X86_64],
"ruby3.2": [ARM64, X86_64],
"ruby3.3": [ARM64, X86_64],
"java8.al2": [ARM64, X86_64],
Expand Down
5 changes: 4 additions & 1 deletion samcli/local/common/runtime_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
RUNTIME_DEP_TEMPLATE_MAPPING = {
"python": [
{
"runtimes": ["python3.12", "python3.11", "python3.10", "python3.9", "python3.8"],
"runtimes": ["python3.13", "python3.12", "python3.11", "python3.10", "python3.9", "python3.8"],
"dependency_manager": "pip",
"init_location": os.path.join(_templates, "cookiecutter-aws-sam-hello-python"),
"build": True,
Expand Down Expand Up @@ -117,6 +117,7 @@ def get_local_lambda_images_location(mapping, runtime):
"provided.al2",
"provided",
# python runtimes in descending order
"python3.13",
"python3.12",
"python3.11",
"python3.10",
Expand All @@ -141,6 +142,7 @@ def get_local_lambda_images_location(mapping, runtime):
"nodejs20.x": "amazon/nodejs20.x-base",
"nodejs18.x": "amazon/nodejs18.x-base",
"nodejs16.x": "amazon/nodejs16.x-base",
"python3.13": "amazon/python3.13-base",
"python3.12": "amazon/python3.12-base",
"python3.11": "amazon/python3.11-base",
"python3.10": "amazon/python3.10-base",
Expand All @@ -165,6 +167,7 @@ def get_local_lambda_images_location(mapping, runtime):
"python3.10": "Python36",
"python3.11": "Python36",
"python3.12": "Python36",
"python3.13": "Python36",
"dotnet6": "dotnet6",
"dotnet8": "dotnet6",
"go1.x": "Go1",
Expand Down
4 changes: 4 additions & 0 deletions samcli/local/docker/lambda_debug_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def get_debug_settings(debug_port, debug_args_list, _container_env_vars, runtime
entry + ["/var/lang/bin/python3.12"] + debug_args_list + ["/var/runtime/bootstrap.py"],
container_env_vars=_container_env_vars,
),
Runtime.python313.value: lambda: DebugSettings(
entry + ["/var/lang/bin/python3.13"] + debug_args_list + ["/var/runtime/bootstrap.py"],
container_env_vars=_container_env_vars,
),
}
try:
return entrypoint_mapping[runtime]()
Expand Down
1 change: 1 addition & 0 deletions samcli/local/docker/lambda_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Runtime(Enum):
python310 = "python3.10"
python311 = "python3.11"
python312 = "python3.12"
python313 = "python3.13"
ruby32 = "ruby3.2"
ruby33 = "ruby3.3"
java8al2 = "java8.al2"
Expand Down
8 changes: 5 additions & 3 deletions schema/samcli.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"properties": {
"parameters": {
"title": "Parameters for the init command",
"description": "Available parameters for the init command:\n* no_interactive:\nDisable interactive prompting for init parameters. (fail if any required values are missing)\n* architecture:\nArchitectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\n\nRuntimes: dotnet8, dotnet6, go1.x, java21, java17, java11, java8.al2, nodejs20.x, nodejs18.x, nodejs16.x, provided, provided.al2, provided.al2023, python3.9, python3.8, python3.12, python3.11, python3.10, ruby3.3, ruby3.2\n* package_type:\nLambda deployment package type.\n\nPackage Types: Zip, Image\n* base_image:\nLambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/dotnet8-base, amazon/go-provided.al2-base, amazon/go-provided.al2023-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java21-base, amazon/java8.al2-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/nodejs20.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.12-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/ruby3.3-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip\n* output_dir:\nDirectory to initialize AWS SAM application.\n* name:\nName of AWS SAM Application.\n* app_template:\nIdentifier of the managed application template to be used. Alternatively, run '$sam init' without options for an interactive workflow.\n* no_input:\nDisable Cookiecutter prompting and accept default values defined in the cookiecutter config.\n* extra_context:\nOverride custom parameters in the template's cookiecutter.json configuration e.g. {\"customParam1\": \"customValue1\", \"customParam2\":\"customValue2\"}\n* tracing:\nEnable AWS X-Ray tracing for application.\n* application_insights:\nEnable CloudWatch Application Insights monitoring for application.\n* structured_logging:\nEnable Structured Logging for application.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* save_params:\nSave the parameters provided via the command line to the configuration file.",
"description": "Available parameters for the init command:\n* no_interactive:\nDisable interactive prompting for init parameters. (fail if any required values are missing)\n* architecture:\nArchitectures for Lambda functions.\n\nArchitectures: ['arm64', 'x86_64']\n* location:\nTemplate location (git, mercurial, http(s), zip, path).\n* runtime:\nLambda runtime for application.\n\nRuntimes: dotnet8, dotnet6, go1.x, java21, java17, java11, java8.al2, nodejs20.x, nodejs18.x, nodejs16.x, provided, provided.al2, provided.al2023, python3.9, python3.8, python3.13, python3.12, python3.11, python3.10, ruby3.3, ruby3.2\n* package_type:\nLambda deployment package type.\n\nPackage Types: Zip, Image\n* base_image:\nLambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/dotnet8-base, amazon/go-provided.al2-base, amazon/go-provided.al2023-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java21-base, amazon/java8.al2-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/nodejs20.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.12-base, amazon/python3.13-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/ruby3.3-base\n* dependency_manager:\nDependency manager for Lambda runtime.\n\nDependency managers: bundler, cli-package, gradle, maven, mod, npm, pip\n* output_dir:\nDirectory to initialize AWS SAM application.\n* name:\nName of AWS SAM Application.\n* app_template:\nIdentifier of the managed application template to be used. Alternatively, run '$sam init' without options for an interactive workflow.\n* no_input:\nDisable Cookiecutter prompting and accept default values defined in the cookiecutter config.\n* extra_context:\nOverride custom parameters in the template's cookiecutter.json configuration e.g. {\"customParam1\": \"customValue1\", \"customParam2\":\"customValue2\"}\n* tracing:\nEnable AWS X-Ray tracing for application.\n* application_insights:\nEnable CloudWatch Application Insights monitoring for application.\n* structured_logging:\nEnable Structured Logging for application.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* save_params:\nSave the parameters provided via the command line to the configuration file.",
"type": "object",
"properties": {
"no_interactive": {
Expand All @@ -48,7 +48,7 @@
"runtime": {
"title": "runtime",
"type": "string",
"description": "Lambda runtime for application.\n\nRuntimes: dotnet8, dotnet6, go1.x, java21, java17, java11, java8.al2, nodejs20.x, nodejs18.x, nodejs16.x, provided, provided.al2, provided.al2023, python3.9, python3.8, python3.12, python3.11, python3.10, ruby3.3, ruby3.2",
"description": "Lambda runtime for application.\n\nRuntimes: dotnet8, dotnet6, go1.x, java21, java17, java11, java8.al2, nodejs20.x, nodejs18.x, nodejs16.x, provided, provided.al2, provided.al2023, python3.9, python3.8, python3.13, python3.12, python3.11, python3.10, ruby3.3, ruby3.2",
"enum": [
"dotnet6",
"dotnet8",
Expand All @@ -66,6 +66,7 @@
"python3.10",
"python3.11",
"python3.12",
"python3.13",
"python3.8",
"python3.9",
"ruby3.2",
Expand All @@ -84,7 +85,7 @@
"base_image": {
"title": "base_image",
"type": "string",
"description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/dotnet8-base, amazon/go-provided.al2-base, amazon/go-provided.al2023-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java21-base, amazon/java8.al2-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/nodejs20.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.12-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/ruby3.3-base",
"description": "Lambda base image for deploying IMAGE based package type.\n\nBase images: amazon/dotnet6-base, amazon/dotnet8-base, amazon/go-provided.al2-base, amazon/go-provided.al2023-base, amazon/go1.x-base, amazon/java11-base, amazon/java17-base, amazon/java21-base, amazon/java8.al2-base, amazon/nodejs16.x-base, amazon/nodejs18.x-base, amazon/nodejs20.x-base, amazon/python3.10-base, amazon/python3.11-base, amazon/python3.12-base, amazon/python3.13-base, amazon/python3.8-base, amazon/python3.9-base, amazon/ruby3.2-base, amazon/ruby3.3-base",
"enum": [
"amazon/dotnet6-base",
"amazon/dotnet8-base",
Expand All @@ -101,6 +102,7 @@
"amazon/python3.10-base",
"amazon/python3.11-base",
"amazon/python3.12-base",
"amazon/python3.13-base",
"amazon/python3.8-base",
"amazon/python3.9-base",
"amazon/ruby3.2-base",
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/buildcmd/test_build_cmd_arm64.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ class TestBuildCommand_PythonFunctions_With_Specified_Architecture_arm64(BuildIn
("python3.10", "Python", False),
("python3.11", "Python", False),
("python3.12", "Python", False),
("python3.13", "Python", False),
("python3.8", "PythonPEP600", False),
("python3.9", "PythonPEP600", False),
("python3.10", "PythonPEP600", False),
("python3.11", "PythonPEP600", False),
("python3.12", "PythonPEP600", False),
("python3.13", "PythonPEP600", False),
("python3.8", "Python", "use_container"),
("python3.9", "Python", "use_container"),
("python3.10", "Python", "use_container"),
Expand All @@ -54,6 +56,7 @@ def test_with_default_requirements(self, runtime, codeuri, use_container):
@parameterized.expand(
[
("python3.12", "Python", "use_container"),
("python3.13", "Python", "use_container"),
]
)
@pytest.mark.al2023
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/buildcmd/test_build_cmd_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_with_default_requirements(self, runtime, dockerfile):

@parameterized.expand(
[
*[(runtime, "Dockerfile") for runtime in ["3.12"]],
*[(runtime, "Dockerfile.production") for runtime in ["3.12"]],
*[(runtime, "Dockerfile") for runtime in ["3.12", "3.13"]],
*[(runtime, "Dockerfile.production") for runtime in ["3.12", "3.13"]],
]
)
@pytest.mark.al2023
Expand Down Expand Up @@ -307,6 +307,8 @@ def test_with_default_requirements(self):
[
("python3.12", "Python"),
("python3.12", "PythonPEP600"),
("python3.13", "Python"),
("python3.13", "PythonPEP600"),
],
)
@pytest.mark.al2023
Expand Down Expand Up @@ -362,6 +364,7 @@ def test_with_default_requirements(self, runtime):
@parameterized.expand(
[
("python3.12",),
("python3.13",),
]
)
@pytest.mark.al2023
Expand Down Expand Up @@ -489,6 +492,9 @@ def test_with_default_requirements(self, runtime, codeuri, use_container, archit
("python3.12", "Python", False, "x86_64"),
("python3.12", "PythonPEP600", False, "x86_64"),
("python3.12", "Python", "use_container", "x86_64"),
("python3.13", "Python", False, "x86_64"),
("python3.13", "PythonPEP600", False, "x86_64"),
("python3.13", "Python", "use_container", "x86_64"),
]
)
@pytest.mark.al2023
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ numpy<1.20.3; python_version <= '3.9'
numpy==1.23.5; python_version == '3.10'
numpy==1.23.5; python_version == '3.11'
numpy==1.26.1; python_version == '3.12'
numpy==2.1.1; python_version == '3.13'
# `cryptography` has a dependency on `pycparser` which, for some reason doesn't build inside a Docker container.
# Turning this off until we resolve this issue: https://github.com/awslabs/aws-lambda-builders/issues/29
# cryptography~=2.4
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ numpy==1.20.3; python_version <= '3.9'
numpy==1.23.5; python_version == '3.10'
numpy==1.23.5; python_version == '3.11'
numpy==1.26.1; python_version == '3.12'
numpy==2.1.1; python_version == '3.13'
greenlet==3.0.1
sqlalchemy==2.0.23
2 changes: 1 addition & 1 deletion tests/unit/lib/build_module/test_workflow_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setUp(self):
self.project_dir = ""
EventTracker.clear_trackers()

@parameterized.expand([("python3.8",), ("python3.9",), ("python3.10",), ("python3.11",), ("python3.12",)])
@parameterized.expand([("python3.8",), ("python3.9",), ("python3.10",), ("python3.11",), ("python3.12",), ("python3.13",)])
def test_must_work_for_python(self, runtime):
result = get_workflow_config(runtime, self.code_dir, self.project_dir)
self.assertEqual(result.language, "python")
Expand Down
1 change: 1 addition & 0 deletions tests/unit/local/docker/test_lambda_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Runtime.python310.value,
Runtime.python311.value,
Runtime.python312.value,
Runtime.python313.value,
Runtime.dotnet6.value,
Runtime.dotnet8.value,
]
Expand Down
1 change: 1 addition & 0 deletions tests/unit/local/docker/test_lambda_debug_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Runtime.python310,
Runtime.python311,
Runtime.python312,
Runtime.python313,
]


Expand Down

0 comments on commit 92aad59

Please sign in to comment.