Skip to content

Commit e9a66c0

Browse files
committed
Merge remote-tracking branch 'bjia56/python3.11' into freeorion-patches-android-5
2 parents 573fe8a + 226a146 commit e9a66c0

13 files changed

Lines changed: 587 additions & 162 deletions

File tree

.github/workflows/CI.yml

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@ on:
44
pull_request:
55
push:
66
branches:
7-
- master
7+
- portable-python
8+
workflow_dispatch:
9+
inputs:
10+
verbose:
11+
required: false
12+
type: boolean
13+
14+
env:
15+
MACOSX_DEPLOYMENT_TARGET: 10.5
816

917
jobs:
1018
tests:
@@ -13,49 +21,33 @@ jobs:
1321
fail-fast: false
1422
matrix:
1523
runs-on: [macos-latest]
16-
python-version: [3.7.17, 3.8.17, 3.9.17]
17-
include:
18-
- runs-on: macos-latest
19-
c-compiler: "clang"
20-
cxx-compiler: "clang++"
21-
initial-dashboard-cache: "CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.13"
24+
python-version: [3.8.18, 3.9.18, 3.10.13, 3.11.7]
2225

2326
name: python-${{ matrix.python-version }}-${{ matrix.runs-on }}
2427
steps:
2528
- uses: actions/checkout@v3
26-
with:
27-
fetch-depth: 0
28-
path: src
2929

3030
- name: Setup cmake
3131
uses: jwlawson/actions-setup-cmake@v1.13.1
3232
with:
3333
cmake-version: 3.13.5
3434

35-
- name: Setup ninja
36-
uses: ashutoshvarma/setup-ninja@master
37-
with:
38-
version: 1.10.0
39-
40-
- name: Download dashboard script
41-
uses: actions/checkout@v3
42-
with:
43-
repository: 'python-cmake-buildsystem/python-cmake-buildsystem'
44-
ref: dashboard
45-
fetch-depth: 0
46-
path: scripts
47-
48-
- name: Writing initial dashboard cache
49-
shell: bash
35+
- name: Build
5036
run: |
51-
cat > scripts/initial-dashboard-cache.txt << EOF
52-
${{ matrix.initial-dashboard-cache }}
53-
EOF
54-
cat scripts/initial-dashboard-cache.txt
55-
56-
- name: Build & Test
57-
run: ctest --timeout 360 -S scripts/github_actions_dashboard.cmake -VV
58-
env:
59-
PY_VERSION: ${{ matrix.python-version }}
60-
CC: ${{ matrix.c-compiler }}
61-
CXX: ${{ matrix.cxx-compiler }}
37+
mkdir -p python-build && mkdir -p python-install
38+
cd python-build
39+
cmake \
40+
${{ inputs.verbose && '--trace-expand --debug-find' || '' }} \
41+
-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/python-install \
42+
-DCMAKE_OSX_DEPLOYMENT_TARGET=${{ env.MACOSX_DEPLOYMENT_TARGET }} \
43+
-DCMAKE_C_STANDARD=11 \
44+
-DPython3_EXECUTABLE=$(which python3) \
45+
${{ startsWith(matrix.python-version, '3.11') && '-DUSE_SYSTEM_TCL=OFF' || '' }} \
46+
-DPYTHON_VERSION=${{ matrix.python-version }} \
47+
..
48+
make -j4 ${{ inputs.verbose && 'VERBOSE=1' || '' }}
49+
make install
50+
51+
- name: Test
52+
run: |
53+
./python-install/bin/python -m test || true

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ endif()
138138

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

141-
cmake_dependent_option(USE_LIBEDIT "Use libedit instead of readline" OFF
142-
"USE_SYSTEM_READLINE" OFF)
141+
option(USE_LIBEDIT "Use libedit instead of readline" OFF)
143142

