Skip to content

Conversation

@desertaxle
Copy link
Member

@desertaxle desertaxle commented Oct 7, 2025

This PR adds Python 3.14 support to Prefect.

Closes #19252

🤖 Generated with Claude Code

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 7, 2025

CodSpeed Performance Report

Merging #19119 will not alter performance

Comparing add-python-3.14-support (410984e) with main (3f85d23)

Summary

✅ 2 untouched

@ogenstad
Copy link
Contributor

It looks like some of these issues have been resolved in later versions of the packages. Even though orjson 3.10.18 claims to support Python 3.14 that doesn't seem to be the case. The later versions at least compiles correctly.

❯ docker run -it --rm python:3.14-slim bash
root@c5ad300c6569:/# pip install orjson==3.10.18
Collecting orjson==3.10.18
  Downloading orjson-3.10.18.tar.gz (5.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.4/5.4 MB 42.8 MB/s  0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: orjson
  Building wheel for orjson (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for orjson (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [53 lines of output]
      Running `maturin pep517 build-wheel -i /usr/local/bin/python3.14 --compatibility off`
      Python reports SOABI: cpython-314-aarch64-linux-gnu
      Computed rustc target triple: aarch64-unknown-linux-gnu
      Installation directory: /root/.cache/puccinialin
      Rustup already downloaded
      Installing rust to /root/.cache/puccinialin/rustup
      warn: It looks like you have an existing rustup settings file at:
      warn: /root/.rustup/settings.toml
      warn: Rustup will install the default toolchain as specified in the settings file,
      warn: instead of the one inferred from the default host triple.
      info: profile set to 'minimal'
      info: default host triple is aarch64-unknown-linux-gnu
      warn: Updating existing toolchain, profile choice will be ignored
      info: syncing channel updates for 'stable-aarch64-unknown-linux-gnu'
      info: default toolchain set to 'stable-aarch64-unknown-linux-gnu'
      Checking if cargo is installed
      cargo 1.90.0 (840b83a10 2025-07-30)
      📦 Including license file `LICENSE-APACHE`
      📦 Including license file `LICENSE-MIT`
      🍹 Building a mixed python/rust project
      🔗 Found pyo3-ffi bindings
      🐍 Found CPython 3.14 at /usr/local/bin/python3.14
         Compiling target-lexicon v0.13.2
         Compiling proc-macro2 v1.0.95
         Compiling unicode-ident v1.0.18
         Compiling once_cell v1.21.3
         Compiling serde v1.0.219
         Compiling rustversion v1.0.20
         Compiling libc v0.2.172
         Compiling shlex v1.3.0
         Compiling cfg-if v1.0.0
         Compiling itoa v1.0.15
         Compiling version_check v0.9.5
         Compiling ryu v1.0.20
         Compiling serde_json v1.0.140
         Compiling cc v1.2.20
         Compiling static_assertions v1.1.0
      error: linker `cc` not found
        |
        = note: No such file or directory (os error 2)

      error: could not compile `serde_json` (build script) due to 1 previous error
      warning: build failed, waiting for other jobs to finish...
      error: could not compile `serde` (build script) due to 1 previous error
      error: could not compile `rustversion` (build script) due to 1 previous error
      error: could not compile `libc` (build script) due to 1 previous error
      error: could not compile `proc-macro2` (build script) due to 1 previous error
      error: could not compile `target-lexicon` (build script) due to 1 previous error
      💥 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_BUILD_EXTENSION_MODULE="1" PYO3_ENVIRONMENT_SIGNATURE="cpython-3.14-64bit" PYO3_PYTHON="/usr/local/bin/python3.14" PYTHON_SYS_EXECUTABLE="/usr/local/bin/python3.14" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/pip-install-x28a1a6n/orjson_0abcaf6da7f74c86932f61a2c821f1e1/Cargo.toml" "--release" "--lib"`
      Rust not found, installing into a temporary directory
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/usr/local/bin/python3.14', '--compatibility', 'off'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for orjson
Failed to build orjson
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> orjson
root@c5ad300c6569:/# pip install orjson==3.11.3
Collecting orjson==3.11.3
  Downloading orjson-3.11.3-cp314-cp314-manylinux_2_34_aarch64.whl.metadata (41 kB)
Downloading orjson-3.11.3-cp314-cp314-manylinux_2_34_aarch64.whl (122 kB)
Installing collected packages: orjson
Successfully installed orjson-3.11.3
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
root@c5ad300c6569:/#

@desertaxle desertaxle force-pushed the add-python-3.14-support branch 2 times, most recently from 5f7638b to 786fc0f Compare October 16, 2025 17:04
desertaxle and others added 6 commits October 20, 2025 11:39
This PR adds Python 3.14 support to Prefect by updating version declarations and CI test matrices.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Pillow does not yet support Python 3.14, so this commit:
- Restricts pillow installation to Python <3.14 in pyproject.toml
- Makes PIL import optional in BlockStandardTestSuite
- Skips image validation tests when PIL is not available

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
cairosvg has a transitive dependency on pillow, which doesn't support
Python 3.14 yet. This prevents pillow from being installed on 3.14.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@desertaxle desertaxle force-pushed the add-python-3.14-support branch from 786fc0f to b4d3e20 Compare October 20, 2025 16:47
@github-actions github-actions bot added the enhancement An improvement of an existing feature label Oct 22, 2025

try:
if asyncio.iscoroutinefunction(hook):
if inspect.iscoroutinefunction(hook):
Copy link
Member Author

Choose a reason for hiding this comment

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

asyncio.iscoroutinefunction is deprecated in Python 3.14

Copy link
Member Author

Choose a reason for hiding this comment

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

This was created to replace V2ValidatedFunction because pydantic v1 isn't supported with Python 3.14. This implementation only uses pydantic v2.

@desertaxle desertaxle marked this pull request as ready for review October 22, 2025 19:20
Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

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

🥧

@desertaxle desertaxle merged commit 7fa6093 into main Oct 23, 2025
68 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to use Python 3.14 with prefect

4 participants