Skip to content

Commit

Permalink
runtime: Add python3.9 support (#260)
Browse files Browse the repository at this point in the history
* Adding python39 support (#14)

* Adding python39 support

* changing Visual Studio image from 2017 to Visual Studio 2019

* update Appveyor to solve make pr failure

* update packager.py

* Update test case

* skip new test case which is not tests in windows

* update skipif part

* black reformat

Co-authored-by: jonife <[email protected]>
  • Loading branch information
wchengru and jonife authored Aug 16, 2021
1 parent 53eabd2 commit 9ccd919
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
9 changes: 8 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ environment:
LINE_COVERAGE: '72'
NEW_FLAKE8: 1
JAVA_HOME: "C:\\Program Files\\Java\\jdk11"
- PYTHON: "C:\\Python39-x64"
PYTHON_VERSION: '3.9'
PYTHON_ARCH: '64'
LINE_COVERAGE: '72'
NEW_FLAKE8: 1
JAVA_HOME: "C:\\Program Files\\Java\\jdk11"



build: off
Expand All @@ -42,7 +49,7 @@ for:
-
matrix:
only:
- image: Visual Studio 2017
- image: Visual Studio 2019

environment:
GOPATH: c:\gopath
Expand Down
9 changes: 8 additions & 1 deletion aws_lambda_builders/workflows/python_pip/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ def __init__(self, version):


def get_lambda_abi(runtime):
supported = {"python2.7": "cp27mu", "python3.6": "cp36m", "python3.7": "cp37m", "python3.8": "cp38"}
supported = {
"python2.7": "cp27mu",
"python3.6": "cp36m",
"python3.7": "cp37m",
"python3.8": "cp38",
"python3.9": "cp39",
}

if runtime not in supported:
raise UnsupportedPythonVersion(runtime)
Expand Down Expand Up @@ -164,6 +170,7 @@ class DependencyBuilder(object):
"cp36m": (2, 17),
"cp37m": (2, 17),
"cp38": (2, 26),
"cp39": (2, 26),
}
# Fallback version if we're on an unknown python version
# not in _RUNTIME_GLIBC.
Expand Down
2 changes: 1 addition & 1 deletion aws_lambda_builders/workflows/python_pip/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class PythonRuntimeValidator(object):
SUPPORTED_RUNTIMES = {"python2.7", "python3.6", "python3.7", "python3.8"}
SUPPORTED_RUNTIMES = {"python2.7", "python3.6", "python3.7", "python3.8", "python3.9"}

def __init__(self, runtime):
self.language = "python"
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/workflows/python_pip/test_python_pip.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import os
import shutil
import sys
import platform
import tempfile
from unittest import TestCase
from unittest import TestCase, skipIf
import mock

from aws_lambda_builders.builder import LambdaBuilder
from aws_lambda_builders.exceptions import WorkflowFailedError
import logging

logger = logging.getLogger("aws_lambda_builders.workflows.python_pip.workflow")
IS_WINDOWS = platform.system().lower() == "windows"


class TestPythonPipWorkflow(TestCase):
Expand Down Expand Up @@ -44,6 +46,7 @@ def setUp(self):
"python3.7": "python2.7",
"python2.7": "python3.8",
"python3.8": "python2.7",
"python3.9": "python2.7",
}

def tearDown(self):
Expand Down Expand Up @@ -84,6 +87,7 @@ def test_runtime_validate_python_project_fail_open_unsupported_runtime(self):
self.source_dir, self.artifacts_dir, self.scratch_dir, self.manifest_path_valid, runtime="python2.8"
)

@skipIf(IS_WINDOWS, "Skip in windows tests")
def test_must_resolve_local_dependency(self):
source_dir = os.path.join(self.source_dir, "local-dependencies")
manifest = os.path.join(source_dir, "requirements.txt")
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/workflows/python_pip/test_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def test_get_lambda_abi_python37(self):
def test_get_lambda_abi_python38(self):
assert "cp38" == get_lambda_abi("python3.8")

def test_get_lambda_abi_python39(self):
assert "cp39" == get_lambda_abi("python3.9")


class TestPythonPipDependencyBuilder(object):
def test_can_call_dependency_builder(self, osutils):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/workflows/python_pip/test_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TestPythonRuntimeValidator(TestCase):
def setUp(self):
self.validator = PythonRuntimeValidator(runtime="python3.7")

@parameterized.expand(["python2.7", "python3.6", "python3.7", "python3.8"])
@parameterized.expand(["python2.7", "python3.6", "python3.7", "python3.8", "python3.9"])
def test_supported_runtimes(self, runtime):
validator = PythonRuntimeValidator(runtime=runtime)
self.assertTrue(validator.has_runtime())
Expand Down

0 comments on commit 9ccd919

Please sign in to comment.