Skip to content

Commit

Permalink
Python 3.11 (#1)
Browse files Browse the repository at this point in the history
* Add support for Python 3.10

Based on python-cmake-buildsystem/python-cmake-buildsystem#345

* Add limited Python 3.11 support

* add 3.11.7

* test 3.11

* modify sources for 3.11

* fix cache.c

* install new tcl-tk

* newer macos

* skip tkinter on macos

* fix condition

* allow verbose CI builds

* back to macos-latest

* syntax

* control tkinter outside

* tweak gha expression

* add verbose make

* adjust ndbm detection

* add HAVE_NETDB_H

* use c11

* update indentation

* freeze getpath

* change getpath.h path

* remove unmatched condition

* make cmake_debug_postfix optional

* skip tk in ci

* set python3 exe

* Revert "remove unmatched condition"

This reverts commit 06dfd6a.

* add missing endif

* restore missing freeze command invocation

* build getpath for 3.11

* Revert "build getpath for 3.11"

This reverts commit 58100e1.

* use proper getpath

* Revert "use proper getpath"

This reverts commit 2e054df.

* add back 3.11 test

* Revert "Revert "use proper getpath""

This reverts commit 226a146.

* set expected c standard

* should autodetect c standard

* Revert "Revert "Revert "use proper getpath"""

This reverts commit 5967772.

* add dl_nt.c to _freeze_importlib for windows

* add config.c to _freeze_importlib win32

* set fail-fast

* search for system python3 automatically

* add PYTHONPATH to getpath.c

* Revert "add config.c to _freeze_importlib win32"

This reverts commit 51aadd8.

* Revert "add dl_nt.c to _freeze_importlib for windows"

This reverts commit 31e1c2b.

* PYTHONPATH fixes

* roll forward patches

* explicitly add lib directory to PYTHONPATH

* add MS_DLL_ID and patch config_minimal on PC

* fix VPATH

* explicitly point PYTHONPATH to stdlib

* add default abiflags

* add check for pipe syscall

* fix missing macro in _msi.c

* add check for umask syscall

* add missing syscall checks

* update PYTHONPATH for windows

* use proper delimiter

* escape semicolon

* Drop list for now

* add getsockname

* add more missing syscalls

* add test patch

* test

* test

* test

* check for socket func

* add HAVE_ACCEPT

* remove test patch

* print value for NDBM_USE

* add missing stub function to getpath_noop

* run tests with verbose

* add chmod

* add gethostbyaddr

* refactor sqlite3 sources

* fix extension list

* install certifi in test

* add test timeout

---------

Co-authored-by: Minmin Gong <[email protected]>
  • Loading branch information
bjia56 and gongminmin authored Mar 13, 2024
1 parent c9c4318 commit df01f03
Show file tree
Hide file tree
Showing 15 changed files with 819 additions and 123 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ on:
required: false
type: boolean

env:
MACOSX_DEPLOYMENT_TARGET: 10.5

jobs:
tests:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
fail-fast: true
matrix:
runs-on: [macos-latest]
python-version: [3.8.18, 3.9.18, 3.10.13]
python-version: [3.8.18, 3.9.18, 3.10.13, 3.11.7]

name: python-${{ matrix.python-version }}-${{ matrix.runs-on }}
steps:
Expand All @@ -40,17 +43,19 @@ jobs:
cmake \
${{ inputs.verbose && '--trace-expand --debug-find' || '' }} \
-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/python-install \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \
-DCMAKE_C_STANDARD=99 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.MACOSX_DEPLOYMENT_TARGET }} \
${{ startsWith(matrix.python-version, '3.11') && '-DUSE_SYSTEM_TCL=OFF' || '' }} \
-DPYTHON_VERSION=${{ matrix.python-version }} \
..
make -j4
make -j4 ${{ inputs.verbose && 'VERBOSE=1' || '' }}
make install
- name: Check sysconfig
run: |
./python-install/bin/python -m sysconfig
- name: Test
run: |
./python-install/bin/python -m test || true
./python-install/bin/python -m ensurepip || true
./python-install/bin/python -m pip install certifi || true
./python-install/bin/python -m test -v --timeout 60 || true
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ 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")
# 3.11.x
set(_download_3.11.7_md5 "ef61f81ec82c490484219c7f0ec96783")

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

Expand Down Expand Up @@ -379,6 +381,13 @@ if(WIN32 AND IS_PY3)
enable_language(CXX)
endif()

if(PY_VERSION VERSION_GREATER_EQUAL "3.11")
set(CMAKE_C_STANDARD "11")
find_package(Python3 COMPONENTS Interpreter)
else()
set(CMAKE_C_STANDARD "99")
endif()

