Skip to content
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

chore(lifecycle) - Add support for to create resource extensions in Python 3.8 and 3.9 #198

Merged
merged 4 commits into from
Nov 23, 2022
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
6 changes: 5 additions & 1 deletion .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: [ 3.6, 3.7, 3.8, 3.9 ]
python: [ 3.7, 3.8, 3.9 ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
Expand All @@ -38,3 +38,7 @@ jobs:
run: ./e2e-test.sh python36
- name: End to End Resource Packaging Test Python 3.7
run: ./e2e-test.sh python37
- name: End to End Resource Packaging Test Python 3.8
run: ./e2e-test.sh python38
- name: End to End Resource Packaging Test Python 3.9
run: ./e2e-test.sh python39
12 changes: 12 additions & 0 deletions python/rpdk/python/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,15 @@ class Python37LanguagePlugin(Python36LanguagePlugin):
NAME = "python37"
RUNTIME = "python3.7"
DOCKER_TAG = 3.7


class Python38LanguagePlugin(Python36LanguagePlugin):
NAME = "python38"
RUNTIME = "python3.8"
DOCKER_TAG = 3.8


class Python39LanguagePlugin(Python36LanguagePlugin):
NAME = "python39"
RUNTIME = "python3.9"
DOCKER_TAG = 3.9
20 changes: 14 additions & 6 deletions python/rpdk/python/parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def setup_subparser(subparsers, parents, python_version):
def setup_subparser(subparsers, parents, python_version, python_version_number):
parser = subparsers.add_parser(
python_version,
description="""This sub command generates IDE and build files for Python {}
""".format(
"3.6" if python_version == "python36" else "3.7"
description=(
"This sub command generates IDE and build files for Python "
"{}".format(python_version_number)
),
parents=parents,
)
Expand All @@ -22,8 +22,16 @@ def setup_subparser(subparsers, parents, python_version):


def setup_subparser_python36(subparsers, parents):
return setup_subparser(subparsers, parents, "python36")
return setup_subparser(subparsers, parents, "python36", "3.6")


def setup_subparser_python37(subparsers, parents):
return setup_subparser(subparsers, parents, "python37")
return setup_subparser(subparsers, parents, "python37", "3.7")


def setup_subparser_python38(subparsers, parents):
return setup_subparser(subparsers, parents, "python38", "3.8")


def setup_subparser_python39(subparsers, parents):
return setup_subparser(subparsers, parents, "python39", "3.9")
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ def find_version(*file_paths):
install_requires=["cloudformation-cli>=0.2.26", "types-dataclasses>=0.1.5"],
entry_points={
"rpdk.v1.languages": [
"python39 = rpdk.python.codegen:Python39LanguagePlugin",
"python38 = rpdk.python.codegen:Python38LanguagePlugin",
"python37 = rpdk.python.codegen:Python37LanguagePlugin",
"python36 = rpdk.python.codegen:Python36LanguagePlugin",
],
"rpdk.v1.parsers": [
"python39 = rpdk.python.parser:setup_subparser_python39",
"python38 = rpdk.python.parser:setup_subparser_python38",
"python37 = rpdk.python.parser:setup_subparser_python37",
"python36 = rpdk.python.parser:setup_subparser_python36",
],
Expand Down
31 changes: 30 additions & 1 deletion tests/plugin/parser_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import argparse
from rpdk.python.parser import setup_subparser_python36, setup_subparser_python37
from rpdk.python.parser import (
setup_subparser_python36,
setup_subparser_python37,
setup_subparser_python38,
setup_subparser_python39,
)


def test_setup_subparser_python36():
Expand All @@ -24,3 +29,27 @@ def test_setup_subparser_python37():

assert args.language == "python37"
assert args.use_docker is False


def test_setup_subparser_python38():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="subparser_name")

sub_parser = setup_subparser_python38(subparsers, [])

args = sub_parser.parse_args([])

assert args.language == "python38"
assert args.use_docker is False


def test_setup_subparser_python39():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="subparser_name")

sub_parser = setup_subparser_python39(subparsers, [])

args = sub_parser.parse_args([])

assert args.language == "python39"
assert args.use_docker is False