Skip to content

Add support for building Python 3.10.x #383

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 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ jobs:
workflows:
build-and-test:
jobs:
# 3.10.17
- build-test-python:
name: python-3.10.17-x64
python_version: 3.10.17
python_arch: x64

- build-test-python:
name: python-3.10.17-x86
python_version: 3.10.17
python_arch: x86

# 3.9.22
- build-test-python:
name: python-3.9.22-x64
Expand Down Expand Up @@ -133,6 +144,13 @@ workflows:

build-and-test-win:
jobs:
# 3.10.17
- build-test-python-win:
name: python-3.10.17-win-x64
python_version: 3.10.17
python_arch: x64
generator: "Visual Studio 16 2019"

# 3.9.22
- build-test-python-win:
name: python-3.9.22-win-x64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
runs-on: [macos-latest]
python-version: [3.7.17, 3.8.20, 3.9.22]
python-version: [3.7.17, 3.8.20, 3.9.22, 3.10.17]
include:
- runs-on: macos-latest
c-compiler: "clang"
Expand Down
52 changes: 48 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20.6)

set(PYTHON_VERSION "3.9.22" CACHE STRING "The version of Python to build.")
set(PYTHON_VERSION "3.10.17" CACHE STRING "The version of Python to build.")

string(REPLACE "." ";" VERSION_LIST ${PYTHON_VERSION})
list(GET VERSION_LIST 0 PY_VERSION_MAJOR)
Expand Down Expand Up @@ -66,17 +66,35 @@ option(BUILD_EXTENSIONS_AS_BUILTIN "Default all modules as builtin to libpython"
option(USE_LIB64 "Search for dependencies and install to prefix/lib64 instead of prefix/lib" OFF)
if(WIN32)
option(INSTALL_WINDOWS_TRADITIONAL "Install the executable and extensions in the traditional location" OFF)
else()
set(INSTALL_WINDOWS_TRADITIONAL OFF)
endif()

if(WIN32 AND PY_VERSION VERSION_GREATER_EQUAL "3.10")
if(DEFINED BUILD_WININST)
message(AUTHOR_WARNING "BUILD_WININST option is *NOT* supported with Python >= 3.10. Current version is ${PY_VERSION}")
message(AUTHOR_WARNING "Unsetting cache variable BUILD_WININST")
unset(BUILD_WININST CACHE)
endif()
if(DEFINED BUILD_WININST_ALWAYS)
message(AUTHOR_WARNING "BUILD_WININST_ALWAYS option is *NOT* supported with Python >= 3.10. Current version is ${PY_VERSION}")
message(AUTHOR_WARNING "Unsetting cache variable BUILD_WININST_ALWAYS")
unset(BUILD_WININST_ALWAYS CACHE)
endif()
endif()

if(WIN32 AND PY_VERSION VERSION_LESS "3.10")
set(_build_wininst_default ON)
if(CMAKE_CROSSCOMPILING)
set(_build_wininst_default OFF)
endif()
option(BUILD_WININST "Build 'Windows Installer' program for distutils if not already provided in the source tree." ${_build_wininst_default})
cmake_dependent_option(BUILD_WININST_ALWAYS "Always build 'Windows installer' program even if provided in the source tree." OFF "BUILD_WININST" OFF)
else()
set(INSTALL_WINDOWS_TRADITIONAL OFF)
set(BUILD_WININST OFF)
set(BUILD_WININST_ALWAYS OFF)
endif()

option(INSTALL_DEVELOPMENT "Install files required to develop C extensions" ON)
option(INSTALL_MANUAL "Install man files" ON)
option(INSTALL_TEST "Install test files" ON)
Expand Down Expand Up @@ -117,8 +135,7 @@ cmake_dependent_option(USE_SYSTEM_LIBMPDEC "Use system LIBMPDEC" OFF "USE_SYSTEM

cmake_dependent_option(USE_BUILTIN_ZLIB "Use builtin ZLIB" ${_use_builtin_zlib_default} "NOT USE_SYSTEM_ZLIB" OFF)

cmake_dependent_option(USE_LIBEDIT "Use libedit instead of readline" OFF
"USE_SYSTEM_READLINE" OFF)
option(USE_LIBEDIT "Use libedit instead of readline" OFF)

option(WITH_TSC "profile with the Pentium timestamp counter" OFF)
option(ENABLE_IPV6 "Enable IP v6" ON)
Expand Down Expand Up @@ -261,6 +278,25 @@ set(_download_3.9.19_md5 "b4d723903d0a8266b110c3da2f992416")
set(_download_3.9.20_md5 "896c19e5815ba990a3d1261502ea9f83")
set(_download_3.9.21_md5 "e61b3568082b57d55fd74cfc7ca020b4")
set(_download_3.9.22_md5 "8fe76e248a0e149ac23e8e4886397475")
# 3.10.x
set(_download_3.10.0_md5 "729e36388ae9a832b01cf9138921b383")
set(_download_3.10.1_md5 "91822157a97da16203877400c810d93e")
set(_download_3.10.2_md5 "67c92270be6701f4a6fed57c4530139b")
set(_download_3.10.3_md5 "f276ffcd05bccafe46da023d0a5bb04a")
set(_download_3.10.4_md5 "7011fa5e61dc467ac9a98c3d62cfe2be")
set(_download_3.10.5_md5 "d87193c077541e22f892ff1353fac76c")
set(_download_3.10.6_md5 "d76638ca8bf57e44ef0841d2cde557a0")
set(_download_3.10.7_md5 "1aea68575c0e97bc83ff8225977b0d46")
set(_download_3.10.8_md5 "fbe3fff11893916ad1756b15c8a48834")
set(_download_3.10.9_md5 "25eb3686327c157dcb8ac9f01105c306")
set(_download_3.10.10_md5 "6dbe644dd1a520d9853cf6648084c346")
set(_download_3.10.11_md5 "7e25e2f158b1259e271a45a249cb24bb")
set(_download_3.10.12_md5 "1d64320e0b0df6e9ab7e611bacb2178d")
set(_download_3.10.13_md5 "cbcad7f5e759176bf8ce8a5f9d487087")
set(_download_3.10.14_md5 "f67d78c8323a18fe6b945914c51a7aa6")
set(_download_3.10.15_md5 "b6a2b570ea75ef55f50bfe79d778eb01")
set(_download_3.10.16_md5 "2515d8571c6fdd7fc620aa9e1cc6d202")
set(_download_3.10.17_md5 "763324aa2b396ee10a51bfa6c645d8e9")

set(_extracted_dir "Python-${PY_VERSION}")

Expand Down Expand Up @@ -376,6 +412,14 @@ else()
endif()
endif()

if(PY_VERSION VERSION_GREATER_EQUAL "3.10")
option(WITH_VALGRIND "Enable to disable pymalloc when running under valgrind" OFF)
else()
if(DEFINED WITH_VALGRIND)
message(AUTHOR_WARNING "WITH_VALGRIND option is *NOT* supported with Python < 3.10. Current version is ${PY_VERSION}")
endif()
endif()

if(PY_VERSION VERSION_GREATER_EQUAL "3.7")
set(WITH_SSL_DEFAULT_SUITES "python" CACHE STRING "Override default cipher suites string: python, openssl or a custom string")
if("${WITH_SSL_DEFAULT_SUITES}" STREQUAL "python")
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ How to use this buildsystem:

.. note::

By default, the build system will download the python 3.9.22 source from
By default, the build system will download the python 3.10.17 source from
http://www.python.org/ftp/python/


Expand All @@ -72,7 +72,7 @@ options on the commandline with `-DOPTION=VALUE`, or use the "ccmake" gui.

::

PYTHON_VERSION=major.minor.patch (defaults to 3.9.22)
PYTHON_VERSION=major.minor.patch (defaults to 3.10.17)
The version of Python to build.

PYTHON_APPLY_PATCHES=ON|OFF (defaults to ON)
Expand Down
37 changes: 34 additions & 3 deletions cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ check_include_files(langinfo.h HAVE_LANGINFO_H)
check_include_files(libintl.h HAVE_LIBINTL_H)
check_include_files(libutil.h HAVE_LIBUTIL_H)
check_include_files(linux/tipc.h HAVE_LINUX_TIPC_H)
check_include_files(linux/auxvec.h HAVE_LINUX_AUXVEC_H) # Python 3.10
check_include_files(locale.h HAVE_LOCALE_H)

check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
Expand Down Expand Up @@ -334,7 +335,11 @@ check_include_files(process.h HAVE_PROCESS_H)
check_include_files(pthread.h HAVE_PTHREAD_H)
check_include_files(pty.h HAVE_PTY_H)
check_include_files(pwd.h HAVE_PWD_H)
check_include_files("stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H)
if(USE_LIBEDIT)
check_include_files("stdio.h;editline/readline.h" HAVE_READLINE_READLINE_H)
else()
check_include_files("stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H)
endif()
check_include_files(semaphore.h HAVE_SEMAPHORE_H)
check_include_files(shadow.h HAVE_SHADOW_H)
check_include_files(signal.h HAVE_SIGNAL_H)
Expand All @@ -346,8 +351,10 @@ check_include_files(string.h HAVE_STRING_H) # libffi and cpython
check_include_files(stropts.h HAVE_STROPTS_H)
check_include_files(sysexits.h HAVE_SYSEXITS_H)
check_include_files(sys/audioio.h HAVE_SYS_AUDIOIO_H)
check_include_files(sys/auxv.h HAVE_SYS_AUXV_H) # Python 3.10
check_include_files(sys/bsdtty.h HAVE_SYS_BSDTTY_H)
check_include_files(sys/epoll.h HAVE_SYS_EPOLL_H)
check_include_files(sys/eventfd.h HAVE_SYS_EVENTFD_H) # Python 3.10
check_include_files(sys/event.h HAVE_SYS_EVENT_H)
check_include_files(sys/file.h HAVE_SYS_FILE_H)
check_include_files(sys/loadavg.h HAVE_SYS_LOADAVG_H)
Expand Down Expand Up @@ -432,7 +439,11 @@ endif()

find_library(HAVE_LIBNCURSES ncurses)
find_library(HAVE_LIBNSL nsl)
find_library(HAVE_LIBREADLINE readline)
if(USE_LIBEDIT)
find_library(HAVE_LIBREADLINE edit)
else()
find_library(HAVE_LIBREADLINE readline)
endif()
find_library(HAVE_LIBSENDFILE sendfile)
find_library(HAVE_LIBTERMCAP termcap)

Expand Down Expand Up @@ -477,6 +488,16 @@ if(WITH_THREAD OR PY_VERSION VERSION_GREATER_EQUAL "3.7")
endif()
endif()

if(WITH_VALGRIND AND PY_VERSION VERSION_GREATER_EQUAL "3.10")
check_include_files(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
if(NOT HAVE_VALGRIND_VALGRIND_H)
message(FATAL_ERROR "Valgrind support requested but headers not available")
endif()
set(DYNAMIC_ANNOTATIONS_ENABLED 1)
else()
set(DYNAMIC_ANNOTATIONS_ENABLED 0)
endif()

set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_cv_lib_crypto_RAND_egd.c)
file(WRITE ${check_src} "/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
Expand Down Expand Up @@ -696,6 +717,7 @@ check_type_size(float SIZEOF_FLOAT)
check_type_size(fpos_t SIZEOF_FPOS_T)
check_type_size(int SIZEOF_INT)
check_type_size(long SIZEOF_LONG)
check_type_size(long ALIGNOF_LONG) # Python 3.10
check_type_size("long double" SIZEOF_LONG_DOUBLE)
set(HAVE_LONG_DOUBLE ${SIZEOF_LONG_DOUBLE}) # libffi and cpython
check_type_size("long long" SIZEOF_LONG_LONG)
Expand All @@ -705,6 +727,7 @@ check_type_size(pid_t SIZEOF_PID_T)
check_type_size(pthread_t SIZEOF_PTHREAD_T)
check_type_size(short SIZEOF_SHORT)
check_type_size(size_t SIZEOF_SIZE_T)
check_type_size(size_t ALIGNOF_SIZE_T) # Python 3.10
check_type_size(ssize_t HAVE_SSIZE_T)
check_type_size(time_t SIZEOF_TIME_T)
check_type_size(uintptr_t SIZEOF_UINTPTR_T)
Expand Down Expand Up @@ -903,6 +926,7 @@ check_symbol_exists(siginterrupt "${CFG_HEADERS}" HAVE_SIGINTERRUPT)
check_symbol_exists(sigrelse "${CFG_HEADERS}" HAVE_SIGRELSE)
check_symbol_exists(snprintf "${CFG_HEADERS}" HAVE_SNPRINTF)
check_symbol_exists(socketpair "${CFG_HEADERS}" HAVE_SOCKETPAIR)
check_symbol_exists(splice "${CFG_HEADERS}" HAVE_SPLICE) # Python 3.10
check_symbol_exists(statvfs "${CFG_HEADERS}" HAVE_STATVFS)
check_symbol_exists(strdup "${CFG_HEADERS}" HAVE_STRDUP)
check_symbol_exists(strftime "${CFG_HEADERS}" HAVE_STRFTIME)
Expand All @@ -927,11 +951,13 @@ check_symbol_exists(wcscoll "${CFG_HEADERS}" HAVE_WCSCOLL)
check_symbol_exists(_getpty "${CFG_HEADERS}" HAVE__GETPTY)

check_symbol_exists(accept4 "${CFG_HEADERS}" HAVE_ACCEPT4)
check_symbol_exists(close_range "${CFG_HEADERS}" HAVE_CLOSE_RANGE) # Python 3.10
check_symbol_exists(copy_file_range "${CFG_HEADERS}" HAVE_COPY_FILE_RANGE)
check_symbol_exists(dup3 "${CFG_HEADERS}" HAVE_DUP3)
check_symbol_exists(_dyld_shared_cache_contains_path "${CFG_HEADERS}" HAVE_DYLD_SHARED_CACHE_CONTAINS_PATH)
check_symbol_exists(explicit_bzero "${CFG_HEADERS}" HAVE_EXPLICIT_BZERO)
check_symbol_exists(explicit_memset "${CFG_HEADERS}" HAVE_EXPLICIT_MEMSET)
check_symbol_exists(eventfd "${CFG_HEADERS}" HAVE_EVENTFD) # Python 3.10
check_symbol_exists(faccessat "${CFG_HEADERS}" HAVE_FACCESSAT)
check_symbol_exists(fchmodat "${CFG_HEADERS}" HAVE_FCHMODAT)
check_symbol_exists(fchownat "${CFG_HEADERS}" HAVE_FCHOWNAT)
Expand Down Expand Up @@ -1004,6 +1030,7 @@ check_symbol_exists(symlinkat "${CFG_HEADERS}" HAVE_SYMLINKAT)
check_symbol_exists(sync "${CFG_HEADERS}" HAVE_SYNC)
check_symbol_exists(unlinkat "${CFG_HEADERS}" HAVE_UNLINKAT)
check_symbol_exists(utimensat "${CFG_HEADERS}" HAVE_UTIMENSAT)
check_symbol_exists(vfork "${CFG_HEADERS}" HAVE_VFORK) # Python 3.10
check_symbol_exists(waitid "${CFG_HEADERS}" HAVE_WAITID)
check_symbol_exists(wcsftime "${CFG_HEADERS}" HAVE_WCSFTIME)
check_symbol_exists(wcsxfrm "${CFG_HEADERS}" HAVE_WCSXFRM)
Expand Down Expand Up @@ -1989,7 +2016,11 @@ if(HAVE_READLINE_READLINE_H)
cmake_push_check_state()
set(CFG_HEADERS_SAVE ${CFG_HEADERS})

add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H readline/readline.h)
if(USE_LIBEDIT)
add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H "editline/readline.h")
else()
add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H "readline/readline.h")
endif()
add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBREADLINE ${HAVE_LIBREADLINE})
check_symbol_exists(rl_callback_handler_install "${CFG_HEADERS}" HAVE_RL_CALLBACK)
check_symbol_exists(rl_catch_signals "${CFG_HEADERS}" HAVE_RL_CATCH_SIGNAL)
Expand Down
3 changes: 3 additions & 0 deletions cmake/config-mingw/pyconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 8
# define SIZEOF_SIZE_T 8
# define ALIGNOF_SIZE_T 8
/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG,
sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t).
On Win64 the second condition is not true, but if fpos_t replaces off_t
Expand All @@ -200,6 +201,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 4
# define SIZEOF_SIZE_T 4
# define ALIGNOF_SIZE_T 4
# define SIZEOF_TIME_T 8
#endif

Expand All @@ -213,6 +215,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define ALIGNOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_DOUBLE 8
#define SIZEOF_FLOAT 4
Expand Down
Loading