# Options depending of the python version
if(IS_PY2)
cmake_dependent_option(USE_SYSTEM_DB "Use system DB" ON "USE_SYSTEM_LIBRARIES" OFF)
Expand Down
24 changes: 24 additions & 0 deletions cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ if(USE_SYSTEM_GDBM)

if(NDBM_INCLUDE_PATH)
set(NDBM_TAG NDBM)
set(NDBM_USE NDBM)
else()
set(NDBM_USE GDBM_COMPAT)
find_path(GDBM_NDBM_INCLUDE_PATH gdbm/ndbm.h)
if(GDBM_NDBM_INCLUDE_PATH)
set(NDBM_TAG GDBM_NDBM)
Expand All @@ -112,6 +114,7 @@ message(STATUS "GDBM_INCLUDE_PATH=${GDBM_INCLUDE_PATH}")
message(STATUS "GDBM_LIBRARY=${GDBM_LIBRARY}")
message(STATUS "GDBM_COMPAT_LIBRARY=${GDBM_COMPAT_LIBRARY}")
message(STATUS "NDBM_TAG=${NDBM_TAG}")
message(STATUS "NDBM_USE=${NDBM_USE}")
message(STATUS "<NDBM_TAG>_INCLUDE_PATH=${${NDBM_TAG}_INCLUDE_PATH}")

