Skip to content

Supporting in-development Python versions #5093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
davidhewitt opened this issue Apr 25, 2025 · 8 comments · May be fixed by #5144
Open

Supporting in-development Python versions #5093

davidhewitt opened this issue Apr 25, 2025 · 8 comments · May be fixed by #5144

Comments

@davidhewitt
Copy link
Member

This release cycle for Python 3.14 I've seen a lot of user requests for PyO3 to support 3.14 already, and I expect there will be similar demand for 3.15 as soon as 3.14 is stable. Maybe some folks testing 3.15 on CPython main might care as soon as 3.14 is in beta.

At the moment our version check basically refuses to build for 3.14 except in abi3 mode, which is safe but doesn't work for all projects (or free-threaded Python). This is 100% safe but gets in the way of development efforts.

For some reasonable definition of "in-development" Python (TBC how we decide / detect this), I propose that we relax this a bit and just emit warnings (probably at both build time and runtime). Maybe we require opt-in with an environment variable, similar to how we have PYO3_USE_ABI3_FORWARD_COMPATIBILITY for future stable Python versions.

I think also for supporting future versions of CPython, we should allow PRs to support the Python main branch (currently 3.14, soon to be 3.15). We should also run development versions on CI, but they should not block merge until they are stable.

In this direction, I think #4811 should probably also be merged asap as 3.14 beta is very close and we should start testing 3.14 beta in CI.

Would be interested to hear everyone's thoughts on the matter!

@ngoldbaum
Copy link
Contributor

In this direction, I think #4811 should probably also be merged asap as 3.14 beta is very close and we should start testing 3.14 beta in CI.

Hearty +1.

Also OK with allowing early testing with 3.15.

@alex
Copy link
Contributor

alex commented May 13, 2025

Hmm, is there a bug here? I'm seeing the:

DEBUG   error: the configured Python interpreter version (3.14) is newer than PyO3's maximum supported version (3.13)
DEBUG   = help: please check if an updated version of PyO3 is available. Current version: 0.24.2
DEBUG   = help: set PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to suppress this check and build anyway using the stable ABI

error for a build that has features = ["abi3"] (but does not specify a particular abi3 version). It seems like defaulting to the highest available abi3 is a safe and sensible behavior?

@davidhewitt
Copy link
Member Author

I don't think there's a bug; at the moment the logic is:

  • we don't know what the 3.14 ABI and runtime behaviour actually is
  • you can choose to attempt to use abi3 to build and run anyway

I think for this case of an in-dev version where you request to build with abi3 we could just build and assume abi3 works fine, maybe with warnings that PyO3 doesn't officially support this version yet.

@alex
Copy link
Contributor

alex commented May 13, 2025

From my perspective, the theory of abi3 is: it must be valid to build abi3-py313 and use it on a Python 3.14, therefore it should be ok to, when running on Python 3.14, also build for 3.13-abi3 :-)

So from that perspective, there should be no correctness risk, it's just a question of whether downgrading like this is too unintuitive to be the default behavior.

@reaperhulk
Copy link

FWIW, abi3-py313 on an in-dev Python 3.14 would have been my assumption of expected behavior on a generic abi3 build that targets "current version".

@alex
Copy link
Contributor

alex commented May 13, 2025

I think:

diff --git a/pyo3-build-config/src/impl_.rs b/pyo3-build-config/src/impl_.rs
index 9485b8a03..56baaf4e6 100644
--- a/pyo3-build-config/src/impl_.rs
+++ b/pyo3-build-config/src/impl_.rs
@@ -730,6 +730,8 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
             );
 
             self.version = version;
+        } else if self.version > SUPPORTED_VERSIONS_CPYTHON.max {
+            self.version = SUPPORTED_VERSIONS_CPYTHON.max;
         }
 
         Ok(())

is roughly the desired behavior, but SUPPORTED_VERSIONS_CPYTHON isn't actually defined in this file, so I haven't tested.

(And with apologies, I'm now walking away from my computer for most of the day :-))

@davidhewitt
Copy link
Member Author

If you have already opted for abi3, building for "newest known" abi3 version makes a ton of sense for future compatibility, I support that.

I guess the only question is whether it makes sense to warn, maybe just at build time?

@alex
Copy link
Contributor

alex commented May 13, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants