aws-powertools / powertools-lambda-python

A developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/python/latest/
MIT No Attribution
2.79k stars 386 forks source link

Maintenance: Support for Python 3.11 #2732

Closed heitorlessa closed 1 year ago

heitorlessa commented 1 year ago

Why is this needed?

Python 3.11 official docker image is available in preview: https://github.com/aws/aws-lambda-base-images/issues/62#issuecomment-1569890315

Which area does this relate to?

Other

Solution

Add support in CI. We have some customers using Python 3.11 using OCI images in Lambda.

Acknowledgment

leandrodamascena commented 1 year ago

Initial findings:

1 - We need to remove python-snappy from the dev dependencies and refactor the example that uses it. This library does not support Python 3.11. There is an issue adding support for Python 3.11 (https://github.com/andrix/python-snappy/issues/124), but I have no idea when.

• Installing python-snappy (0.6.1): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke build_wheel

  /tmp/tmpuenu801o/.venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'cffi_modules'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-cpython-311
  creating build/lib.linux-x86_64-cpython-311/snappy
  copying src/snappy/snappy_formats.py -> build/lib.linux-x86_64-cpython-311/snappy

2 - I got this error on the LRU cache test and I couldn't understand why we have this test. Do you have any historical data to help us @heitorlessa? Looks like we don't need this test.

    def test_lru_pop_failing():
        cache = LRUDict()
        key = "test"
        cache[key] = "value"
        try:
            cache.pop(key, None)
>           pytest.fail("GitHub #300: LRUDict pop bug has been fixed :)")
E           Failed: GitHub #300: LRUDict pop bug has been fixed :)

tests/unit/test_lru_cache.py:67: Failed
================================================================================================================================================ short test summary info ================================================================================================================================================
FAILED tests/unit/test_lru_cache.py::test_lru_pop_failing - Failed: GitHub #300: LRUDict pop bug has been fixed :)

3 - If we remove the python-snappy library and this LRU test, our CI works fine and we have no compatibility issues with our code.

4 - I will start some exploratory tests using the image available here: https://gallery.ecr.aws/lambda/python.

Thanks

leandrodamascena commented 1 year ago

For transparency, here's our playbook for releasing a new version of Powertools to add support for the AWS Lambda Python 3.11 runtime, when it's released in GA.

Steps

1. Prerequisites

2. Testing locally

3. Bumping the supported runtimes in the layer construct

On the CDK Layer repository, do:

4. Updating workflows and templates

5. Layer

6. SAR

7. Change the PyPi metadata

8. Open a PR and run E2E tests

9. Examples

10. Merge and release

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] commented 1 year ago

This is now released under 2.22.0 version!

github-actions[bot] commented 1 year ago

This is now released under 2.23.0 version!