144143
option(WITH_TSC "profile with the Pentium timestamp counter" OFF)
145144
option(ENABLE_IPV6 "Enable IP v6" ON)
@@ -272,6 +271,7 @@ set(_download_3.8.14_md5 "a82168eb586e19122b747b84038825f2")
272271
set(_download_3.8.15_md5 "28b111e1e97a9e5acb62e1d153f188d9")
273272
set(_download_3.8.16_md5 "060040f864f1003b849b33393c9605df")
274273
set(_download_3.8.17_md5 "d3e789ab828016927a122a0ae9b0e6b0")
274+
set(_download_3.8.18_md5 "1c611d70ba4d0ec32da3a364490fc6f4")
275275
# 3.9.x
276276
set(_download_3.9.0_md5 "e19e75ec81dd04de27797bf3f9d918fd")
277277
set(_download_3.9.1_md5 "429ae95d24227f8fa1560684fad6fca7")
@@ -291,6 +291,7 @@ set(_download_3.9.14_md5 "324a9dcaaa11b2b0dafe5614e8f01145")
291291
set(_download_3.9.15_md5 "3e13283a5f4e089db508bf81b60a5cca")
292292
set(_download_3.9.16_md5 "38c99c7313f416dcf3238f5cf444c6c2")
293293
set(_download_3.9.17_md5 "ded6379983f364cf790793ca24dcfe3e")
294+
set(_download_3.9.18_md5 "c3a3e67e35838cadca247237a5a279a7")
294295
# 3.10.x
295296
set(_download_3.10.0_md5 "729e36388ae9a832b01cf9138921b383")
296297
set(_download_3.10.1_md5 "91822157a97da16203877400c810d93e")
@@ -306,6 +307,8 @@ set(_download_3.10.10_md5 "6dbe644dd1a520d9853cf6648084c346")
306307
set(_download_3.10.11_md5 "7e25e2f158b1259e271a45a249cb24bb")
307308
set(_download_3.10.12_md5 "1d64320e0b0df6e9ab7e611bacb2178d")
308309
set(_download_3.10.13_md5 "cbcad7f5e759176bf8ce8a5f9d487087")
310+
# 3.11.x
311+
set(_download_3.11.7_md5 "ef61f81ec82c490484219c7f0ec96783")
309312

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

CTestConfig.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
set(CTEST_PROJECT_NAME "Python")
2-
set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
31

4-
set(CTEST_DROP_METHOD "http")
5-
set(CTEST_DROP_SITE "open.cdash.org")
6-
set(CTEST_DROP_LOCATION "/submit.php?project=CPython")
7-
set(CTEST_DROP_SITE_CDASH TRUE)
8-
set(CTEST_TEST_TIMEOUT "60")

cmake/ConfigureChecks.cmake

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ if(USE_SYSTEM_GDBM)
9696

