Skip to content

Conversation

@cdce8p
Copy link
Contributor

@cdce8p cdce8p commented May 23, 2025

I've pulled in the latest changes from PyO3 0.25.0 / 0.25.1 and applied the remaining patch from the current master branch again, 27d7e27. As for the other two changes:

Additional changes were necessary for _Py_IsImmortal which was made private in PyO3/pyo3#4811 and _PyDict_SetItem_KnownHash_LockHeld which isn't part of PyO3.

Fixes #569

@cdce8p cdce8p changed the title Update pyo3 to 0.25.0 and add support for Python 3.14.0b1 Update pyo3 to 0.25.0 and add support for Python 3.14.0b2 May 28, 2025
@cdce8p
Copy link
Contributor Author

cdce8p commented May 28, 2025

Tests pass with 3.14.0b2 as well.

@github-actions github-actions bot added the Stale label Jun 5, 2025
@musicinmybrain
Copy link
Contributor

This is working in Fedora to build python-orjson for Python 3.14 – thank you! – except that we are still affected by PyO3/pyo3#5175 on i686. That will be fixed upstream in pyo3-ffi by PyO3/pyo3#5180. When you have a chance, could you please update this PR with that fix as well?

@cdce8p
Copy link
Contributor Author

cdce8p commented Jun 5, 2025

That will be fixed upstream in pyo3-ffi by PyO3/pyo3#5180. When you have a chance, could you please update this PR with that fix as well?

Added the patch here as well though ideally this would be merged upstream and pyo3 would release another version "soonish".

@musicinmybrain
Copy link
Contributor

Added the patch here as well though ideally this would be merged upstream and pyo3 would release another version "soonish".

Thanks! According to PyO3/pyo3#5175 (comment), a prompt new release is planned.

@github-actions github-actions bot removed the Stale label Jun 6, 2025
@clin1234
Copy link

clin1234 commented Jun 7, 2025

Build error with your branch via pip install:

(venv) cc@pretty:~$ pip install git+https://github.com/cdce8p/orjson@python-3.14
Collecting git+https://github.com/cdce8p/orjson@python-3.14
  Cloning https://github.com/cdce8p/orjson (to revision python-3.14) to /tmp/pip-req-build-ztb6monb
  Running command git clone --filter=blob:none --quiet https://github.com/cdce8p/orjson /tmp/pip-req-build-ztb6monb
  Running command git checkout -b python-3.14 --track origin/python-3.14
  Switched to a new branch 'python-3.14'
  branch 'python-3.14' set up to track 'origin/python-3.14'.
  Resolved https://github.com/cdce8p/orjson to commit ea5a7d83f4ff5262f131d37dd1d490a634ce2626
  Installing build dependencies ... done
  Getting requirements to build wheel ... 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
  ╰─> [67 lines of output]
      Running `maturin pep517 build-wheel -i /home/cc/venv/bin/python3.14t --compatibility off`
      📦 Including license file "/tmp/pip-req-build-ztb6monb/LICENSE-APACHE"
      📦 Including license file "/tmp/pip-req-build-ztb6monb/LICENSE-MIT"
      🍹 Building a mixed python/rust project
      🔗 Found pyo3-ffi bindings
      🐍 Found CPython 3.14t at /home/cc/venv/bin/python3.14t
         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 cfg-if v1.0.0
         Compiling shlex v1.3.0
         Compiling version_check v0.9.5
         Compiling serde_json v1.0.140
         Compiling ryu v1.0.20
         Compiling itoa v1.0.15
         Compiling memchr v2.7.4
         Compiling static_assertions v1.1.0
         Compiling uuid v1.16.0
         Compiling xxhash-rust v0.8.15
         Compiling itoap v1.0.1
         Compiling jiff v0.2.10
         Compiling simdutf8 v0.1.5
         Compiling smallvec v1.15.0
         Compiling half v2.6.0
         Compiling encoding_rs v0.8.35
         Compiling associative-cache v2.0.0
         Compiling bytecount v0.6.8
         Compiling cc v1.2.20
         Compiling castaway v0.2.3
         Compiling pyo3-build-config v0.25.0 (/tmp/pip-req-build-ztb6monb/include/pyo3/pyo3-build-config)
         Compiling quote v1.0.40
         Compiling syn v2.0.101
         Compiling pyo3-ffi v0.25.0 (/tmp/pip-req-build-ztb6monb/include/pyo3/pyo3-ffi)
         Compiling orjson v3.10.18 (/tmp/pip-req-build-ztb6monb)
         Compiling serde_derive v1.0.219
         Compiling compact_str v0.9.0
      error[E0599]: no function or associated item named `new` found for struct `PyMutex` in the current scope
        --> src/ffi/fragment.rs:75:46
         |
      75 |                 ob_mutex: pyo3_ffi::PyMutex::new(),
         |                                              ^^^ function or associated item not found in `PyMutex`
      
      error[E0560]: struct `pyo3_ffi::PyObject` has no field named `_padding`
         --> src/ffi/fragment.rs:124:21
          |
      124 |                     _padding: 0,
          |                     ^^^^^^^^ `pyo3_ffi::PyObject` does not have this field
          |
          = note: available fields are: `ob_flags`
      
      error[E0599]: no function or associated item named `new` found for struct `PyMutex` in the current scope
         --> src/ffi/fragment.rs:126:50
          |
      126 |                     ob_mutex: pyo3_ffi::PyMutex::new(),
          |                                                  ^^^ function or associated item not found in `PyMutex`
      
      Some errors have detailed explanations: E0560, E0599.
      For more information about an error, try `rustc --explain E0560`.
      error: could not compile `orjson` (lib) due to 3 previous errors
      💥 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.14-64bit" PYO3_PYTHON="/home/cc/venv/bin/python3.14t" PYTHON_SYS_EXECUTABLE="/home/cc/venv/bin/python3.14t" "cargo" "rustc" "--message-format" "json-render-diagnostics" "--manifest-path" "/tmp/pip-req-build-ztb6monb/Cargo.toml" "--release" "--lib"`
      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/home/cc/venv/bin/python3.14t', '--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 to build installable wheels for some pyproject.toml based projects (orjson)