find_path(LZMA_INCLUDE_PATH lzma.h)
Expand Down Expand Up @@ -812,12 +815,15 @@ set(CFG_HEADERS ${CFG_HEADERS} time.h stdio.h math.h)
check_symbol_exists(alarm "${CFG_HEADERS}" HAVE_ALARM)
check_symbol_exists(alloca "${CFG_HEADERS}" HAVE_ALLOCA) # libffi and cpython
check_symbol_exists(altzone "${CFG_HEADERS}" HAVE_ALTZONE)
check_symbol_exists(bind "${CFG_HEADERS}" HAVE_BIND)
check_symbol_exists(bind_textdomain_codeset "${CFG_HEADERS}" HAVE_BIND_TEXTDOMAIN_CODESET)
check_symbol_exists(chflags "${CFG_HEADERS}" HAVE_CHFLAGS)
check_symbol_exists(chmod "${CFG_HEADERS}" HAVE_CHMOD)
check_symbol_exists(chown "${CFG_HEADERS}" HAVE_CHOWN)
check_symbol_exists(chroot "${CFG_HEADERS}" HAVE_CHROOT)
check_symbol_exists(clock "${CFG_HEADERS}" HAVE_CLOCK)
check_symbol_exists(confstr "${CFG_HEADERS}" HAVE_CONFSTR)
check_symbol_exists(connect "${CFG_HEADERS}" HAVE_CONNECT)
check_symbol_exists(ctermid "${CFG_HEADERS}" HAVE_CTERMID)
check_symbol_exists(ctermid_r "${CFG_HEADERS}" HAVE_CTERMID_R)
check_symbol_exists(dup2 "${CFG_HEADERS}" HAVE_DUP2)
Expand Down Expand Up @@ -858,6 +864,7 @@ if(IS_PY2)
check_symbol_exists(getcwd "${CFG_HEADERS}" HAVE_GETCWD)
endif()
check_symbol_exists(getc_unlocked "${CFG_HEADERS}" HAVE_GETC_UNLOCKED)
check_symbol_exists(getgid "${CFG_HEADERS}" HAVE_GETGID)
check_symbol_exists(getgroups "${CFG_HEADERS}" HAVE_GETGROUPS)
check_symbol_exists(getitimer "${CFG_HEADERS}" HAVE_GETITIMER)
check_symbol_exists(getloadavg "${CFG_HEADERS}" HAVE_GETLOADAVG)
Expand All @@ -866,14 +873,17 @@ check_symbol_exists(getpagesize "${CFG_HEADERS}" HAVE_GETPAGESIZE)
check_symbol_exists(getpgid "${CFG_HEADERS}" HAVE_GETPGID)
check_symbol_exists(getpgrp "${CFG_HEADERS}" HAVE_GETPGRP)
check_symbol_exists(getpid "${CFG_HEADERS}" HAVE_GETPID)
check_symbol_exists(getppid "${CFG_HEADERS}" HAVE_GETPPID)
python_check_function(getpriority HAVE_GETPRIORITY)
check_symbol_exists(getpwent "${CFG_HEADERS}" HAVE_GETPWENT)
check_symbol_exists(getresgid "${CFG_HEADERS}" HAVE_GETRESGID)
check_symbol_exists(getresuid "${CFG_HEADERS}" HAVE_GETRESUID)
check_symbol_exists(getsid "${CFG_HEADERS}" HAVE_GETSID)
check_symbol_exists(getsockname "${CFG_HEADERS}" HAVE_GETSOCKNAME)
check_symbol_exists(getspent "${CFG_HEADERS}" HAVE_GETSPENT)
check_symbol_exists(getspnam "${CFG_HEADERS}" HAVE_GETSPNAM)
check_symbol_exists(gettimeofday "${CFG_HEADERS}" HAVE_GETTIMEOFDAY)
check_symbol_exists(getuid "${CFG_HEADERS}" HAVE_GETUID)
check_symbol_exists(getwd "${CFG_HEADERS}" HAVE_GETWD)
check_symbol_exists(hypot "${CFG_HEADERS}" HAVE_HYPOT)
check_symbol_exists(initgroups "${CFG_HEADERS}" HAVE_INITGROUPS)
Expand All @@ -884,6 +894,7 @@ check_symbol_exists(lchflags "${CFG_HEADERS}" HAVE_LCHFLAGS)
python_check_function(lchmod HAVE_LCHMOD)
check_symbol_exists(lchown "${CFG_HEADERS}" HAVE_LCHOWN)
check_symbol_exists(link "${CFG_HEADERS}" HAVE_LINK)
check_symbol_exists(listen "${CFG_HEADERS}" HAVE_LISTEN)
check_symbol_exists(lstat "${CFG_HEADERS}" HAVE_LSTAT)
check_symbol_exists(makedev "${CFG_HEADERS}" HAVE_MAKEDEV)
check_symbol_exists(memcpy "${CFG_HEADERS}" HAVE_MEMCPY) # libffi and cpython
Expand All @@ -894,6 +905,7 @@ check_symbol_exists(mktime "${CFG_HEADERS}" HAVE_MKTIME)
check_symbol_exists(mmap "${CFG_HEADERS}" HAVE_MMAP) # libffi and cpython
check_symbol_exists(mremap "${CFG_HEADERS}" HAVE_MREMAP)
check_symbol_exists(nice "${CFG_HEADERS}" HAVE_NICE)
check_symbol_exists(opendir "${CFG_HEADERS}" HAVE_OPENDIR)
check_symbol_exists(openpty "${CFG_HEADERS}" HAVE_OPENPTY)
check_symbol_exists(pathconf "${CFG_HEADERS}" HAVE_PATHCONF)
check_symbol_exists(pause "${CFG_HEADERS}" HAVE_PAUSE)
Expand All @@ -902,7 +914,9 @@ check_symbol_exists(poll "${CFG_HEADERS}" HAVE_POLL)
check_symbol_exists(putenv "${CFG_HEADERS}" HAVE_PUTENV)
check_symbol_exists(readlink "${CFG_HEADERS}" HAVE_READLINK)
check_symbol_exists(realpath "${CFG_HEADERS}" HAVE_REALPATH)
check_symbol_exists(recvfrom "${CFG_HEADERS}" HAVE_RECVFROM)
check_symbol_exists(select "${CFG_HEADERS}" HAVE_SELECT)
check_symbol_exists(sendto "${CFG_HEADERS}" HAVE_SENDTO)
check_symbol_exists(setegid "${CFG_HEADERS}" HAVE_SETEGID)
check_symbol_exists(seteuid "${CFG_HEADERS}" HAVE_SETEUID)
check_symbol_exists(setgid "${CFG_HEADERS}" HAVE_SETGID)
Expand All @@ -916,18 +930,22 @@ check_symbol_exists(setreuid "${CFG_HEADERS}" HAVE_SETREUID)
check_symbol_exists(setresgid "${CFG_HEADERS}" HAVE_SETRESGID)
check_symbol_exists(setresuid "${CFG_HEADERS}" HAVE_SETRESUID)
check_symbol_exists(setsid "${CFG_HEADERS}" HAVE_SETSID)
check_symbol_exists(setsockopt "${CFG_HEADERS}" HAVE_SETSOCKOPT)
check_symbol_exists(setuid "${CFG_HEADERS}" HAVE_SETUID)
check_symbol_exists(setvbuf "${CFG_HEADERS}" HAVE_SETVBUF)
check_symbol_exists(shutdown "${CFG_HEADERS}" HAVE_SHUTDOWN)
check_symbol_exists(sigaction "${CFG_HEADERS}" HAVE_SIGACTION)
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(socket "${CFG_HEADERS}" HAVE_SOCKET)
check_symbol_exists(socketpair "${CFG_HEADERS}" HAVE_SOCKETPAIR)
check_symbol_exists(statvfs "${CFG_HEADERS}" HAVE_STATVFS)
check_symbol_exists(strdup "${CFG_HEADERS}" HAVE_STRDUP)
check_symbol_exists(strftime "${CFG_HEADERS}" HAVE_STRFTIME)
check_symbol_exists(symlink "${CFG_HEADERS}" HAVE_SYMLINK)
check_symbol_exists(sysconf "${CFG_HEADERS}" HAVE_SYSCONF)
check_symbol_exists(system "${CFG_HEADERS}" HAVE_SYSTEM)
check_symbol_exists(tcgetpgrp "${CFG_HEADERS}" HAVE_TCGETPGRP)
check_symbol_exists(tcsetpgrp "${CFG_HEADERS}" HAVE_TCSETPGRP)
check_symbol_exists(tempnam "${CFG_HEADERS}" HAVE_TEMPNAM)
Expand All @@ -937,16 +955,20 @@ check_symbol_exists(tmpfile "${CFG_HEADERS}" HAVE_TMPFILE)
check_symbol_exists(tmpnam "${CFG_HEADERS}" HAVE_TMPNAM)
check_symbol_exists(tmpnam_r "${CFG_HEADERS}" HAVE_TMPNAM_R)
check_symbol_exists(truncate "${CFG_HEADERS}" HAVE_TRUNCATE)
check_symbol_exists(ttyname "${CFG_HEADERS}" HAVE_TTYNAME)
check_symbol_exists(umask "${CFG_HEADERS}" HAVE_UMASK)
check_symbol_exists(uname "${CFG_HEADERS}" HAVE_UNAME)
check_symbol_exists(unsetenv "${CFG_HEADERS}" HAVE_UNSETENV)
check_symbol_exists(utimes "${CFG_HEADERS}" HAVE_UTIMES)
check_symbol_exists(wait "${CFG_HEADERS}" HAVE_WAIT)
check_symbol_exists(wait3 "${CFG_HEADERS}" HAVE_WAIT3)
check_symbol_exists(wait4 "${CFG_HEADERS}" HAVE_WAIT4)
check_symbol_exists(waitpid "${CFG_HEADERS}" HAVE_WAITPID)
check_symbol_exists(wcscoll "${CFG_HEADERS}" HAVE_WCSCOLL)
check_symbol_exists(_getpty "${CFG_HEADERS}" HAVE__GETPTY)