9797
if(NDBM_INCLUDE_PATH)
9898
set(NDBM_TAG NDBM)
99+
set(NDBM_USE NDBM)
99100
else()
101+
set(NDBM_USE GDBM_COMPAT)
100102
find_path(GDBM_NDBM_INCLUDE_PATH gdbm/ndbm.h)
101103
if(GDBM_NDBM_INCLUDE_PATH)
102104
set(NDBM_TAG GDBM_NDBM)
@@ -326,7 +328,11 @@ check_include_files(process.h HAVE_PROCESS_H)
326328
check_include_files(pthread.h HAVE_PTHREAD_H)
327329
check_include_files(pty.h HAVE_PTY_H)
328330
check_include_files(pwd.h HAVE_PWD_H)
329-
check_include_files("stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H)
331+
if(USE_LIBEDIT)
332+
check_include_files("stdio.h;editline/readline.h" HAVE_READLINE_READLINE_H)
333+
else()
334+
check_include_files("stdio.h;readline/readline.h" HAVE_READLINE_READLINE_H)
335+
endif()
330336
check_include_files(semaphore.h HAVE_SEMAPHORE_H)
331337
check_include_files(shadow.h HAVE_SHADOW_H)
332338
check_include_files(signal.h HAVE_SIGNAL_H)
@@ -431,6 +437,11 @@ endif()
431437
find_library(HAVE_LIBNCURSES ncurses)
432438
find_library(HAVE_LIBNSL nsl)
433439
find_library(HAVE_LIBREADLINE readline)
440+
if(USE_LIBEDIT)
441+
find_library(HAVE_LIBREADLINE edit)
442+
else()
443+
find_library(HAVE_LIBREADLINE readline)
444+
endif()
434445
if(IS_PY3)
435446
find_library(HAVE_LIBSENDFILE sendfile)
436447
endif()
@@ -1791,7 +1802,8 @@ if(HAVE_GETHOSTBYNAME_R)
17911802

17921803
# Checking gethostbyname_r with 6 args
17931804
set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/have_gethostbyname_r_6_arg.c)
1794-
file(WRITE ${check_src} "int main() {
1805+
file(WRITE ${check_src} "#include <netdb.h>
1806+
int main() {
17951807
char *name;
17961808
struct hostent *he, *res;
17971809
char buffer[2048];
@@ -2032,7 +2044,11 @@ if(HAVE_READLINE_READLINE_H)
20322044
cmake_push_check_state()
20332045
set(CFG_HEADERS_SAVE ${CFG_HEADERS})
20342046

2035-
add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H readline/readline.h)
2047+
if(USE_LIBEDIT)
2048+
add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H editline/readline.h)
2049+
else()
2050+
add_cond(CFG_HEADERS HAVE_READLINE_READLINE_H readline/readline.h)
2051+
endif()
20362052
add_cond(CMAKE_REQUIRED_LIBRARIES HAVE_LIBREADLINE ${HAVE_LIBREADLINE})
20372053
check_symbol_exists(rl_callback_handler_install "${CFG_HEADERS}" HAVE_RL_CALLBACK)
20382054
check_symbol_exists(rl_catch_signals "${CFG_HEADERS}" HAVE_RL_CATCH_SIGNAL)

cmake/config-mingw/pyconfig.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,11 @@ WIN32 is still required for the locale module.
121121
#define HAVE_SSIZE_T 1
122122

123123
#include <float.h>
124-
#define Py_IS_NAN _isnan
125-
#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
126-
#define Py_IS_FINITE(X) _finite(X)
124+
#if PY_VERSION_HEX < 0x030B0000
125+
# define Py_IS_NAN _isnan
126+
# define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
127+
# define Py_IS_FINITE(X) _finite(X)
128+
#endif
127129
#define copysign _copysign
128130

129131
#include <basetsd.h>

cmake/config-unix/pyconfig.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,9 @@
762762
/* Define to 1 if you have the <ncurses.h> header file. */
763763
#cmakedefine HAVE_NCURSES_H 1
764764

765+
/* Define to 1 if you have the <netdb.h> header file. */
766+
#cmakedefine HAVE_NETDB_H 1
767+
765768
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
766769
#cmakedefine HAVE_NDIR_H 1
767770

@@ -1555,6 +1558,7 @@
15551558

15561559
/* The size of `long', as computed by sizeof. */
15571560
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
1561+
/* The size of `long', as computed by alignof. */
15581562
#cmakedefine ALIGNOF_LONG @SIZEOF_LONG@
15591563

15601564
/* The size of `long double', as computed by sizeof. */
@@ -1580,6 +1584,9 @@
15801584

15811585
/* The size of `size_t', as computed by sizeof. */
15821586
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
1587+
1588+
1589+
/* The size of `size_t', as computed by alignof. */
15831590
#cmakedefine ALIGNOF_SIZE_T @SIZEOF_SIZE_T@
15841591

15851592
/* The size of `time_t', as computed by sizeof. */

cmake/extensions/CMakeLists.txt

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ endif()
1313
add_python_extension(array ${WIN32_BUILTIN} SOURCES arraymodule.c)
1414
add_python_extension(audioop ${WIN32_BUILTIN} REQUIRES HAVE_LIBM SOURCES audioop.c LIBRARIES ${M_LIBRARIES})
1515
add_python_extension(_bisect ${WIN32_BUILTIN} SOURCES _bisectmodule.c)
16-
add_python_extension(cmath REQUIRES HAVE_LIBM ${WIN32_BUILTIN} SOURCES _math.c cmathmodule.c LIBRARIES ${M_LIBRARIES})
16+
add_python_extension(cmath REQUIRES HAVE_LIBM ${WIN32_BUILTIN} SOURCES $<$<VERSION_LESS:${PY_VERSION},3.11>:_math.c> cmathmodule.c LIBRARIES ${M_LIBRARIES})
1717
add_python_extension(_codecs_cn ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_cn.c)
1818
add_python_extension(_codecs_hk ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_hk.c)
1919
add_python_extension(_codecs_iso2022 ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_iso2022.c)
@@ -68,7 +68,7 @@ add_python_extension(itertools ${WIN32_BUILTIN} ${PY3_BUILTIN} SOURCES itertools
6868
add_python_extension(_json ${WIN32_BUILTIN} SOURCES _json.c)
6969
add_python_extension(_locale ${WIN32_BUILTIN} ${PY3_BUILTIN} SOURCES _localemodule.c) # access to ISO C locale support
7070
add_python_extension(_lsprof ${WIN32_BUILTIN} SOURCES _lsprof.c rotatingtree.c)
71-
add_python_extension(math ${WIN32_BUILTIN} REQUIRES HAVE_LIBM SOURCES _math.c mathmodule.c LIBRARIES ${M_LIBRARIES})
71+
add_python_extension(math ${WIN32_BUILTIN} REQUIRES HAVE_LIBM SOURCES $<$<VERSION_LESS:${PY_VERSION},3.11>:_math.c> mathmodule.c LIBRARIES ${M_LIBRARIES})
7272
add_python_extension(mmap ${WIN32_BUILTIN} SOURCES mmapmodule.c)
7373
add_python_extension(_multibytecodec ${WIN32_BUILTIN} SOURCES cjkcodecs/multibytecodec.c)
7474
add_python_extension(operator ${WIN32_BUILTIN} REQUIRES IS_PY2 SOURCES operator.c)
@@ -102,7 +102,11 @@ add_python_extension(faulthandler ALWAYS_BUILTIN REQUIRES IS_PY3 SOURCES faultha
102102
add_python_extension(_opcode ${WIN32_BUILTIN} REQUIRES IS_PY3 SOURCES _opcode.c)
103103
add_python_extension(_operator BUILTIN REQUIRES IS_PY3 SOURCES _operator.c)
104104
add_python_extension(_pickle ${WIN32_BUILTIN} REQUIRES IS_PY3 SOURCES _pickle.c)
105-
add_python_extension(_sre BUILTIN SOURCES _sre.c) # Fredrik Lundh's new regular expressions
105+
if(PY_VERSION VERSION_LESS "3.11")
106+
add_python_extension(_sre BUILTIN SOURCES _sre.c) # Fredrik Lundh's new regular expressions
107+
else()
108+
add_python_extension(_sre BUILTIN SOURCES _sre/sre.c) # Fredrik Lundh's new regular expressions
109+
endif()
106110
add_python_extension(_stat BUILTIN REQUIRES IS_PY3 SOURCES _stat.c) # stat.h interface
107111
add_python_extension(_symtable BUILTIN SOURCES symtablemodule.c)
108112
# Python PEP-3118 (buffer protocol) test module
@@ -711,7 +715,7 @@ endif()
711715
add_python_extension(${dbm_name}
712716
REQUIRES NDBM_TAG GDBM_LIBRARY GDBM_COMPAT_LIBRARY
713717
SOURCES ${dbm${PY_VERSION_MAJOR}_SOURCES}
714-
DEFINITIONS HAVE_${NDBM_TAG}_H
718+
DEFINITIONS HAVE_${NDBM_TAG}_H USE_${NDBM_USE}
715719
LIBRARIES ${GDBM_LIBRARY} ${GDBM_COMPAT_LIBRARY}
716720
INCLUDEDIRS ${${NDBM_TAG}_INCLUDE_PATH}
717721
)
@@ -758,7 +762,8 @@ add_python_extension(readline
758762
)
759763
add_python_extension(_sqlite3
760764
REQUIRES SQLite3_INCLUDE_DIRS SQLite3_LIBRARIES
761-
SOURCES _sqlite/cache.c
765+
SOURCES $<$<VERSION_LESS:${PY_VERSION},3.11>:_sqlite/cache.c>
766+
$<$<VERSION_GREATER_EQUAL:${PY_VERSION},3.11>:_sqlite/blob.c>
762767
_sqlite/connection.c
763768
_sqlite/cursor.c
764769
_sqlite/microprotocols.c
@@ -792,9 +797,9 @@ set(_tkinter_REQUIRES TCL_LIBRARY TK_LIBRARY TCL_INCLUDE_PATH TK_INCLUDE_PATH)
792797
set(_tkinter_LIBRARIES ${TCL_LIBRARY} ${TK_LIBRARY})
793798
set(_tkinter_INCLUDEDIRS ${TCL_INCLUDE_PATH} ${TK_INCLUDE_PATH})
794799
if(UNIX)
795-
list(APPEND _tkinter_REQUIRES X11_INCLUDE_DIR X11_LIBRARIES)
796-
list(APPEND _tkinter_LIBRARIES ${X11_LIBRARIES})
797-
list(APPEND _tkinter_INCLUDEDIRS ${X11_INCLUDE_DIR})
800+
list(APPEND _tkinter_REQUIRES X11_INCLUDE_DIR X11_LIBRARIES)
801+
list(APPEND _tkinter_LIBRARIES ${X11_LIBRARIES})
802+
list(APPEND _tkinter_INCLUDEDIRS ${X11_INCLUDE_DIR})
798803
endif()
799804
add_python_extension(_tkinter
800805
REQUIRES ${_tkinter_REQUIRES}
@@ -830,7 +835,20 @@ else()
830835
)
831836
endif()
832837

833-
if(USE_LIBEDIT AND ENABLE_READLINE AND NOT BUILTIN_READLINE)
834-
set_target_properties(extension_readline PROPERTIES
835-
COMPILE_DEFINITIONS "USE_LIBEDIT")
838+
if(USE_LIBEDIT AND ENABLE_READLINE)
839+
if(PY_VERSION VERSION_GREATER_EQUAL "3.10")
840+
if(BUILTIN_READLINE)
841+
set_property(GLOBAL APPEND PROPERTY extension_readline_definitions "WITH_EDITLINE")
842+
else()
843+
set_target_properties(extension_readline PROPERTIES
844+
COMPILE_DEFINITIONS "WITH_EDITLINE")
845+
endif()
846+
else()
847+
if(BUILTIN_READLINE)
848+
set_property(GLOBAL APPEND PROPERTY extension_readline_definitions "USE_LIBEDIT")
849+
else()
850+
set_target_properties(extension_readline PROPERTIES
851+
COMPILE_DEFINITIONS "USE_LIBEDIT")
852+
endif()
853+
endif()
836854
endif()

cmake/fficonfig.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154

155155
/* The size of `size_t', as computed by sizeof. */
156156
#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@
157+
158+
/* The size of `size_t', as computed by alignof. */
157159
#define ALIGNOF_SIZE_T @SIZEOF_SIZE_T@
158160

159161
/* If using the C implementation of alloca, define if you know the

0 commit comments

Comments
 (0)