Skip to content

adding support for Python 3.11 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--- Provide a general summary of the issue in the Title above -->
## Context
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.7/3.8/3.9/3.10 -->
<!--- Also, please make sure that you are running Zappa _from a virtual environment_ and are using Python 3.7/3.8/3.9/3.10/3.11 -->

## Expected Behavior
<!--- Tell us what should happen -->
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Before you submit this PR, please make sure that you meet these criteria:

* Did you **make sure this code actually works on Lambda**, as well as locally?

* Did you test this code with all of **Python 3.7**, **Python 3.8**, **Python 3.9** and **Python 3.10** ?
* Did you test this code with all of **Python 3.7**, **Python 3.8**, **Python 3.9**, **Python 3.10** and **Python 3.11** ?

* Does this commit ONLY relate to the issue at hand and have your linter shit all over the code?

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Install `pypa/build`
run: python -m pip install build
- name: Build sdist and wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [3.7, 3.8, 3.9, "3.10"]
python: [3.7, 3.8, 3.9, "3.10", "3.11"]
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ __Awesome!__

## Installation and Configuration

_Before you begin, make sure you are running Python 3.7/3.8/3.9/3.10 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._
_Before you begin, make sure you are running Python 3.7/3.8/3.9/3.10/3.11 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._

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

Expand Down Expand Up @@ -443,7 +443,7 @@ For instance, suppose you have a basic application in a file called "my_app.py",

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

You can also invoke interpretable Python 3.7/3.8/3.9/3.10 strings directly by using `--raw`, like so:
You can also invoke interpretable Python 3.7/3.8/3.9/3.10/3.11 strings directly by using `--raw`, like so:

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

Expand Down Expand Up @@ -984,7 +984,7 @@ to change Zappa's behavior. Use these at your own risk!
"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.
"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.
"route53_enabled": true, // Have Zappa update your Route53 Hosted Zones when certifying with a custom domain. Default true.
"runtime": "python3.10", // Python runtime to use on Lambda. Can be one of "python3.7", "python3.8", "python3.9", or "python3.10". Defaults to whatever the current Python being used is.
"runtime": "python3.11", // Python runtime to use on Lambda. Can be one of "python3.7", "python3.8", "python3.9", or "python3.10", or "python3.11". Defaults to whatever the current Python being used is.
"s3_bucket": "dev-bucket", // Zappa zip bucket,
"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.
"settings_file": "~/Projects/MyApp/settings/dev_settings.py", // Server side settings file location,
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Framework :: Django",
"Framework :: Django :: 1.11",
"Framework :: Django :: 2.0",
Expand Down
27 changes: 27 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,33 @@ def test_get_manylinux_python310(self):
self.assertTrue(os.path.isfile(path))
os.remove(path)

def test_get_manylinux_python311(self):
z = Zappa(runtime="python3.11")
self.assertIsNotNone(z.get_cached_manylinux_wheel("psycopg2-binary", "2.9.1"))
self.assertIsNone(z.get_cached_manylinux_wheel("derp_no_such_thing", "0.0"))

# mock with a known manylinux wheel package so that code for downloading them gets invoked
mock_installed_packages = {"psycopg2-binary": "2.9.1"}
with mock.patch(
"zappa.core.Zappa.get_installed_packages",
return_value=mock_installed_packages,
):
z = Zappa(runtime="python3.11")
path = z.create_lambda_zip(handler_file=os.path.realpath(__file__))
self.assertTrue(os.path.isfile(path))
os.remove(path)

# same, but with an ABI3 package
mock_installed_packages = {"cryptography": "2.8"}
with mock.patch(
"zappa.core.Zappa.get_installed_packages",
return_value=mock_installed_packages,
):
z = Zappa(runtime="python3.11")
path = z.create_lambda_zip(handler_file=os.path.realpath(__file__))
self.assertTrue(os.path.isfile(path))
os.remove(path)

def test_getting_installed_packages(self, *args):
z = Zappa(runtime="python3.7")

Expand Down
2 changes: 1 addition & 1 deletion zappa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def running_in_docker() -> bool:
return running_in_docker_flag


SUPPORTED_VERSIONS = [(3, 7), (3, 8), (3, 9), (3, 10)]
SUPPORTED_VERSIONS = [(3, 7), (3, 8), (3, 9), (3, 10), (3, 11)]
MINIMUM_SUPPORTED_MINOR_VERSION = 7

if not running_in_docker() and sys.version_info[:2] not in SUPPORTED_VERSIONS:
Expand Down
4 changes: 3 additions & 1 deletion zappa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,10 @@ def __init__(
self.manylinux_suffix_start = "cp38"
elif self.runtime == "python3.9":
self.manylinux_suffix_start = "cp39"
else:
elif self.runtime == "python3.10":
self.manylinux_suffix_start = "cp310"
else:
self.manylinux_suffix_start = "cp311"

# AWS Lambda supports manylinux1/2010, manylinux2014, and manylinux_2_24
manylinux_suffixes = ("_2_24", "2014", "2010", "1")
Expand Down
4 changes: 3 additions & 1 deletion zappa/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,10 @@ def get_runtime_from_python_version():
return "python3.8"
elif sys.version_info[1] <= 9:
return "python3.9"
else:
elif sys.version_info[1] <= 10:
return "python3.10"
else:
return "python3.11"


##
Expand Down