@cdce8p
Copy link
Contributor Author

cdce8p commented Jun 7, 2025

@clin1234 Which platform are you using? That might help reproduce the error. It works fine on my local machine with cp314-cp314-macosx_11_0_arm64.

@clin1234
Copy link

clin1234 commented Jun 7, 2025

@clin1234 Which platform are you using? That might help reproduce the error. It works fine on my local machine with cp314-cp314-macosx_11_0_arm64.

CPython 3.14t Linux x86_64

@cdce8p
Copy link
Contributor Author

cdce8p commented Jun 8, 2025

@clin1234 Pushed a few more commits to fix 3.14t. Would you mind checking it again?

@clin1234
Copy link

clin1234 commented Jun 8, 2025

@clin1234 Pushed a few more commits to fix 3.14t. Would you mind checking it again?

Builds successfully on my end.

Copy link

@clin1234 clin1234 left a comment

Choose a reason for hiding this comment

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

For PyMutex, would it not be simpler to use std::mem::zeroed() for initializing ob_mutex?

@cdce8p
Copy link
Contributor Author

cdce8p commented Jun 8, 2025

For PyMutex, would it not be simpler to use std::mem::zeroed() for initializing ob_mutex?

Tbh I just wanted to reuse what's already there. PyMutex::new() is patched in currently, so I just copied that.

impl PyMutex {
pub const fn new() -> PyMutex {
PyMutex {
_bits: AtomicU8::new(0),
_pin: PhantomPinned,
}
}
}

@clin1234
Copy link

clin1234 commented Jun 8, 2025

For PyMutex, would it not be simpler to use std::mem::zeroed() for initializing ob_mutex?

Tbh I just wanted to reuse what's already there. PyMutex::new() is patched in currently, so I just copied that.

impl PyMutex {
pub const fn new() -> PyMutex {
PyMutex {
_bits: AtomicU8::new(0),
_pin: PhantomPinned,
}
}
}

I suggested it mainly because of https://github.com/python/cpython/blob/main/Include/cpython/lock.h#L22-L31 and https://docs.python.org/3/c-api/init.html#c.PyMutex

@cdce8p cdce8p changed the title Update pyo3 to 0.25.0 and add support for Python 3.14.0b2 Update pyo3 to 0.25.1 and add support for Python 3.14.0b2 Jun 12, 2025
@cdce8p cdce8p changed the title Update pyo3 to 0.25.1 and add support for Python 3.14.0b2 Update pyo3 to 0.25.1 and add support for Python 3.14.0b3 Jun 19, 2025
@cdce8p
Copy link
Contributor Author

cdce8p commented Jun 19, 2025

@ijl Saw your commits yesterday. Just wanted to highlight this PR in case you'd like to reuse parts of it.

@grantlouisherman
Copy link

Hey all, I am waiting on this diff to land. Do we know when this will land?

@sh-rp
Copy link

sh-rp commented Jun 24, 2025

same here!

@cdce8p
Copy link
Contributor Author

cdce8p commented Jul 4, 2025

Not stale

@github-actions github-actions bot removed the Stale label Jul 5, 2025
@github-actions github-actions bot added the Stale label Jul 12, 2025
@cdce8p
Copy link
Contributor Author

cdce8p commented Jul 12, 2025

Not stale

@github-actions github-actions bot removed the Stale label Jul 13, 2025
@cdce8p cdce8p changed the title Update pyo3 to 0.25.1 and add support for Python 3.14.0b3 Update pyo3 to 0.25.1 and add support for Python 3.14.0b4 Jul 14, 2025
@cdce8p cdce8p mentioned this pull request Jul 14, 2025
@ijl
Copy link
Owner

ijl commented Jul 15, 2025

3.11.0 is compatible with 3.14 beta 4. PyStr in 75331b7 and ffi::compat 91f946d are different approach.

@ijl ijl closed this Jul 15, 2025
@cdce8p
Copy link
Contributor Author

cdce8p commented Jul 15, 2025

3.11.0 is compatible with 3.14 beta 4.

Awesome, thanks a lot for working on it @ijl! AFAICT this release is looking fine. Testing so far looks good.
One note, @musicinmybrain mentioned an issue with i686 earlier which was fixed in Pyo3 0.25.1. I believe the release is still based on 0.25.0.

@cdce8p cdce8p deleted the python-3.14 branch July 15, 2025 19:00
@musicinmybrain
Copy link
Contributor

One note, @musicinmybrain mentioned an issue with i686 earlier which was fixed in Pyo3 0.25.1. I believe the release is still based on 0.25.0.

The version bound is 0.25,

pyo3-ffi = { version = "0.25", default-features = false, features = ["extension-module"] }

which would allow 0.25.0, but Cargo.lock has 0.25.1

orjson/Cargo.lock

Lines 175 to 177 in 3b03a4a

[[package]]
name = "pyo3-ffi"
version = "0.25.1"

and the vendored crate in include/cargo/ in the PyPI sdist is version 0.25.1, so I think nobody should encounter problems in practice unless they go out of their way to build with 0.25.0 in particular.

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.

Build fails on Python 3.14.0b1

6 participants