Skip to content

Support Python 3.13 and modern dependencies - #3

Open
Janekk wants to merge 1 commit into
masterfrom
py313-support
Open

Support Python 3.13 and modern dependencies#3
Janekk wants to merge 1 commit into
masterfrom
py313-support

Conversation

@Janekk

@Janekk Janekk commented Aug 4, 2026

Copy link
Copy Markdown

Make BLESS run on Python 3.13. Pushed (as asked); master untouched at f6f54cf.

  • marshmallow 2→3: dropped strict=True and .data; added **kwargs to @post_load; removed the hand-rolled check_unknown_fields (mm3 defaults to unknown=RAISE, and the old hook signature TypeErrors under 3.x regardless). Constrained to <4 — mm4 removes Schema.context and URL(require_tld=), both used here.
  • cryptography: dropped the removed backend arg; replaced the deleted private ssh._ssh_read_next_string with a documented unpack_ssh_string; ed25519 now loads via the public load_ssh_public_key, plus a test that a mismatched key header is still rejected.
  • Dependencies: boto3 1.43, cryptography 50, marshmallow 3.26; python_requires=">=3.11".
  • Packaging: lambda_compile.sh + Makefile build in the AWS Lambda base image instead of Amazon Linux 2, install non-editable, set -e.

Verified: 161 tests pass, flake8 clean, handlers import on 3.13.

The pinned dependency set (boto3 1.14.47, cryptography 2.9.2, marshmallow
2.19.2) installs on Python 3.13 but fails at import time, so a lambda
packaged from it deploys successfully and then dies on its first cold
start:

    File "urllib3/exceptions.py", line 2, in <module>
      from .packages.six.moves.http_client import IncompleteRead
    ModuleNotFoundError: No module named 'urllib3.packages.six.moves'

Bump the dependencies and port the code to their current APIs:

- marshmallow 2 -> 3: drop `strict=True` and `ValidationError.data`, which
  are now the only behaviour; add `**kwargs` to `@post_load` hooks, which
  marshmallow 3 calls with `many`/`partial`. Remove the hand-rolled
  `check_unknown_fields` validators — marshmallow 3 defaults to
  `unknown=RAISE`, so unknown fields are still rejected, and the old
  two-argument hook signature raises TypeError under 3.x regardless. Use
  the `error=` keyword for `validate.Email`.
- cryptography: drop the removed `backend` positional argument. Replace
  the private `ssh._ssh_read_next_string`, which no longer exists, with a
  documented `unpack_ssh_string` in bless.ssh.protocol. Load ed25519 keys
  via the public `load_ssh_public_key` now that hazmat supports them,
  rather than parsing the wire format by hand.
- Constrain marshmallow to <4: version 4 removes `Schema.context` and
  `validate.URL(require_tld=...)`, both of which the request schemas use.
- Declare `python_requires=">=3.11"`.

The ed25519 rewrite delegates the header/body key-type consistency check
to load_ssh_public_key instead of doing it inline, so add a test that a
mismatched header is still rejected.

Package inside the AWS Lambda Python base image rather than Amazon Linux 2:
cryptography now ships manylinux_2_34 wheels that will not install there,
and building in the runtime image keeps the bundled wheels matched to the
deployed interpreter and glibc. lambda_compile.sh installs non-editable
into ./aws_lambda_libs, which keeps build-time __editable__ .pth shims out
of the zip, and gains `set -e` so a failed install cannot yield a
silently incomplete bundle.

Verified on python3.13: 161 tests pass, flake8 clean, and both
lambda_handler_user and lambda_handler_host import from a packaged bundle.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant