diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index a57ee8315..c2ffaa9bf 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -2768,16 +2768,17 @@ endif() ########################################################## if(ZLIB_LIBRARIES) - cmake_push_check_state() - set(CFG_HEADERS_SAVE ${CFG_HEADERS}) + #cmake_push_check_state() + #set(CFG_HEADERS_SAVE ${CFG_HEADERS}) - set(CFG_HEADERS ${CFG_HEADERS} zlib.h) - add_cond(CMAKE_REQUIRED_INCLUDES ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) - add_cond(CMAKE_REQUIRED_LIBRARIES ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) - check_symbol_exists(inflateCopy "${CFG_HEADERS}" HAVE_ZLIB_COPY) + #set(CFG_HEADERS ${CFG_HEADERS} zlib.h) + #add_cond(CMAKE_REQUIRED_INCLUDES ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) + #add_cond(CMAKE_REQUIRED_LIBRARIES ZLIB_LIBRARIES ${ZLIB_LIBRARIES}) + #check_symbol_exists(inflateCopy "${CFG_HEADERS}" HAVE_ZLIB_COPY) + set(HAVE_ZLIB_COPY ON CACHE BOOL "Assume Zlib have inflateCopy since checking inflateCopy would result in error during CMake configure" FORCE) - set(CFG_HEADERS ${CFG_HEADERS_SAVE}) - cmake_pop_check_state() + #set(CFG_HEADERS ${CFG_HEADERS_SAVE}) + #cmake_pop_check_state() endif() # Check if tirpc static library and its dependencies can be linked statically diff --git a/cmake/Extensions.cmake b/cmake/Extensions.cmake index d9adc80b1..a1d74ad39 100644 --- a/cmake/Extensions.cmake +++ b/cmake/Extensions.cmake @@ -65,6 +65,8 @@ function(add_python_extension name) # libraries that we might want to link against (eg. readline) set(target_name extension_${pretty_name}) + set_property(GLOBAL APPEND PROPERTY FUCKING_PYTHON_EXTENSION_TARGETS ${target_name}) + set(enable_default ON) if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN AND WITH_STATIC_DEPENDENCIES) set(enable_default OFF) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 40d32f8c5..7b2b236bd 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -311,10 +311,6 @@ if(UNIX) list(APPEND PYTHON_COMMON_SOURCES ${SRC_DIR}/Python/frozenmain.c ) -else() - list(APPEND PYTHON_COMMON_SOURCES - ${SRC_DIR}/Python/frozen.c - ) endif() if(UNIX OR MINGW) @@ -457,10 +453,16 @@ endif() set(LIBPYTHON_FROZEN_SOURCES ) if(IS_PY3) +# Windows needs PyImport_FrozenModules declared... +if(WIN32) + set(FROZENMODULES_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/frozenmodules.c) +endif() + # Build _freeze_importlib executable add_executable(_freeze_importlib ${SRC_DIR}/Programs/_freeze_importlib.c ${LIBPYTHON_OMIT_FROZEN_SOURCES} + ${FROZENMODULES_SOURCE} ) target_link_libraries(_freeze_importlib ${LIBPYTHON_TARGET_LIBRARIES}) if(builtin_compile_definitions_without_py_limited_api) @@ -542,12 +544,8 @@ endif() set(LIBPYTHON_SOURCES ${LIBPYTHON_OMIT_FROZEN_SOURCES} ${LIBPYTHON_FROZEN_SOURCES} + ${SRC_DIR}/Python/frozen.c ) -if(UNIX) - list(APPEND LIBPYTHON_SOURCES - ${SRC_DIR}/Python/frozen.c - ) -endif() # Build python libraries function(add_libpython name type install component) diff --git a/cmake/libpython/frozenmodules.c b/cmake/libpython/frozenmodules.c new file mode 100644 index 000000000..821c10650 --- /dev/null +++ b/cmake/libpython/frozenmodules.c @@ -0,0 +1,8 @@ +/* Dummy frozen modules initializer for building _freeze_importlib + under MS Windows, as using the frozen.c from the Python + distribution results in a circular include of importlib.h +*/ +#include +#include + +const struct _frozen *PyImport_FrozenModules; diff --git a/cmake/python/CMakeLists.txt b/cmake/python/CMakeLists.txt index 7850be5ae..592c205bf 100644 --- a/cmake/python/CMakeLists.txt +++ b/cmake/python/CMakeLists.txt @@ -77,6 +77,9 @@ if(UNIX AND PY_VERSION VERSION_GREATER "2.7.4") ) install(FILES ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py} DESTINATION ${PYTHONHOME}/) + set_property(GLOBAL PROPERTY FUCK_PYTHON_SYSCONFIG_NIMABI ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py}) + set_property(GLOBAL PROPERTY FUCK_PYTHON_SYSCONFIG_NIMABI2 ${PYTHONHOME}/${_sysconfigdata_py}) + set_property(GLOBAL PROPERTY FUCK_PYTHON_SYSCONFIG_NIMABI3 ${PROJECT_BINARY_DIR}) endif() if(UNIX AND NOT CMAKE_CROSSCOMPILING) diff --git a/patches/3.9/0001-Prevent-missing-include-of-io.h-found-in-msi-.patch b/patches/3.9/0001-Prevent-missing-include-of-io.h-found-in-msi-.patch new file mode 100644 index 000000000..9bcf599ed --- /dev/null +++ b/patches/3.9/0001-Prevent-missing-include-of-io.h-found-in-msi-.patch @@ -0,0 +1,105 @@ +--- a/PC/_msi.c 2022-09-08 15:57:12.205510328 +0800 ++++ b/PC/_msi.c 2022-09-08 15:57:42.597842635 +0800 +@@ -174,8 +174,7 @@ + FileTimeToLocalFileTime(&bhfi.ftLastWriteTime, &filetime); + FileTimeToDosDateTime(&filetime, pdate, ptime); + +- *pattribs = (int)(bhfi.dwFileAttributes & +- (_A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH)); ++ *pattribs = (int)(bhfi.dwFileAttributes & 39); /* _A_RDONLY | _A_SYSTEM | _A_HIDDEN | _A_ARCH = 39 */ + + CloseHandle(handle); + +--- a/Modules/posixmodule.c 2022-09-08 15:56:51.851881539 +0800 ++++ b/Modules/posixmodule.c 2022-09-08 15:57:05.029367072 +0800 +@@ -308,8 +308,8 @@ + # define HAVE_PIPE 1 + # define HAVE_SYSTEM 1 + # define HAVE_CWAIT 1 +-# define HAVE_FSYNC 1 +-# define fsync _commit ++/*# define HAVE_FSYNC 1*/ ++/*# define fsync _commit*/ + # else + /* Unix functions that the configure script doesn't check for */ + # ifndef __VXWORKS__ +--- a/Modules/_winapi.c 2022-09-08 15:54:25.084773865 +0800 ++++ b/Modules/_winapi.c 2022-09-08 15:54:50.474541290 +0800 +@@ -145,7 +145,7 @@ + + /*[clinic input] + module _winapi +-class _winapi.Overlapped "OverlappedObject *" "&OverlappedType" ++class _winapi.Overlapped "OverlappedObject *" "&WinApiOverlappedType" + [clinic start generated code]*/ + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c13d3f5fd1dabb84]*/ + +@@ -304,7 +304,7 @@ + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -350,7 +350,7 @@ + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1941,7 +1941,7 @@ + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1949,7 +1949,7 @@ + return NULL; + d = PyModule_GetDict(m); + +- PyDict_SetItemString(d, "Overlapped", (PyObject *) &OverlappedType); ++ PyDict_SetItemString(d, "Overlapped", (PyObject *) &WinApiOverlappedType); + + /* constants */ + WINAPI_CONSTANT(F_DWORD, CREATE_NEW_CONSOLE); +--- a/Modules/_decimal/libmpdec/mpdecimal.c 2022-09-08 15:59:03.704908109 +0800 ++++ b/Modules/_decimal/libmpdec/mpdecimal.c 2022-09-08 15:59:15.807383050 +0800 +@@ -63,7 +63,7 @@ + + + #if defined(_MSC_VER) +- #define ALWAYS_INLINE __forceinline ++ #define ALWAYS_INLINE extern __forceinline + #elif defined(__IBMC__) || defined(LEGACY_COMPILER) + #define ALWAYS_INLINE + #undef inline +@@ -517,7 +517,7 @@ + } + + /* Same as mpd_qresize, but do not set the result no NaN on failure. */ +-static ALWAYS_INLINE int ++ALWAYS_INLINE int + mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords) + { + assert(!mpd_isconst_data(result)); /* illegal operation for a const */ +--- a/Modules/_decimal/libmpdec/mpdecimal.h 2022-09-09 15:51:38.202653415 +0800 ++++ b/Modules/_decimal/libmpdec/mpdecimal.h 2022-09-09 15:52:07.611967326 +0800 +@@ -105,6 +105,10 @@ + /* Configuration */ + /******************************************************************************/ + ++#if !defined(CONFIG_64) && !defined(CONFIG_32) && !defined(UNIVERSAL) ++#define CONFIG_64 1 ++#endif ++ + #if defined(UNIVERSAL) + #if defined(CONFIG_64) || defined(CONFIG_32) + #error "cannot use CONFIG_64 or CONFIG_32 with UNIVERSAL."