Skip to content

Commit

Permalink
Python 3.13 (#28)
Browse files Browse the repository at this point in the history
* add 3.13.0

* roll forward existing patches

* run_tests.py was removed in 3.13

* update freebsd patch

* _msi.c removed in 3.13

* disable other versions

* roll patches forward

* remove dead batteries modules

* update tokenizer sources

* update _testcapi

* update sources

* detect various ncurses headers

* add missing sources

* free threading

* add missing sources

* add missing sources

* add missing sources

* patch deepfreeze.py to create missing parent dirs

* patch getpath to use relative header

* update portable patches

* remove dead batteries

* update testinternalcapi

* add missing source

* dos2unix

* fix gettimeofday

* use different freeze script

* syntax

* Revert "syntax"

This reverts commit 9c709a9.

* Revert "use different freeze script"

This reverts commit 4f20041.

* dos2unix

* deepfreeze.c is no longer needed? + reindent

* remove unused patch

* copy over windows pyconfig.h.in

* include mimalloc

* remove freebsd errno patch

* Revert "remove freebsd errno patch"

This reverts commit 158aa46.

* update errno patch

* Revert "update errno patch"

This reverts commit c67404c.

* Revert "Revert "remove freebsd errno patch""

This reverts commit 65f4ceb.

* update freebsd errno patch

* update errno patches

* Revert "update errno patches"

This reverts commit aec043a.

* Revert "update freebsd errno patch"

This reverts commit 79134fe.

* Revert "Revert "Revert "remove freebsd errno patch"""

This reverts commit f0a0935.

* override errno hacks
  • Loading branch information
bjia56 authored Dec 14, 2024
1 parent 07e5043 commit b5a60a9
Show file tree
Hide file tree
Showing 19 changed files with 759 additions and 269 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: [3.9.21, 3.10.16, 3.11.11, 3.12.8]
#python-version: [3.9.21, 3.10.16, 3.11.11, 3.12.8, 3.13.0]
python-version: [3.13.0]
os: [ubuntu]
include:
- os: ubuntu
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ if(UNIX)
else()
set(WITH_STATIC_DEPENDENCIES 0)
endif()
if(PY_VERSION VERSION_GREATER_EQUAL "3.13")
option(WITH_FREE_THREADING "Enable experimental free-threaded build and disables the GIL" OFF)
endif()

# Detect source directory
set(_landmark "pyconfig.h.in") # CMake will look for this file.
Expand Down Expand Up @@ -335,6 +338,8 @@ set(_download_3.12.5_md5 "d23d56b51d36a9d51b2b13d30c849d00")
set(_download_3.12.6_md5 "c2f1dd5c8807ee50b778684b7958ee28")
set(_download_3.12.7_md5 "5d0c0e4c6a022a87165a9addcd869109")
set(_download_3.12.8_md5 "304473cf367fa65e450edf4b06b55fcc")
# 3.13.x
set(_download_3.13.0_md5 "c29f37220520ec6075fc37d4c62e178b")

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

Expand Down Expand Up @@ -586,6 +591,14 @@ if(UNIX)
configure_file(cmake/config-unix/pyconfig.h.in
${PYCONFIG_BUILD_DIR}/pyconfig.h)
elseif(WIN32)
if(PY_VERSION VERSION_GREATER_EQUAL "3.13")
file(READ ${SRC_DIR}/PC/pyconfig.h.in PYCONFIG_H_CONTENTS)
if(WITH_FREE_THREADING)
string(REPLACE "/* #define Py_GIL_DISABLED 1 */" "#define Py_GIL_DISABLED 1" PYCONFIG_H_CONTENTS "${PYCONFIG_H_CONTENTS}")
endif()
file(WRITE ${SRC_DIR}/PC/pyconfig.h "${PYCONFIG_H_CONTENTS}")
endif()

set(PYCONFIG_BUILD_DIR ${SRC_DIR}/PC) # In a windows build tree, 'pyconfig.h' is NOT required to
# live along side the python executable.
# See function '_init_posix()' and '_init_non_posix()'
Expand Down
4 changes: 4 additions & 0 deletions cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ endif()
if(WITH_PYMALLOC AND PY_VERSION VERSION_LESS "3.8")
set(ABIFLAGS "${ABIFLAGS}m")
endif()
if(WITH_FREE_THREADING AND PY_VERSION VERSION_GREATER_EQUAL "3.13")
set(ABIFLAGS "${ABIFLAGS}t")
endif()
message(STATUS "${_msg} - ${ABIFLAGS}")

set(_msg "Checking PLATFORM_TRIPLET")
Expand Down Expand Up @@ -326,6 +329,7 @@ check_include_files(memory.h HAVE_MEMORY_H) # libffi and cpython
check_include_files(minix/config.h HAVE_MINIX_CONFIG_H)
check_include_files(ncurses.h HAVE_NCURSES_H)
check_include_files(ncurses/panel.h HAVE_NCURSES_PANEL_H)
check_include_files(ncursesw/panel.h HAVE_NCURSESW_PANEL_H)
check_include_files(netdb.h HAVE_NETDB_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
check_include_files(netpacket/packet.h HAVE_NETPACKET_PACKET_H)
Expand Down
9 changes: 9 additions & 0 deletions cmake/config-unix/pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,15 @@
/* Define to 1 if you have the <ncurses.h> header file. */
#cmakedefine HAVE_NCURSES_H 1

/* Define to 1 if you have the <ncurses/panel.h> header file. */
#cmakedefine HAVE_NCURSES_PANEL_H 1

/* Define to 1 if you have the <ncursesw/panel.h> header file. */
#cmakedefine HAVE_NCURSESW_PANEL_H 1

/* Define to 1 if you have the <panel.h> header file. */
#cmakedefine HAVE_PANEL_H 1

/* Define to 1 if you have the <netdb.h> header file. */
#cmakedefine HAVE_NETDB_H 1

Expand Down
144 changes: 90 additions & 54 deletions cmake/extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ if(Cosmopolitan)
set(NOT_COSMOPOLITAN 0)
endif()

if(WITH_FREE_THREADING)
add_definitions(-DPy_GIL_DISABLED)
endif()

add_python_extension(array ${WIN32_BUILTIN} SOURCES arraymodule.c)
add_python_extension(audioop ${WIN32_BUILTIN} REQUIRES HAVE_LIBM SOURCES audioop.c LIBRARIES ${M_LIBRARIES})
if(PY_VERSION VERSION_LESS "3.13")
add_python_extension(audioop ${WIN32_BUILTIN} REQUIRES HAVE_LIBM SOURCES audioop.c LIBRARIES ${M_LIBRARIES})
endif()
add_python_extension(_bisect ${WIN32_BUILTIN} SOURCES _bisectmodule.c)
add_python_extension(cmath REQUIRES HAVE_LIBM ${WIN32_BUILTIN} SOURCES $<$<VERSION_LESS:${PY_VERSION},3.11>:_math.c> cmathmodule.c LIBRARIES ${M_LIBRARIES})
add_python_extension(_codecs_cn ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_cn.c)
Expand All @@ -27,11 +33,13 @@ add_python_extension(_codecs_kr ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_kr.c)
add_python_extension(_codecs_tw ${WIN32_BUILTIN} SOURCES cjkcodecs/_codecs_tw.c)
add_python_extension(_collections ${WIN32_BUILTIN} ${PY3_BUILTIN} SOURCES _collectionsmodule.c) # Container types
add_python_extension(cPickle ${WIN32_BUILTIN} REQUIRES IS_PY2 SOURCES cPickle.c)
set(crypt2_NAME crypt)
set(crypt2_SOURCES cryptmodule.c)
set(crypt3_NAME _crypt)
set(crypt3_SOURCES _cryptmodule.c)
add_python_extension(${crypt${PY_VERSION_MAJOR}_NAME} REQUIRES HAVE_LIBCRYPT SOURCES ${crypt${PY_VERSION_MAJOR}_SOURCES} LIBRARIES ${HAVE_LIBCRYPT})
if(PY_VERSION VERSION_LESS "3.13")
set(crypt2_NAME crypt)
set(crypt2_SOURCES cryptmodule.c)
set(crypt3_NAME _crypt)
set(crypt3_SOURCES _cryptmodule.c)
add_python_extension(${crypt${PY_VERSION_MAJOR}_NAME} REQUIRES HAVE_LIBCRYPT SOURCES ${crypt${PY_VERSION_MAJOR}_SOURCES} LIBRARIES ${HAVE_LIBCRYPT})
endif()
add_python_extension(cStringIO ${WIN32_BUILTIN} REQUIRES IS_PY2 SOURCES cStringIO.c)
add_python_extension(_csv ${WIN32_BUILTIN} SOURCES _csv.c)
add_python_extension(_ctypes_test NEVER_BUILTIN REQUIRES HAVE_LIBM SOURCES _ctypes/_ctypes_test.c LIBRARIES ${M_LIBRARIES})
Expand Down Expand Up @@ -85,40 +93,51 @@ add_python_extension(strop ${WIN32_BUILTIN} REQUIRES IS_PY2 SOURCES stropmodule.
add_python_extension(_struct ${WIN32_BUILTIN} SOURCES _struct.c)
set(testcapi_SOURCES _testcapimodule.c)
if(PY_VERSION VERSION_GREATER_EQUAL "3.12")
list(APPEND testcapi_SOURCES
_testcapi/abstract.c
_testcapi/buffer.c
_testcapi/bytearray.c
_testcapi/bytes.c
_testcapi/code.c
_testcapi/codec.c
_testcapi/complex.c
_testcapi/datetime.c
_testcapi/dict.c
_testcapi/docstring.c
_testcapi/exceptions.c
_testcapi/file.c
_testcapi/float.c
_testcapi/gc.c
_testcapi/getargs.c
_testcapi/heaptype.c
_testcapi/heaptype_relative.c
_testcapi/immortal.c
_testcapi/list.c
_testcapi/long.c
_testcapi/mem.c
_testcapi/numbers.c
_testcapi/pyos.c
_testcapi/pytime.c
_testcapi/set.c
_testcapi/structmember.c
_testcapi/sys.c
_testcapi/tuple.c
_testcapi/unicode.c
_testcapi/vectorcall.c
_testcapi/vectorcall_limited.c
_testcapi/watchers.c
)
if(PY_VERSION VERSION_LESS "3.13")
list(APPEND testcapi_SOURCES
_testcapi/bytearray.c
_testcapi/heaptype_relative.c
_testcapi/pyos.c
_testcapi/pytime.c
_testcapi/sys.c
_testcapi/vectorcall_limited.c
)
else()
list(APPEND testcapi_SOURCES
_testcapi/hash.c
_testcapi/pyatomic.c
_testcapi/run.c
_testcapi/time.c
)
endif()
list(APPEND testcapi_SOURCES
_testcapi/abstract.c
_testcapi/buffer.c
_testcapi/bytes.c
_testcapi/code.c
_testcapi/codec.c
_testcapi/complex.c
_testcapi/datetime.c
_testcapi/dict.c
_testcapi/docstring.c
_testcapi/exceptions.c
_testcapi/file.c
_testcapi/float.c
_testcapi/gc.c
_testcapi/getargs.c
_testcapi/heaptype.c
_testcapi/immortal.c
_testcapi/list.c
_testcapi/long.c
_testcapi/mem.c
_testcapi/numbers.c
_testcapi/set.c
_testcapi/structmember.c
_testcapi/tuple.c
_testcapi/unicode.c
_testcapi/vectorcall.c
_testcapi/watchers.c
)
endif()
if(PY_VERSION VERSION_LESS "3.12" OR UNIX)
# This module seems to build incorrectly for Python 3.12 Windows
Expand Down Expand Up @@ -208,7 +227,16 @@ endif()

# Python 3.8
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
add_python_extension(_testinternalcapi SOURCES _testinternalcapi.c DEFINITIONS "PY3_DLLNAME=\"python3$<$<CONFIG:Debug>:_d>\"")
set(_testinternalcapi_SOURCES _testinternalcapi.c)
if(PY_VERSION VERSION_GREATER_EQUAL "3.13")
list(APPEND _testinternalcapi_SOURCES
_testinternalcapi/pytime.c
_testinternalcapi/set.c
_testinternalcapi/test_lock.c
_testinternalcapi/test_critical_sections.c
)
endif()
add_python_extension(_testinternalcapi SOURCES ${_testinternalcapi_SOURCES} DEFINITIONS "PY3_DLLNAME=\"python3$<$<CONFIG:Debug>:_d>\"")
endif()

# Python 3.9
Expand Down Expand Up @@ -237,17 +265,21 @@ if(TIRPC_LIBRARY AND TIRPC_RPC_INCLUDE_PATH)
list(APPEND nis_LIBRARIES ${TIRPC_STATIC_LIBRARIES})
endif()
endif()
add_python_extension(nis
REQUIRES ${nis_REQUIRES}
SOURCES nismodule.c
LIBRARIES ${nis_LIBRARIES}
INCLUDEDIRS ${nis_INCLUDEDIRS}
)
if(PY_VERSION VERSION_LESS "3.13")
add_python_extension(nis
REQUIRES ${nis_REQUIRES}
SOURCES nismodule.c
LIBRARIES ${nis_LIBRARIES}
INCLUDEDIRS ${nis_INCLUDEDIRS}
)
endif()

add_python_extension(posix REQUIRES UNIX ALWAYS_BUILTIN SOURCES posixmodule.c DEFINITIONS Py_BUILD_CORE)
add_python_extension(pwd REQUIRES UNIX BUILTIN SOURCES pwdmodule.c) # this is needed to find out the user's home dir if $HOME is not set
add_python_extension(resource REQUIRES UNIX SOURCES resource.c)
add_python_extension(spwd REQUIRES UNIX HAVE_GETSPNAM HAVE_GETSPENT SOURCES spwdmodule.c)
if(PY_VERSION VERSION_LESS "3.13")
add_python_extension(spwd REQUIRES UNIX HAVE_GETSPNAM HAVE_GETSPENT SOURCES spwdmodule.c)
endif()
add_python_extension(syslog REQUIRES UNIX SOURCES syslogmodule.c)
add_python_extension(termios REQUIRES UNIX SOURCES termios.c)

Expand All @@ -266,7 +298,9 @@ add_python_extension(_scproxy

# Linux-only extensions
add_python_extension(linuxaudiodev REQUIRES LINUX IS_PY2 NOT_COSMOPOLITAN SOURCES linuxaudiodev.c)
add_python_extension(ossaudiodev REQUIRES LINUX NOT_COSMOPOLITAN SOURCES ossaudiodev.c)
if(PY_VERSION VERSION_LESS "3.13")
add_python_extension(ossaudiodev REQUIRES LINUX NOT_COSMOPOLITAN SOURCES ossaudiodev.c)
endif()

# Python 3.8: UNIX-only extensions
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
Expand All @@ -278,11 +312,13 @@ if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
endif()

# Windows-only extensions
add_python_extension(_msi
REQUIRES WIN32
SOURCES ${SRC_DIR}/PC/_msi.c
LIBRARIES cabinet.lib msi.lib rpcrt4.lib
)
if(PY_VERSION VERSION_LESS "3.13")
add_python_extension(_msi
REQUIRES WIN32
SOURCES ${SRC_DIR}/PC/_msi.c
LIBRARIES cabinet.lib msi.lib rpcrt4.lib
)
endif()
add_python_extension(msvcrt REQUIRES MSVC BUILTIN SOURCES ${SRC_DIR}/PC/msvcrtmodule.c)
add_python_extension(nt REQUIRES WIN32 ALWAYS_BUILTIN SOURCES posixmodule.c)
add_python_extension(_subprocess REQUIRES WIN32 IS_PY2 BUILTIN SOURCES ${SRC_DIR}/PC/_subprocess.c)
Expand Down
Loading

0 comments on commit b5a60a9

Please sign in to comment.