Skip to content

Commit 71b82d7

Browse files
RemyTincosumanth-zeneviltwin
authored
Add support for Python 3.13 in templates, CI, and codebase (#1364)
* Add support for Python 3.13 in templates, CI, and codebase * Update test cases for psycopg-binary and cryptography to latest versions * Fix lint error in test * Update README.md Co-authored-by: Graham Lyon <graham.lyon@gmail.com> --------- Co-authored-by: sumanth <sumanth@gstzen.in> Co-authored-by: Graham Lyon <graham.lyon@gmail.com>
1 parent b83a1da commit 71b82d7

10 files changed

Lines changed: 63 additions & 24 deletions

File tree

.github/ISSUE_TEMPLATE.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
11
<!--- Provide a general summary of the issue in the Title above -->
2+
23
## Context
4+
35
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
4-
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.8/3.9/3.10/3.11/3.12 -->
6+
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.8/3.9/3.10/3.11/3.12/3.13 -->
57

68
## Expected Behavior
9+
710
<!--- Tell us what should happen -->
811

912
## Actual Behavior
13+
1014
<!--- Tell us what happens instead -->
1115

1216
## Possible Fix
17+
1318
<!--- Not obligatory, but suggest a fix or reason for the bug -->
1419

1520
## Steps to Reproduce
21+
1622
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
1723
<!--- reproduce this bug include code to reproduce, if relevant -->
24+
1825
1.
1926
2.
2027
3.
2128

2229
## Your Environment
30+
2331
<!--- Include as many relevant details about the environment you experienced the bug in -->
24-
* Zappa version used:
25-
* Operating System and Python version:
26-
* The output of `pip freeze`:
27-
* Link to your project (optional):
28-
* Your `zappa_settings.json`:
32+
33+
- Zappa version used:
34+
- Operating System and Python version:
35+
- The output of `pip freeze`:
36+
- Link to your project (optional):
37+
- Your `zappa_settings.json`:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Before you submit this PR, please make sure that you meet these criteria:
2020
2121
* Did you **make sure this code actually works on Lambda**, as well as locally?
2222
23-
* Did you test this code with all of: **Python 3.8**, **Python 3.9**, **Python 3.10**, **Python 3.11**, and **Python 3.12**?
23+
* Did you test this code with all of: **Python 3.8**, **Python 3.9**, **Python 3.10**, **Python 3.11**, **Python 3.12**, and **Python 3.13**?
2424
2525
* Does this commit ONLY relate to the issue at hand and have your linter shit all over the code?
2626
@@ -31,9 +31,10 @@ Thank you for your contribution!
3131
-->
3232

3333
## Description
34-
<!-- Please describe the changes included in this PR -->
34+
35+
<!-- Please describe the changes included in this PR -->
3536

3637
## GitHub Issues
38+
3739
<!-- Proposed changes should be discussed in an issue before submitting a PR. -->
3840
<!-- Link to relevant tickets here. -->
39-

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: # yamllint disable-line rule:truthy
3+
on: # yamllint disable-line rule:truthy
44
pull_request:
55
branches: ["master"]
66
push:
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
14+
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
1515
steps:
1616
- name: Checkout Code Repository
1717
uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: isort
1313
args: [--profile=black, --gitignore]
1414
- repo: https://github.com/psf/black
15-
rev: 24.1.1
15+
rev: 24.8.0
1616
hooks:
1717
- id: black
1818
args: [--line-length=127]

Pipfile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ url = "https://pypi.org/simple"
44
verify_ssl = true
55

66
[dev-packages]
7-
black = "==24.1.1"
7+
black = "==24.8.0"
88
boto3-stubs = "*"
99
coveralls = "*"
10-
Django = "<4"
10+
django = ">4,<6"
1111
django-stubs = "*"
1212
flake8 = "==7.0.0"
1313
Flask = "*"
@@ -18,6 +18,7 @@ packaging = "*"
1818
pre-commit = "*"
1919
pytest = "*"
2020
pytest-cov = "*"
21+
legacy-cgi = "*"
2122

2223
[packages]
2324
argcomplete = "*"
@@ -26,20 +27,18 @@ durationpy = "*"
2627
hjson = "*"
2728
jmespath = "*"
2829
kappa = "==0.6.0"
29-
pip = ">=9.0.1"
30-
# Workaround until tests are updated to work with 'placebo' 0.10
31-
# Move to 'dev-packages' when unpinned
30+
pip = ">=24.0.0"
3231
placebo = "<0.10"
3332
python-dateutil = "*"
3433
python-slugify = "*"
3534
PyYAML = "*"
36-
# previous versions don't work with urllib3 1.24
37-
requests = ">=2.20.0"
35+
requests = ">=2.32.0"
3836
toml = "*"
39-
tqdm = "*"
37+
tqdm = ">=4.66.3"
4038
troposphere = ">=3.0"
4139
Werkzeug = "*"
4240
wheel = "*"
41+
setuptools = "*"
4342

4443
[pipenv]
4544
allow_prereleases = false

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ And finally, Zappa is **super easy to use**. You can deploy your application wit
133133

134134
## Installation and Configuration
135135

136-
_Before you begin, make sure you are running Python 3.8/3.9/3.10/3.11/3.12 and you have a valid AWS account and your [AWS credentials file](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) is properly installed._
136+
_Before you begin, make sure you are running Python 3.8/3.9/3.10/3.11/3.12/3.13 and you have a valid AWS account and your [AWS credentials file](https://blogs.aws.amazon.com/security/post/Tx3D6U6WSFGOK2H/A-New-and-Standardized-Way-to-Manage-Credentials-in-the-AWS-SDKs) is properly installed._
137137

138138
**Zappa** can easily be installed through pip, like so:
139139

@@ -444,7 +444,7 @@ For instance, suppose you have a basic application in a file called "my_app.py",
444444

445445
Any remote print statements made and the value the function returned will then be printed to your local console. **Nifty!**
446446

447-
You can also invoke interpretable Python 3.8/3.9/3.10/3.11/3.12 strings directly by using `--raw`, like so:
447+
You can also invoke interpretable Python 3.8/3.9/3.10/3.11/3.12/3.13 strings directly by using `--raw`, like so:
448448

449449
$ zappa invoke production "print(1 + 2 + 3)" --raw
450450

@@ -992,7 +992,7 @@ to change Zappa's behavior. Use these at your own risk!
992992
"role_name": "MyLambdaRole", // Name of Zappa execution role. Default <project_name>-<env>-ZappaExecutionRole. To use a different, pre-existing policy, you must also set manage_roles to false.
993993
"role_arn": "arn:aws:iam::12345:role/app-ZappaLambdaExecutionRole", // ARN of Zappa execution role. Default to None. To use a different, pre-existing policy, you must also set manage_roles to false. This overrides role_name. Use with temporary credentials via GetFederationToken.
994994
"route53_enabled": true, // Have Zappa update your Route53 Hosted Zones when certifying with a custom domain. Default true.
995-
"runtime": "python3.12", // Python runtime to use on Lambda. Can be one of: "python3.8", "python3.9", "python3.10", "python3.11", or "python3.12". Defaults to whatever the current Python being used is.
995+
"runtime": "python3.13", // Python runtime to use on Lambda. Can be one of: "python3.8", "python3.9", "python3.10", "python3.11", "python3.12", or "python3.13". Defaults to whatever the current Python being used is.
996996
"s3_bucket": "dev-bucket", // Zappa zip bucket,
997997
"slim_handler": false, // Useful if project >50M. Set true to just upload a small handler to Lambda and load actual project from S3 at runtime. Default false.
998998
"snap_start": "PublishedVersions", // Enable Lambda SnapStart for faster cold starts. Can be "PublishedVersions" or "None". Default "None".

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"Programming Language :: Python :: 3.10",
5050
"Programming Language :: Python :: 3.11",
5151
"Programming Language :: Python :: 3.12",
52+
"Programming Language :: Python :: 3.13",
5253
"Framework :: Django",
5354
"Framework :: Django :: 3.2",
5455
"Framework :: Django :: 4.2",

tests/tests.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,33 @@ def test_get_manylinux_python312(self):
237237
self.assertTrue(os.path.isfile(path))
238238
os.remove(path)
239239

240+
def test_get_manylinux_python313(self):
241+
z = Zappa(runtime="python3.13")
242+
self.assertIsNotNone(z.get_cached_manylinux_wheel("psycopg-binary", "3.2.5"))
243+
self.assertIsNone(z.get_cached_manylinux_wheel("derp_no_such_thing", "0.0"))
244+
245+
# mock with a known manylinux wheel package so that code for downloading them gets invoked
246+
mock_installed_packages = {"psycopg-binary": "3.2.5"}
247+
with mock.patch(
248+
"zappa.core.Zappa.get_installed_packages",
249+
return_value=mock_installed_packages,
250+
):
251+
z = Zappa(runtime="python3.13")
252+
path = z.create_lambda_zip(handler_file=os.path.realpath(__file__))
253+
self.assertTrue(os.path.isfile(path))
254+
os.remove(path)
255+
256+
# same, but with an ABI3 package
257+
mock_installed_packages = {"cryptography": "44.0.2"}
258+
with mock.patch(
259+
"zappa.core.Zappa.get_installed_packages",
260+
return_value=mock_installed_packages,
261+
):
262+
z = Zappa(runtime="python3.13")
263+
path = z.create_lambda_zip(handler_file=os.path.realpath(__file__))
264+
self.assertTrue(os.path.isfile(path))
265+
os.remove(path)
266+
240267
def test_verify_downloaded_manylinux_wheel(self):
241268
z = Zappa(runtime="python3.10")
242269
cached_wheels_dir = os.path.join(tempfile.gettempdir(), "cached_wheels")

zappa/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def running_in_docker() -> bool:
1212
return running_in_docker_flag
1313

1414

15-
SUPPORTED_VERSIONS = [(3, 8), (3, 9), (3, 10), (3, 11), (3, 12)]
15+
SUPPORTED_VERSIONS = [(3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (3, 13)]
1616
MINIMUM_SUPPORTED_MINOR_VERSION = 8
1717

1818
if not running_in_docker() and sys.version_info[:2] not in SUPPORTED_VERSIONS:

zappa/utilities.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ def get_runtime_from_python_version():
220220
return "python3.11"
221221
elif sys.version_info[1] == 12:
222222
return "python3.12"
223+
elif sys.version_info[1] == 13:
224+
return "python3.13"
223225
else:
224226
raise ValueError(f"Python f{'.'.join(str(v) for v in sys.version_info[:2])} is not yet supported.")
225227

0 commit comments

Comments
 (0)