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

Add support for Python 3.12 #2087

Merged
merged 2 commits into from
Feb 21, 2024
Merged

Add support for Python 3.12 #2087

merged 2 commits into from
Feb 21, 2024

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Dec 15, 2023

In addition to the mechanical changes needed to support a new Python version, I also made a few additional changes to get everything passing:

  • Removed testing cdkv1. CDK v1 is deprecated now, and while we still have code that will try and import cdkv1, we're no longer testing support for CDK v1.
  • Refresh the test/dev dependencies via pip-compile. New package versions were needed for Python 3.12 support.
  • Update the pylintrc config to match the previous behavior of earlier versions
  • Only use typing_extensions on Python 3.7, which is the only version that needs this. TypedDict was added in 3.8, and it's the only thing from that package that we use.

Closes #2086

@jamesls
Copy link
Member Author

jamesls commented Dec 15, 2023

Looks like there's some issues with the pylint specific to python3.12 that I'll need to track down. Otherwise the feature itself seems to be working (I can deploy python3.12 apps to Lambda).

@@ -53,8 +53,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
cdk-version: [cdk, cdkv2]
python-version: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
Copy link

@devinmatte devinmatte Dec 16, 2023

Choose a reason for hiding this comment

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

Just curious, any reason to still support Python 3.7 since it's EOL?
https://devguide.python.org/versions/
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Copy link
Member Author

Choose a reason for hiding this comment

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

I have a branch that removes 3.7 support, but we're following the python support policy for AWS SDKs and Tools (https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/), which would drop 3.7 support at the end of this month.

I was hoping to get 3.12 support released quickly and then drop support for 3.7 next month, but depending on how long it takes to work out the remaining 3.12 issues, we might end having 3.12 support + dropping 3.7 in the same release if it ends up getting pushed to next month.

Choose a reason for hiding this comment

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

@jamesls It's the new year, any chance you could take a look at this again?

@iw-an
Copy link

iw-an commented Jan 3, 2024

@jamesls @devinmatte is there any update on getting this out?

@werlex
Copy link

werlex commented Feb 7, 2024

@jamesls @devinmatte seems like 3.7 support was dropped. So you are planning to remove 3.7 support and add 3.12 with this same PR?

@@ -379,8 +379,10 @@ def test_can_load_python_version():
expected_runtime = 'python3.9'
elif minor <= 10:
expected_runtime = 'python3.10'
Copy link

Choose a reason for hiding this comment

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

Also here, we are Py 3.7+ if not 3.8+, a lot can disappear

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, there's a number of places in the tests that still reference older versions of python that can be removed. I'll send a follow up pull request to clean these up.

@jamesls
Copy link
Member Author

jamesls commented Feb 21, 2024

Quick update, python 3.7 has been deprecated for a few months now and haven't seen any issues in the SDK/other projects so I think we should be good to move ahead with also dropping 3.7 support. I think the simplest path here is to send a pr to drop 3.7 support, the rebase this PR on top. Working on this now, should have an update shortly.

@jamesls
Copy link
Member Author

jamesls commented Feb 21, 2024

Py37 dropped in #2095, going to rebase now and should be able to get a clean run through CI.

In addition to the mechanical changes needed to support a new Python
version, I also made a few additional changes to get everything passing:

* Removed testing cdkv1.  CDK v1 is deprecated now, and while we still have
  code that will try and import cdkv1, we're no longer testing support for
  CDK v1.
* Refresh the test/dev dependencies via `pip-compile`.  New package versions
  were needed for Python 3.12 support.
* Update the pylintrc config to match the previous behavior of earlier versions
* Only use `typing_extensions` on Python 3.7, which is the only version that
  needs this.  `TypedDict` was added in 3.8, and it's the only thing
  from that package that we use.
* Had to mess with Pylint because we needed to upgrade to a new major
  version to get python3.12 support.
* Breaking changes in the API required the custom pylint checkers to be
  updated.
* Also needed to update how we load custom plugins because the python
  path is changed in the new version of pylint.
* Needed to update the code for the linters because they were checking
  for the third party mock library which we haven't used in a long time.
* Had to update a few test case classes to not use the nose style tests
  which have been deprecated and now generate pytest errors.
* Test installation of pandas 2.x on 3.10 and higher.  The older
  versions don't have prebuilt binaries and will result in trying to
  compile the package, which we do not want.
* Update several tests to use the updated pytest APIs for testing for
  emitted warnings.
@jamesls jamesls merged commit e927820 into master Feb 21, 2024
26 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Python 3.12
6 participants