Skip to content

Add support for python 3.12 #267

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
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
4 changes: 3 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.8", "3.9", "3.10", "3.11" ]
python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
Expand Down Expand Up @@ -42,3 +42,5 @@ jobs:
run: ./e2e-test.sh python310
- name: End to End Resource Packaging Test Python 3.11
run: ./e2e-test.sh python311
- name: End to End Resource Packaging Test Python 3.12
run: ./e2e-test.sh python312
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: black
exclude: templates/
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: end-of-file-fixer
Expand All @@ -34,7 +34,6 @@ repos:
additional_dependencies:
- flake8-bugbear>=19.3.0
- flake8-builtins>=1.4.1
- flake8-commas>=2.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated dependency. Covered by black so removing.

- flake8-comprehensions>=2.1.0
- flake8-debugger>=3.1.0
- flake8-pep3101>=1.2.1
Expand All @@ -52,7 +51,7 @@ repos:
- id: bandit
files: ^(src|python)/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.7.0
hooks:
- id: mypy
files: ^src/
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ What's the name of your resource type?
Select a language for code generation:
[1] java
[2] csharp
[3] python36
[4] python37
[3] python38
[4] python39
[5] python310
[6] python311
[7] python312
(enter an integer):
>> 4
Use docker for platform-independent packaging (Y/n)?
Expand Down
6 changes: 6 additions & 0 deletions python/rpdk/python/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,9 @@ class Python311LanguagePlugin(_PythonLanguagePlugin):
NAME = "python311"
RUNTIME = "python3.11"
DOCKER_TAG = 3.11


class Python312LanguagePlugin(_PythonLanguagePlugin):
NAME = "python312"
RUNTIME = "python3.12"
DOCKER_TAG = 3.12
4 changes: 4 additions & 0 deletions python/rpdk/python/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ def setup_subparser_python310(subparsers, parents):

def setup_subparser_python311(subparsers, parents):
return setup_subparser(subparsers, parents, "python311", "3.11")


def setup_subparser_python312(subparsers, parents):
return setup_subparser(subparsers, parents, "python312", "3.12")
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,20 @@ def find_version(*file_paths):
include_package_data=True,
zip_safe=True,
python_requires=">=3.8",
install_requires=["cloudformation-cli>=0.2.26", "types-dataclasses>=0.1.5"],
install_requires=[
"cloudformation-cli>=0.2.26",
"types-dataclasses>=0.1.5",
],
entry_points={
"rpdk.v1.languages": [
"python312 = rpdk.python.codegen:Python312LanguagePlugin",
"python311 = rpdk.python.codegen:Python311LanguagePlugin",
"python310 = rpdk.python.codegen:Python310LanguagePlugin",
"python39 = rpdk.python.codegen:Python39LanguagePlugin",
"python38 = rpdk.python.codegen:Python38LanguagePlugin",
],
"rpdk.v1.parsers": [
"python312 = rpdk.python.parser:setup_subparser_python312",
"python311 = rpdk.python.parser:setup_subparser_python311",
"python310 = rpdk.python.parser:setup_subparser_python310",
"python39 = rpdk.python.parser:setup_subparser_python39",
Expand All @@ -67,6 +72,7 @@ def find_version(*file_paths):
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
keywords="Amazon Web Services AWS CloudFormation",
)
8 changes: 3 additions & 5 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
# package_data -> use MANIFEST.in instead
include_package_data=True,
zip_safe=True,
python_requires=">=3.6",
python_requires=">=3.8",
install_requires=[
"boto3>=1.10.20",
'dataclasses;python_version<"3.7"',
"boto3>=1.34.6",
],
license="Apache License 2.0",
classifiers=[
Expand All @@ -27,12 +26,11 @@
"Topic :: Software Development :: Code Generators",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
keywords="Amazon Web Services AWS CloudFormation",
)
32 changes: 32 additions & 0 deletions tests/plugin/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
setup_subparser_python39,
setup_subparser_python310,
setup_subparser_python311,
setup_subparser_python312,
)


Expand Down Expand Up @@ -131,3 +132,34 @@ def test_setup_subparser_python311():

with pytest.raises(SystemExit):
sub_parser.parse_args(["--no-docker", "--use-docker"])


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

sub_parser = setup_subparser_python312(subparsers, [])

args = sub_parser.parse_args([])

assert args.language == "python312"
assert args.use_docker is False
assert args.no_docker is False

short_args = sub_parser.parse_args(["-d"])
assert short_args.language == "python312"
assert short_args.use_docker is True
assert short_args.no_docker is False

long_args = sub_parser.parse_args(["--use-docker"])
assert long_args.language == "python312"
assert long_args.use_docker is True
assert long_args.no_docker is False

no_docker = sub_parser.parse_args(["--no-docker"])
assert no_docker.language == "python312"
assert no_docker.use_docker is False
assert no_docker.no_docker is True

with pytest.raises(SystemExit):
sub_parser.parse_args(["--no-docker", "--use-docker"])