if(IS_PY3)
check_symbol_exists(accept "${CFG_HEADERS}" HAVE_ACCEPT)
check_symbol_exists(accept4 "${CFG_HEADERS}" HAVE_ACCEPT4)
check_symbol_exists(copy_file_range "${CFG_HEADERS}" HAVE_COPY_FILE_RANGE)
check_symbol_exists(dup3 "${CFG_HEADERS}" HAVE_DUP3)
Expand Down Expand Up @@ -983,6 +1005,7 @@ check_symbol_exists(mkdirat "${CFG_HEADERS}" HAVE_MKDIRAT)
check_symbol_exists(mkfifoat "${CFG_HEADERS}" HAVE_MKFIFOAT)
check_symbol_exists(mknodat "${CFG_HEADERS}" HAVE_MKNODAT)
check_symbol_exists(openat "${CFG_HEADERS}" HAVE_OPENAT)
check_symbol_exists(pipe "${CFG_HEADERS}" HAVE_PIPE)
check_symbol_exists(pipe2 "${CFG_HEADERS}" HAVE_PIPE2)
check_symbol_exists(posix_fadvise "${CFG_HEADERS}" HAVE_POSIX_FADVISE)
check_symbol_exists(posix_fallocate "${CFG_HEADERS}" HAVE_POSIX_FALLOCATE)
Expand Down Expand Up @@ -1882,6 +1905,7 @@ endif()
check_symbol_exists(gai_strerror "${CFG_HEADERS}" HAVE_GAI_STRERROR)
check_symbol_exists(getaddrinfo "${CFG_HEADERS}" HAVE_GETADDRINFO)
check_symbol_exists(getnameinfo "${CFG_HEADERS}" HAVE_GETNAMEINFO)
check_symbol_exists(gethostbyaddr "${CFG_HEADERS}" HAVE_GETHOSTBYADDR)
check_symbol_exists(getpeername "${CFG_HEADERS}" HAVE_GETPEERNAME)
check_symbol_exists(hstrerror "${CFG_HEADERS}" HAVE_HSTRERROR)
check_symbol_exists(inet_aton "${CFG_HEADERS}" HAVE_INET_ATON)
Expand Down
8 changes: 5 additions & 3 deletions cmake/config-mingw/pyconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ WIN32 is still required for the locale module.
#define HAVE_SSIZE_T 1

#include <float.h>
#define Py_IS_NAN _isnan
#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
#define Py_IS_FINITE(X) _finite(X)
#if PY_VERSION_HEX < 0x030B0000
# define Py_IS_NAN _isnan
# define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
# define Py_IS_FINITE(X) _finite(X)
#endif
#define copysign _copysign

#include <basetsd.h>
Expand Down
Loading

0 comments on commit df01f03

Please sign in to comment.