From c2f1ce2144cb5118cc46a116d138ef4bd0d4c737 Mon Sep 17 00:00:00 2001 From: Haresh Nasit <84355507+hnnasit@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:53:59 -0800 Subject: [PATCH] feat: Add python3.13 runtime support (#691) * feat: Add python3.13 runime support * skip unknown_package_name test on Windows * skip test using skipTest fn --- .github/workflows/build.yml | 7 +++++ aws_lambda_builders/validator.py | 1 + .../workflows/python_pip/DESIGN.md | 2 +- .../workflows/python_pip/packager.py | 3 ++- setup.py | 1 + .../workflows/python_pip/test_python_pip.py | 27 ++++++++++--------- .../testdata/requirements-numpy.txt | 3 ++- .../workflows/python_pip/test_packager.py | 3 +++ 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d18d33bda..763ff55a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -123,6 +123,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" npm: - 8 - 9 @@ -156,6 +157,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -183,6 +185,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -213,6 +216,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -265,6 +269,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -293,6 +298,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -320,6 +326,7 @@ jobs: - "3.10" - "3.11" - "3.12" + - "3.13" steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 diff --git a/aws_lambda_builders/validator.py b/aws_lambda_builders/validator.py index 641bef650..adee8d7ec 100644 --- a/aws_lambda_builders/validator.py +++ b/aws_lambda_builders/validator.py @@ -18,6 +18,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": [ARM64, X86_64], diff --git a/aws_lambda_builders/workflows/python_pip/DESIGN.md b/aws_lambda_builders/workflows/python_pip/DESIGN.md index 1767e32d3..58f1ef308 100644 --- a/aws_lambda_builders/workflows/python_pip/DESIGN.md +++ b/aws_lambda_builders/workflows/python_pip/DESIGN.md @@ -49,7 +49,7 @@ def build_dependencies(artifacts_dir_path, :type runtime: str :param runtime: Python version to build dependencies for. This can - either be python3.8, python3.9, python3.10, python3.11 or python3.12. These are + either be python3.8, python3.9, python3.10, python3.11, python3.12 or python3.13. These are currently the only supported values. :type ui: :class:`lambda_builders.actions.python_pip.utils.UI` diff --git a/aws_lambda_builders/workflows/python_pip/packager.py b/aws_lambda_builders/workflows/python_pip/packager.py index 3fc48427a..a3d4bf0d8 100644 --- a/aws_lambda_builders/workflows/python_pip/packager.py +++ b/aws_lambda_builders/workflows/python_pip/packager.py @@ -86,6 +86,7 @@ def get_lambda_abi(runtime): "python3.10": "cp310", "python3.11": "cp311", "python3.12": "cp312", + "python3.13": "cp313", } if runtime not in supported: @@ -100,7 +101,7 @@ def __init__(self, runtime, python_exe, osutils=None, dependency_builder=None, a :type runtime: str :param runtime: Python version to build dependencies for. This can - either be python3.8, python3.9, python3.10, python3.11 or python3.12. These are currently the + either be python3.8, python3.9, python3.10, python3.11, python3.12 or python3.13. These are currently the only supported values. :type osutils: :class:`lambda_builders.utils.OSUtils` diff --git a/setup.py b/setup.py index d10bb6cf0..d6eedd07a 100644 --- a/setup.py +++ b/setup.py @@ -63,6 +63,7 @@ def read_version(): "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Internet", "Topic :: Software Development :: Build Tools", "Topic :: Utilities", diff --git a/tests/integration/workflows/python_pip/test_python_pip.py b/tests/integration/workflows/python_pip/test_python_pip.py index 9ceed3d13..162921645 100644 --- a/tests/integration/workflows/python_pip/test_python_pip.py +++ b/tests/integration/workflows/python_pip/test_python_pip.py @@ -18,7 +18,7 @@ logger = logging.getLogger("aws_lambda_builders.workflows.python_pip.workflow") IS_WINDOWS = platform.system().lower() == "windows" NOT_ARM = platform.processor() != "aarch64" -ARM_RUNTIMES = {"python3.8", "python3.9", "python3.10", "python3.11", "python3.12"} +ARM_RUNTIMES = {"python3.8", "python3.9", "python3.10", "python3.11", "python3.12", "python3.13"} @parameterized_class(("experimental_flags",), [([]), ([EXPERIMENTAL_FLAG_BUILD_PERFORMANCE])]) @@ -64,6 +64,7 @@ def setUp(self): "python3.10": "python3.9", "python3.11": "python3.10", "python3.12": "python3.11", + "python3.13": "python3.12", } def tearDown(self): @@ -96,9 +97,9 @@ def test_must_build_python_project(self): experimental_flags=self.experimental_flags, ) - if self.runtime in ("python3.12"): - self.check_architecture_in("numpy-1.26.1.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"]) - expected_files = self.test_data_files.union({"numpy", "numpy-1.26.1.dist-info", "numpy.libs"}) + if self.runtime in ("python3.12", "python3.13"): + self.check_architecture_in("numpy-2.1.2.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"]) + expected_files = self.test_data_files.union({"numpy", "numpy-2.1.2.dist-info", "numpy.libs"}) elif self.runtime in ("python3.10", "python3.11"): self.check_architecture_in("numpy-1.23.5.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"]) expected_files = self.test_data_files.union({"numpy", "numpy-1.23.5.dist-info", "numpy.libs"}) @@ -126,10 +127,10 @@ def test_must_build_python_project_python3_binary(self): executable_search_paths=[executable_dir], ) - if self.runtime in ("python3.12"): - self.check_architecture_in("numpy-1.26.1.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"]) - expected_files = self.test_data_files.union({"numpy", "numpy-1.26.1.dist-info", "numpy.libs"}) - elif self.runtime in ("python3.10", "python3.11", "python3.12"): + if self.runtime in ("python3.12", "python3.13"): + self.check_architecture_in("numpy-2.1.2.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"]) + expected_files = self.test_data_files.union({"numpy", "numpy-2.1.2.dist-info", "numpy.libs"}) + elif self.runtime in ("python3.10", "python3.11"): self.check_architecture_in("numpy-1.23.5.dist-info", ["manylinux2014_x86_64", "manylinux1_x86_64"]) expected_files = self.test_data_files.union({"numpy", "numpy-1.23.5.dist-info", "numpy.libs"}) else: @@ -174,15 +175,15 @@ def test_must_build_python_project_with_arm_architecture(self): experimental_flags=self.experimental_flags, ) expected_files = self.test_data_files.union({"numpy", "numpy.libs", "numpy-1.20.3.dist-info"}) - if self.runtime in ("python3.12"): - expected_files = self.test_data_files.union({"numpy", "numpy.libs", "numpy-1.26.1.dist-info"}) + if self.runtime in ("python3.12", "python3.13"): + expected_files = self.test_data_files.union({"numpy", "numpy.libs", "numpy-2.1.2.dist-info"}) if self.runtime in ("python3.10", "python3.11"): expected_files = self.test_data_files.union({"numpy", "numpy.libs", "numpy-1.23.5.dist-info"}) output_files = set(os.listdir(self.artifacts_dir)) self.assertEqual(expected_files, output_files) - if self.runtime in ("python3.12"): - self.check_architecture_in("numpy-1.26.1.dist-info", ["manylinux2014_aarch64"]) + if self.runtime in ("python3.12", "python3.13"): + self.check_architecture_in("numpy-2.1.2.dist-info", ["manylinux2014_aarch64"]) elif self.runtime in ("python3.10", "python3.11"): self.check_architecture_in("numpy-1.23.5.dist-info", ["manylinux2014_aarch64"]) else: @@ -247,6 +248,8 @@ def test_must_resolve_local_dependency(self): self.assertIn(f, output_files) def test_must_resolve_unknown_package_name(self): + if IS_WINDOWS and self.runtime == "python3.13": + self.skipTest("Skip test as pip install inflate64 does not work on Windows with Python 3.13") self.builder.build( self.source_dir, self.artifacts_dir, diff --git a/tests/integration/workflows/python_pip/testdata/requirements-numpy.txt b/tests/integration/workflows/python_pip/testdata/requirements-numpy.txt index 486c6b57f..3682fe698 100644 --- a/tests/integration/workflows/python_pip/testdata/requirements-numpy.txt +++ b/tests/integration/workflows/python_pip/testdata/requirements-numpy.txt @@ -2,4 +2,5 @@ numpy==1.20.3; python_version == '3.8' 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.2; python_version == '3.12' +numpy==2.1.2; python_version == '3.13' diff --git a/tests/unit/workflows/python_pip/test_packager.py b/tests/unit/workflows/python_pip/test_packager.py index 928387ddd..a2ce11f65 100644 --- a/tests/unit/workflows/python_pip/test_packager.py +++ b/tests/unit/workflows/python_pip/test_packager.py @@ -106,6 +106,9 @@ def test_get_lambda_abi_python311(self): def test_get_lambda_abi_python312(self): assert "cp312" == get_lambda_abi("python3.12") + def test_get_lambda_abi_python313(self): + assert "cp313" == get_lambda_abi("python3.13") + class TestPythonPipDependencyBuilder(object): def test_can_call_dependency_builder(self, osutils):