Skip to content

Commit

Permalink
add support for Python 3.9 (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
wrboyce committed Oct 13, 2021
1 parent f8b5042 commit 12e648e
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [3.6, 3.7, 3.8]
python: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Checkout Code Repository
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Pin troposphere version and update to 3.x (#1029)
* Relax stage name restrictions when not using apigateway (#993)
* Wait for lambda to become active during deploy/update (#992)
* add support for Python 3.9 (#1026)

## 0.53.0
* Deprecated ACME v1 for Lets Encrypt
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'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 @@ -225,6 +225,33 @@ def test_get_manylinux_python38(self):
self.assertTrue(os.path.isfile(path))
os.remove(path)

def test_get_manylinux_python39(self):
z = Zappa(runtime="python3.9")
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.9")
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.9")
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.6")

Expand Down
2 changes: 1 addition & 1 deletion zappa/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

SUPPORTED_VERSIONS = [(3, 6), (3, 7), (3, 8)]
SUPPORTED_VERSIONS = [(3, 6), (3, 7), (3, 8), (3, 9)]

if sys.version_info[:2] not in SUPPORTED_VERSIONS:
formatted_supported_versions = [
Expand Down
6 changes: 4 additions & 2 deletions zappa/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,17 @@ def __init__(
self.manylinux_suffix_start = "cp36m"
elif self.runtime == "python3.7":
self.manylinux_suffix_start = "cp37m"
else:
elif self.runtime == "python3.8":
# The 'm' has been dropped in python 3.8+ since builds with and without pymalloc are ABI compatible
# See https://github.com/pypa/manylinux for a more detailed explanation
self.manylinux_suffix_start = "cp38"
else:
self.manylinux_suffix_start = "cp39"

# AWS Lambda supports manylinux1/2010 and manylinux2014
manylinux_suffixes = ("2014", "2010", "1")
self.manylinux_wheel_file_match = re.compile(
f'^.*{self.manylinux_suffix_start}-manylinux({"|".join(manylinux_suffixes)})_x86_64.whl$'
f'^.*{self.manylinux_suffix_start}-(manylinux_\d+_\d+_x86_64[.])?manylinux({"|".join(manylinux_suffixes)})_x86_64[.]whl$'
)
self.manylinux_wheel_abi3_file_match = re.compile(
f'^.*cp3.-abi3-manylinux({"|".join(manylinux_suffixes)})_x86_64.whl$'
Expand Down
4 changes: 3 additions & 1 deletion zappa/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ def get_runtime_from_python_version():
return "python3.6"
elif sys.version_info[1] <= 7:
return "python3.7"
else:
elif sys.version_info[1] <= 8:
return "python3.8"
else:
return "python3.9"


##
Expand Down

0 comments on commit 12e648e

Please sign in to comment.