Skip to content

Add support for building Python 3.12x #398

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

Merged
merged 4 commits into from
Jun 2, 2025

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented May 22, 2025

  • Add checksums for Python 3.12.0 to 3.12.10

  • Set default python version to 3.12.10

  • Fix windows _bootstrap_python build generating custom "config_minimal.c". This also required adding 3.12 patch to work around the lack of sys.winver. See python-cmake-buildsystem/cpython@ca2fd1a7856 ("_bootstrap_python: Fix execution on windows disabling site import", 2025-05-13)

_bootstrap_python:

  • Fix windows build updating config_minimal.c including _typing. Follow-up of 5683458 ("cmake: Fix windows _bootstrap_python build generating custom "config_minimal.c"", 2025-05-13)

ctypes extension:

  • Introduce HAVE_FFI_CALL set to 1 only if the ffi_call symbol is found. This allows to implement the logic similar to the one introduced in autoconf.

  • On macOS, the extension requires to be built against system ffi. See python/cpython@2df82db4850 ("gh-100540: Remove obsolete Modules/_ctypes/darwin/ dlfcn shim (GH-100541)", 2022-12-29)

  • On macOS, the extension requires to compile _ctypes/malloc_closure.c along with setting define USING_MALLOC_CLOSURE_DOT_C to 1

Updated pyconfig.h.in:

  • Add the following for which there was already a configure check.
    • Headers:
      • HAVE_EDITLINE_READLINE_H
      • HAVE_MINIX_CONFIG_H
      • HAVE_PANEL_H
      • HAVE_READLINE_READLINE_H
    • Libraries:
      • HAVE_NCURSESW

Updated pyconfig.h.in and configure checks:

  • Add header checks:

    • HAVE_LINUX_FS_H
    • HAVE_NET_ETHERNET_H
    • HAVE_STDIO_H
    • HAVE_SYS_PIDFD_H
  • Add symbol checks:

    • HAVE_FFI_CLOSURE_ALLOC
    • HAVE_FFI_PREP_CIF_VAR
    • HAVE_FFI_PREP_CLOSURE_LOC
    • HAVE_SETNS
    • HAVE_TTYNAME_R
    • HAVE_UNSHARE
  • Add type checks:

    • ALIGNOF_MAX_ALIGN_T

Tests:

  • Include CPython patch to update build directory assumptions in getpath.py to
    fix test_frozen and test_sys. See python-cmake-buildsystem/cpython@b8d5fa3e61e ("getpath: Update build directory assumptions based on python-cmake-buildsystem", 2025-05-30)

Working toward addressing:

@jcfr jcfr linked an issue May 22, 2025 that may be closed by this pull request
@jcfr jcfr marked this pull request as draft May 22, 2025 22:09
@jcfr jcfr force-pushed the add-python-3.12-support branch 5 times, most recently from 3cc9a3b to 2b7b380 Compare May 27, 2025 22:42
@jamesobutler
Copy link
Contributor

@jcfr I see the CI is all green. Do you additional ad-hoc testing to see if some feature is missing or not working? Or with the green CI does that mean the Python 3.12 work is completed as well?

@jcfr
Copy link
Contributor Author

jcfr commented May 28, 2025

I was looking at some of the test failures before moving forward with the integration.

@jamesobutler
Copy link
Contributor

Ah I see the test failures are happening, but not failing the CI.

@jcfr jcfr force-pushed the add-python-3.12-support branch 5 times, most recently from 87c20ec to a383fd2 Compare June 2, 2025 18:42
jcfr and others added 4 commits June 2, 2025 14:43
* Add checksums for Python 3.12.0 to 3.12.10

* Set default python version to 3.12.10

* Fix windows _bootstrap_python build generating custom "config_minimal.c"
  This also required adding 3.12 patch to work around the lack of `sys.winver`.
  See python-cmake-buildsystem/cpython@ca2fd1a7856 ("_bootstrap_python: Fix execution on windows disabling site import", 2025-05-13)

_bootstrap_python:

* Fix windows build updating `config_minimal.c` including
  - `_typing` to follow-up on python-cmake-buildsystem/cpython@24d8b88420b ("gh-103763: Implement PEP 695 (#103764)", 2023-05-15)
  - `_winapi` to follow-up on python-cmake-buildsystem/cpython@935aa452359 ("GH-75586: Make shutil.which() on Windows more consistent with the OS (GH-103179)", 2023-04-04)

ctypes extension:

* Introduce `HAVE_FFI_CALL` set to 1 only if the `ffi_call` symbol is found.
  This allows to implement the logic similar to the one introduced in autoconf.

* On macOS, the extension requires to be built against system ffi.
  See python/cpython@2df82db4850 ("gh-100540: Remove obsolete Modules/_ctypes/darwin/ dlfcn shim (GH-100541)", 2022-12-29)

* On macOS, the extension requires to compile `_ctypes/malloc_closure.c`
  along with setting define `USING_MALLOC_CLOSURE_DOT_C` to `1`

Updated `pyconfig.h.in`:

* Add the following for which there was already a configure check.
  - Headers:
    - `HAVE_EDITLINE_READLINE_H`
    - `HAVE_MINIX_CONFIG_H`
    - `HAVE_PANEL_H`
    - `HAVE_READLINE_READLINE_H`
  - Libraries:
    - `HAVE_NCURSESW`

Updated `pyconfig.h.in` and configure checks:

* Add header checks:
  - `HAVE_LINUX_FS_H`
  - `HAVE_NET_ETHERNET_H`
  - `HAVE_STDIO_H`
  - `HAVE_SYS_PIDFD_H`

* Add symbol checks:
  - `HAVE_FFI_CLOSURE_ALLOC`
  - `HAVE_FFI_PREP_CIF_VAR`
  - `HAVE_FFI_PREP_CLOSURE_LOC`
  - `HAVE_SETNS`
  - `HAVE_TTYNAME_R`
  - `HAVE_UNSHARE`

* Add type checks:
  - `ALIGNOF_MAX_ALIGN_T`

Tests:

* Include CPython patch to update build directory assumptions in `getpath.py` to
  fix `test_frozen` and `test_sys`.
  See python-cmake-buildsystem/cpython@b8d5fa3e61e ("getpath: Update build directory assumptions based on python-cmake-buildsystem", 2025-05-30)

Co-authored-by: Brett Jia <dev.bjia56@gmail.com>
… import

Defines _BSD_SOURCE and _DEFAULT_SOURCE to ensure functions from `endian.h`
are defined.

See https://man7.org/linux/man-pages/man3/endian.3.html

Related commits:
* python/cpython@360ef843d8f ("gh-99108: Add missing md5/sha1 defines to Modules/Setup (#102308)", 2023-02-28)
* python/cpython@15665d896ba ("gh-99108: Replace SHA3 implementation HACL* version (#103597)", 2023-05-07)
@jcfr jcfr force-pushed the add-python-3.12-support branch from a383fd2 to 8c61e08 Compare June 2, 2025 18:43
@jcfr jcfr marked this pull request as ready for review June 2, 2025 18:43
@jcfr jcfr merged commit aa69719 into python-cmake-buildsystem:master Jun 2, 2025
28 checks passed
@jcfr jcfr deleted the add-python-3.12-support branch June 2, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Python 3.12
2 participants