generate_self_schema.py incompatible with Python 3.13.0b1
Python 3.13.0b1 (initially python/cpython#118009 but there have been several follow ups) changed the signature of ForwardRef._evaluate so it is now _evaluate(globalns, localns, type_params=_sentinel, *, recursive_guard)
generate_self_schema.py calls this function as follows (with a fallback):
https://github.com/pydantic/pydantic-core/blob/aed68446d61594ead7920cff3dcd478093626c8e/generate_self_schema.py#L191-L196
and therefore fails on both branches with TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
Locally I changed set() to recursive_guard=set() and it builds fine (with the UNSAFE_PYO3_SKIP_VERSION_CHECK environment variable).
Full build output
$ UNSAFE_PYO3_SKIP_VERSION_CHECK=1 RUST_BACKTRACE=1 python3.13 -m pip wheel pydantic-core
Collecting pydantic-core
Downloading pydantic_core-2.18.2.tar.gz (383 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 383.4/383.4 kB 7.4 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting typing-extensions!=4.7.0,>=4.6.0 (from pydantic-core)
File was already downloaded /tmp/html-section/typing_extensions-4.11.0-py3-none-any.whl
Building wheels for collected packages: pydantic-core
Building wheel for pydantic-core (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for pydantic-core (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [113 lines of output]
Running `maturin pep517 build-wheel -i /home/domdf/.local/bin/python3.13 --compatibility off`
📦 Including license file "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/LICENSE"
🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings
🐍 Found CPython 3.13 at /home/domdf/.local/bin/python3.13
📡 Using build options features, bindings from pyproject.toml
Compiling target-lexicon v0.12.9
Compiling autocfg v1.1.0
Compiling python3-dll-a v0.2.9
Compiling proc-macro2 v1.0.76
Compiling unicode-ident v1.0.10
Compiling once_cell v1.18.0
Compiling libc v0.2.147
Compiling heck v0.4.1
Compiling cfg-if v1.0.0
Compiling rustversion v1.0.13
Compiling version_check v0.9.4
Compiling parking_lot_core v0.9.8
Compiling static_assertions v1.1.0
Compiling smallvec v1.13.2
Compiling portable-atomic v1.6.0
Compiling tinyvec_macros v0.1.1
Compiling scopeguard v1.1.0
Compiling lexical-util v0.8.5
Compiling tinyvec v1.6.0
Compiling serde v1.0.197
Compiling memchr v2.6.3
Compiling unindent v0.2.3
Compiling serde_json v1.0.114
Compiling percent-encoding v2.3.1
Compiling unicode-bidi v0.3.13
Compiling hashbrown v0.14.3
Compiling ahash v0.8.10
Compiling num-traits v0.2.16
Compiling num-integer v0.1.45
Compiling lock_api v0.4.10
Compiling memoffset v0.9.0
Compiling num-bigint v0.4.4
Compiling zerocopy v0.7.32
Compiling regex-syntax v0.8.2
Compiling quote v1.0.35
Compiling pyo3-build-config v0.21.1
Compiling aho-corasick v1.0.2
Compiling equivalent v1.0.1
Compiling getrandom v0.2.10
Compiling indoc v2.0.4
Compiling syn v2.0.48
Compiling indexmap v2.2.2
Compiling lexical-parse-integer v0.8.6
Compiling unicode-normalization v0.1.22
Compiling parking_lot v0.12.1
Compiling form_urlencoded v1.2.1
Compiling ryu v1.0.14
Compiling lexical-parse-float v0.8.5
Compiling itoa v1.0.8
Compiling uuid v1.7.0
Compiling base64 v0.21.7
Compiling idna v0.5.0
Compiling url v2.5.0
Compiling pyo3-ffi v0.21.1
Compiling pyo3 v0.21.1
Compiling jiter v0.2.1
Compiling pydantic-core v2.18.2 (/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b)
Compiling regex-automata v0.4.5
error: failed to run custom build command for `pydantic-core v2.18.2 (/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.
Caused by:
process didn't exit successfully: `/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/target/release/build/pydantic-core-a554cfcf76de52f4/build-script-build` (exit status: 101)
--- stdout
cargo:rustc-cfg=Py_3_6
cargo:rustc-cfg=Py_3_7
cargo:rustc-cfg=Py_3_8
cargo:rustc-cfg=Py_3_9
cargo:rustc-cfg=Py_3_10
cargo:rustc-cfg=Py_3_11
cargo:rustc-cfg=Py_3_12
cargo:rustc-cfg=Py_3_13
cargo:rerun-if-changed=python/pydantic_core/core_schema.py
cargo:rerun-if-changed=generate_self_schema.py
--- stderr
Traceback (most recent call last):
File "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/generate_self_schema.py", line 193, in eval_forward_ref
return type_._evaluate(core_schema.__dict__, None, set())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/generate_self_schema.py", line 241, in <module>
main()
~~~~^^
File "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/generate_self_schema.py", line 211, in main
value = get_schema(s, definitions)
File "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/generate_self_schema.py", line 55, in get_schema
return type_dict_schema(obj, definitions)
File "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/generate_self_schema.py", line 153, in type_dict_schema
field_type = eval_forward_ref(field_type)
File "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/generate_self_schema.py", line 196, in eval_forward_ref
return type_._evaluate(core_schema.__dict__, None)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
thread 'main' panicked at build.rs:29:9:
generate_self_schema.py failed with exit status: 1
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
💥 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_ENVIRONMENT_SIGNATURE="cpython-3.13-64bit" PYO3_PYTHON="/home/domdf/.local/bin/python3.13" PYTHON_SYS_EXECUTABLE="/home/domdf/.local/bin/python3.13" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/pip-wheel-9sifp5j1/pydantic-core_922dd6d3818c420ebd6d2e431ba1e09b/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib"`
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/home/domdf/.local/bin/python3.13', '--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 pydantic-core
Failed to build pydantic-core
ERROR: Failed to build one or more wheels
We'll be testing on 3.13 very soon, just waiting to get this in PyO3 first https://github.com/PyO3/pyo3/pull/4184
This particular error should be fixed in #1299
When we changed the version explicitly in pipfile, pydantic from 1.10.15 to 1.10.16 which solved the unit test step failure issue in github Actions. Upgraded python runtime from 3.8 to 3.12 then we got the error in GitHUb actions unit test step "TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'"