From bc3f18cdbf41b9368fdabd3e1a48c0e0e0ef602c Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 21 Mar 2016 20:32:22 +0100 Subject: [PATCH 01/22] Install libpython pdb file when building shared libraries --- cmake/libpython/CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index b7124d3e..386e238a 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -926,6 +926,15 @@ if(BUILD_LIBPYTHON_SHARED) set_target_properties(libpython-shared PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_ARCHIVEDIR} ) + + if((MSVC_VERSION GREATER 1500) AND (NOT CMAKE_VERSION VERSION_LESS "3.1")) + install( + FILES $ + DESTINATION ${LIBPYTHON_ARCHIVEDIR} + CONFIGURATIONS Debug RelWithDebInfo + ) + endif() + if(APPLE) # HACK For python <= 2.7.3, this fix link error related to undefined _environ symbol and # is equivalent to solution implemented in commit http://hg.python.org/cpython/rev/864b983 @@ -1003,6 +1012,14 @@ if(BUILD_LIBPYTHON_SHARED) "PYTHON_DLL_NAME=\"python${PY_VERSION_MAJOR}${PY_VERSION_MINOR}$<$:_d>\"" ) endif() + + if((MSVC_VERSION GREATER 1500) AND (NOT CMAKE_VERSION VERSION_LESS "3.1")) + install( + FILES $ + DESTINATION ${LIBPYTHON_ARCHIVEDIR} + CONFIGURATIONS Debug RelWithDebInfo + ) + endif() endif() if(UNIX AND NOT APPLE) From a58bcb0c1efa4e29c417f2432ddc62ce526532e7 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 21 Mar 2016 20:39:08 +0100 Subject: [PATCH 02/22] Don't export python cmake targets --- CMakeLists.txt | 12 ------------ cmake/libpython/CMakeLists.txt | 2 +- cmake/python/CMakeLists.txt | 2 +- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cabf83c..a64dd507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -941,18 +941,6 @@ write_basic_package_version_file( COMPATIBILITY SameMajorVersion ) -if(INSTALL_DEVELOPMENT) - # Install 'PythonTargets.cmake', 'PythonConfig.cmake' and 'PythonConfigVersion.cmake - install(EXPORT PythonTargets - FILE PythonTargets.cmake - DESTINATION ${CONFIG_INSTALL_DIR} COMPONENT Development) - - install( - FILES ${python_install_config} ${python_config_version} - DESTINATION ${CONFIG_INSTALL_DIR} COMPONENT Development - ) -endif() - # Install License set(license_destination ${PYTHONHOME}) if(INSTALL_WINDOWS_TRADITIONAL) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 386e238a..5b3e1760 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -912,7 +912,7 @@ function(add_libpython name type install component) set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS ${name}) if(install) - install(TARGETS ${name} EXPORT PythonTargets + install(TARGETS ${name} ARCHIVE DESTINATION ${LIBPYTHON_ARCHIVEDIR} LIBRARY DESTINATION ${LIBPYTHON_LIBDIR} RUNTIME DESTINATION ${LIBPYTHON_LIBDIR} diff --git a/cmake/python/CMakeLists.txt b/cmake/python/CMakeLists.txt index 60cda177..6f829ccd 100644 --- a/cmake/python/CMakeLists.txt +++ b/cmake/python/CMakeLists.txt @@ -29,7 +29,7 @@ endif() # Export target set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS python) -install(TARGETS python EXPORT PythonTargets RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) +install(TARGETS python RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) # See "is_python_build()" in sysconfig.py add_custom_command(TARGET python PRE_BUILD From 39ba58430ee234c8d29bcea6694838532df00b91 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Mon, 21 Mar 2016 20:39:55 +0100 Subject: [PATCH 03/22] Change pathes to match current SDK layout --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a64dd507..8bf269d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -524,10 +524,7 @@ if(USE_LIB64) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) set(LIBDIR "lib64") endif() -set(PYTHONHOME "${LIBDIR}") -if(UNIX) - set(PYTHONHOME "${PYTHONHOME}/${LIBPYTHON}") -endif() +set(PYTHONHOME "${LIBDIR}/${LIBPYTHON}") # Install tree directory set(BIN_INSTALL_DIR bin) # Contains the python executable @@ -549,7 +546,7 @@ if(INSTALL_WINDOWS_TRADITIONAL) endif() set(INCLUDE_INSTALL_DIR include/python${LD_VERSION}) if(MSVC) - set(INCLUDE_INSTALL_DIR include) + set(INCLUDE_INSTALL_DIR include/python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) endif() # Build tree directory set(BIN_BUILD_DIR ${PROJECT_BINARY_DIR}/bin) @@ -557,7 +554,7 @@ set(CONFIG_BUILD_DIR ${PROJECT_BINARY_DIR}/${CONFIG_INSTALL_DIR}) set(EXTENSION_BUILD_DIR ${PROJECT_BINARY_DIR}/${PYTHONHOME}/lib-dynload) set(INCLUDE_BUILD_DIR ${SRC_DIR}/Include) -set(ARCHIVEDIR "libs") # Contains the static (*.a) and import libraries (*.lib) +set(ARCHIVEDIR "lib") # Contains the static (*.a) and import libraries (*.lib) # Directories specific to 'libpython' set(LIBPYTHON_LIBDIR ${LIBDIR}) From fecfa206c18efa571a1a560f49ef5e0bc1c2ff16 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Tue, 6 Sep 2016 16:59:04 +0200 Subject: [PATCH 04/22] Disable MSVC specific compiler warnings * Disable C4101 'identifier' : unreferenced local variable for libpython. * Disable C4018 'expression' : signed/unsigned mismatch for libpython. * Disable C4244 'conversion' conversion from 'type1' to 'type2', possible loss of data for libpython. * Disable C4996 The compiler encountered a deprecated declaration. for libpython. --- cmake/libpython/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 5b3e1760..09288181 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -222,6 +222,9 @@ elseif(WIN32) PROPERTY COMPILE_DEFINITIONS "PY3_DLLNAME=${_wide_char_modifier}\"python3$<$:_d>\"" # Python 3.11 ) + if(MSVC) + add_compile_options(/wd4101 /wd4018 /wd4244 /wd4996) + endif() endif() set(PYTHON_COMMON_SOURCES From 02a3b7412edb78839bb640bf18ad443903ab5763 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Sat, 9 Apr 2016 20:16:24 +0200 Subject: [PATCH 05/22] Add Mac OSX framework support --- CMakeLists.txt | 8 ++++++++ cmake/libpython/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bf269d3..b192b208 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,14 @@ else() set(BUILD_WININST_ALWAYS OFF) endif() +if(APPLE) + option(BUILD_FRAMEWORK "Build a Mac OSX Framework" OFF) + if(BUILD_FRAMEWORK) + set(BUILD_LIBPYTHON_SHARED ON CACHE BOOL "Forced to ON because of BUILD_FRAMEWORK=ON" FORCE) + endif() +else() + set(BUILD_FRAMEWORK 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) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 09288181..a3aa8b58 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -914,11 +914,24 @@ function(add_libpython name type install component) # Export target set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS ${name}) + if(BUILD_FRAMEWORK) + set_target_properties(${name} PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" + MACOSX_FRAMEWORK_IDENTIFIER org.python.python + MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" + MACOSX_FRAMEWORK_BUNDLE_VERSION "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" + MACOSX_RPATH ON + OUTPUT_NAME Python + ) + endif() + if(install) install(TARGETS ${name} ARCHIVE DESTINATION ${LIBPYTHON_ARCHIVEDIR} LIBRARY DESTINATION ${LIBPYTHON_LIBDIR} RUNTIME DESTINATION ${LIBPYTHON_LIBDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${component} ) endif() From a1fe89f03a9d33656fe3b68af5902543d77c61a8 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Sat, 17 Sep 2016 21:36:45 +0200 Subject: [PATCH 06/22] Install binaries, libraries, headers files and auxilliary files into framework --- CMakeLists.txt | 22 +++++++++++++++++++--- cmake/include/CMakeLists.txt | 18 ++++++++++++++++++ cmake/libpython/CMakeLists.txt | 11 +++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b192b208..fbbf543e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,8 @@ if(APPLE) if(BUILD_FRAMEWORK) set(BUILD_LIBPYTHON_SHARED ON CACHE BOOL "Forced to ON because of BUILD_FRAMEWORK=ON" FORCE) endif() + set(FRAMEWORK_DIR_ROOT Python.framework) + set(FRAMEWORK_DIR_PREFIX ${FRAMEWORK_DIR_ROOT}/Versions/${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) else() set(BUILD_FRAMEWORK OFF) endif() @@ -532,6 +534,9 @@ if(USE_LIB64) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON) set(LIBDIR "lib64") endif() +if(BUILD_FRAMEWORK) + set(LIBDIR ${FRAMEWORK_DIR_PREFIX}/lib) +endif() set(PYTHONHOME "${LIBDIR}/${LIBPYTHON}") # Install tree directory @@ -539,8 +544,15 @@ set(BIN_INSTALL_DIR bin) # Contains the python executabl if(INSTALL_WINDOWS_TRADITIONAL) set(BIN_INSTALL_DIR .) # Contains the python executable endif() +if(BUILD_FRAMEWORK) + set(BIN_INSTALL_DIR ${FRAMEWORK_DIR_PREFIX}/bin) +endif() +set(SHARE_INSTALL_DIR share) +if(BUILD_FRAMEWORK) + set(SHARE_INSTALL_DIR ${FRAMEWORK_DIR_PREFIX}/share) +endif() set(LD_VERSION ${LIBPYTHON_VERSION}${ABIFLAGS}) -set(CONFIG_INSTALL_DIR share/${LIBPYTHON}) +set(CONFIG_INSTALL_DIR ${SHARE_INSTALL_DIR}/${LIBPYTHON}) set(EXTENSION_INSTALL_DIR ${PYTHONHOME}/lib-dynload) if (${LIBPYTHON_VERSION} GREATER 3.1) @@ -556,6 +568,10 @@ set(INCLUDE_INSTALL_DIR include/python${LD_VERSION}) if(MSVC) set(INCLUDE_INSTALL_DIR include/python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) endif() +if(BUILD_FRAMEWORK) + set(REL_INCLUDE_INSTALL_DIR include/python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) + set(INCLUDE_INSTALL_DIR ${FRAMEWORK_DIR_PREFIX}/include/python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) +endif() # Build tree directory set(BIN_BUILD_DIR ${PROJECT_BINARY_DIR}/bin) set(CONFIG_BUILD_DIR ${PROJECT_BINARY_DIR}/${CONFIG_INSTALL_DIR}) @@ -820,7 +836,7 @@ if(UNIX) ${PROJECT_BINARY_DIR}/Misc/python-${LIBPYTHON_VERSION}.pc ${PROJECT_BINARY_DIR}/Misc/python-${PY_VERSION_MAJOR}.pc ${PROJECT_BINARY_DIR}/Misc/python.pc - DESTINATION lib/pkgconfig + DESTINATION ${LIBDIR}/pkgconfig COMPONENT Development) endif() @@ -847,7 +863,7 @@ if(UNIX) # Install manual if(INSTALL_MANUAL) - set(_install_man FILES ${SRC_DIR}/Misc/python.man DESTINATION share/man/man1 COMPONENT Runtime) + set(_install_man FILES ${SRC_DIR}/Misc/python.man DESTINATION ${SHARE_INSTALL_DIR}/man/man1 COMPONENT Runtime) install(${_install_man} RENAME python${LIBPYTHON_VERSION}.1) install(${_install_man} RENAME python${PY_VERSION_MAJOR}.1) endif() diff --git a/cmake/include/CMakeLists.txt b/cmake/include/CMakeLists.txt index f75ede6e..e14bb19f 100644 --- a/cmake/include/CMakeLists.txt +++ b/cmake/include/CMakeLists.txt @@ -12,3 +12,21 @@ foreach(file ${hfiles}) install(FILES ${includedir}/${file} DESTINATION ${INCLUDE_INSTALL_DIR}/${path} COMPONENT Development) endif() endforeach() +if(BUILD_FRAMEWORK) + install(CODE " + message(STATUS \"Creating Python header framework symlinks...\") + execute_process( + COMMAND + \${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers Headers + WORKING_DIRECTORY + \"${CMAKE_INSTALL_PREFIX}/${FRAMEWORK_DIR_ROOT}\" + ) + + execute_process( + COMMAND + \${CMAKE_COMMAND} -E create_symlink \"${REL_INCLUDE_INSTALL_DIR}\" Headers + WORKING_DIRECTORY + \"${CMAKE_INSTALL_PREFIX}/${FRAMEWORK_DIR_PREFIX}\" + ) + ") +endif() diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index a3aa8b58..5ed66b5e 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -934,6 +934,17 @@ function(add_libpython name type install component) FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${component} ) + if(BUILD_FRAMEWORK) + install(CODE " + message(STATUS \"Creating Python library framework symlinks...\") + execute_process( + COMMAND + \${CMAKE_COMMAND} -E create_symlink \"../${FRAMEWORK_NAME}\" libpython${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.dylib + WORKING_DIRECTORY + \"${CMAKE_INSTALL_PREFIX}/${FRAMEWORK_DIR_PREFIX}/lib\" + ) + ") + endif() endif() endfunction() From 52fc64499f3f5f02db20ba08c8f431f8b2c1082b Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Sun, 18 Sep 2016 23:18:14 +0200 Subject: [PATCH 07/22] Change PYTHONPATH and PYTHONHOME for framework builds --- CMakeLists.txt | 6 +++++- cmake/ConfigureChecks.cmake | 4 +++- cmake/python/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbbf543e..82e0d65f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -668,7 +668,11 @@ if(BUILD_LIBPYTHON_SHARED AND UNIX) if(APPLE) set(_envvar DYLD_LIBRARY_PATH) endif() - set(PYTHON_WRAPPER_COMMAND env ${_envvar}=${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR}) + set(PYTHON_HOME_PATH ) + if(BUILD_FRAMEWORK) + set(PYTHON_HOME_PATH PYTHONHOME=${PROJECT_BINARY_DIR}/${PYTHONHOME} PYTHONPATH=${PROJECT_BINARY_DIR}/${PYTHONHOME}) + endif() + set(PYTHON_WRAPPER_COMMAND env ${_envvar}=${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} ${PYTHON_HOME_PATH}) endif() # Add extension modules diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index ecde8b91..0371dbd5 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -911,7 +911,9 @@ set(WITH_DYLD 0) set(WITH_NEXT_FRAMEWORK 0) if(APPLE) set(WITH_DYLD 1) - set(WITH_NEXT_FRAMEWORK 0) # TODO: See --enable-framework option. + if(BUILD_FRAMEWORK) + set(WITH_NEXT_FRAMEWORK 1) # TODO: See --enable-framework option. + endif() endif() set(PYTHONFRAMEWORK "") diff --git a/cmake/python/CMakeLists.txt b/cmake/python/CMakeLists.txt index 6f829ccd..158816c7 100644 --- a/cmake/python/CMakeLists.txt +++ b/cmake/python/CMakeLists.txt @@ -58,7 +58,7 @@ if(UNIX AND NOT ANDROID) add_custom_command( OUTPUT ${BIN_BUILD_DIR}/pybuilddir.txt ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py} COMMAND ${PYTHON_WRAPPER_COMMAND} - ${CMAKE_CROSSCOMPILING_EMULATOR} $ -E -S -m sysconfig --generate-posix-vars + ${CMAKE_CROSSCOMPILING_EMULATOR} $ -S -m sysconfig --generate-posix-vars COMMAND ${CMAKE_COMMAND} -DBIN_BUILD_DIR:PATH=${BIN_BUILD_DIR} -DSYSCONFIGDATA_PY:STRING=${_sysconfigdata_py} From f06c7309ef947dbae7739e1a2426d73b717efdd6 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Tue, 20 Sep 2016 17:21:09 +0200 Subject: [PATCH 08/22] Install platform library files on MacOSX --- cmake/lib/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/lib/CMakeLists.txt b/cmake/lib/CMakeLists.txt index 5f62ecab..5a7f5808 100644 --- a/cmake/lib/CMakeLists.txt +++ b/cmake/lib/CMakeLists.txt @@ -7,6 +7,10 @@ if(UNIX) set(plat_subdir "plat-linux") endif() +if(APPLE) + set(plat_subdir "plat-darwin") +endif() + foreach(file ${libfiles}) # Don't install files for other platforms string(REGEX MATCH "^plat-" is_platform_file "${file}") From eeacc20c7e474b25c0ac1d5ffff099a8b62ae569 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Thu, 29 Sep 2016 22:36:31 +0200 Subject: [PATCH 09/22] Install configure Makefile and pyconfig.h for sysconfig into INT dir This is required when using multi-config cmake generators. --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82e0d65f..32c0bddd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -598,6 +598,9 @@ if(UNIX) set(PYCONFIG_BUILD_DIR ${BIN_BUILD_DIR}) configure_file(cmake/config-unix/pyconfig.h.in ${PYCONFIG_BUILD_DIR}/pyconfig.h) + file(GENERATE + OUTPUT $/pyconfig.h + INPUT ${PYCONFIG_BUILD_DIR}/pyconfig.h) elseif(WIN32) set(PYCONFIG_BUILD_DIR ${SRC_DIR}/PC) # In a windows build tree, 'pyconfig.h' is NOT required to # live along side the python executable. @@ -850,9 +853,12 @@ if(UNIX) set(MAKEFILE_LDSHARED_FLAGS "-dynamiclib -headerpad_max_install_names -undefined dynamic_lookup") endif() configure_file(cmake/makefile-variables.in - ${BIN_BUILD_DIR}/Makefile @ONLY) + ${BIN_BUILD_DIR}/Makefile.in @ONLY) + file(GENERATE + OUTPUT $/Makefile + INPUT ${BIN_BUILD_DIR}/Makefile.in) if(INSTALL_DEVELOPMENT) - install(FILES ${BIN_BUILD_DIR}/Makefile + install(FILES $/Makefile DESTINATION ${LIB_CONFIG_INSTALL_DIR} RENAME Makefile COMPONENT Development) From ce62a267f60760ce6fae63cd72906960d7d23654 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Wed, 19 Oct 2016 10:16:07 +0200 Subject: [PATCH 10/22] Disable generation of python compiled bytecode when calling python in build --- CMakeLists.txt | 10 +++++----- cmake/python/CMakeLists.txt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32c0bddd..221fb443 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -708,7 +708,7 @@ endif() # Add target to run "Argument Clinic" over all source files add_custom_target(clinic - COMMAND python ${SRC_DIR}/Tools/clinic/clinic.py --make + COMMAND python -B ${SRC_DIR}/Tools/clinic/clinic.py --make DEPENDS python WORKING_DIRECTORY ${SRC_DIR} COMMENT "Running 'Argument Clinic' over all source files" @@ -776,7 +776,7 @@ endif() # Add target to generate 'opcode.h' header file add_custom_target(generate_opcode_h - COMMAND python ${SRC_DIR}/Tools/scripts/generate_opcode_h.py + COMMAND python -B ${SRC_DIR}/Tools/scripts/generate_opcode_h.py ${SRC_DIR}/Lib/opcode.py ${PROJECT_BINARY_DIR}/CMakeFiles/opcode.h COMMAND ${CMAKE_COMMAND} -E copy_if_different @@ -790,7 +790,7 @@ add_custom_target(generate_opcode_h # Add target to generate 'Include/Python-ast.h' from 'Python.asdl' add_custom_target(generate_python_ast_h - COMMAND python ${SRC_DIR}/Parser/asdl_c.py + COMMAND python -B ${SRC_DIR}/Parser/asdl_c.py -h ${SRC_DIR}/Include ${SRC_DIR}/Parser/Python.asdl DEPENDS python @@ -801,7 +801,7 @@ add_custom_target(generate_python_ast_h # Add target to generate 'Python/Python-ast.c' from 'Python.asdl' add_custom_target(generate_python_ast_c - COMMAND python ${SRC_DIR}/Parser/asdl_c.py + COMMAND python -B ${SRC_DIR}/Parser/asdl_c.py -c ${SRC_DIR}/Python ${SRC_DIR}/Parser/Python.asdl DEPENDS python @@ -901,7 +901,7 @@ if(BUILD_TESTING) ) set(TESTPROG ${PROJECT_BINARY_DIR}/${PYTHONHOME}/test/regrtest.py) set(TESTPYTHONOPTS ) - set(TESTPYTHON $ ${TESTPYTHONOPTS}) + set(TESTPYTHON $ -B ${TESTPYTHONOPTS}) set(TESTPYTHON ${CMAKE_CROSSCOMPILING_EMULATOR} ${TESTPYTHON}) include(cmake/UnitTests.cmake) foreach(unittest ${unittests}) diff --git a/cmake/python/CMakeLists.txt b/cmake/python/CMakeLists.txt index 158816c7..0aedbd20 100644 --- a/cmake/python/CMakeLists.txt +++ b/cmake/python/CMakeLists.txt @@ -58,7 +58,7 @@ if(UNIX AND NOT ANDROID) add_custom_command( OUTPUT ${BIN_BUILD_DIR}/pybuilddir.txt ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py} COMMAND ${PYTHON_WRAPPER_COMMAND} - ${CMAKE_CROSSCOMPILING_EMULATOR} $ -S -m sysconfig --generate-posix-vars + ${CMAKE_CROSSCOMPILING_EMULATOR} $ -B -S -m sysconfig --generate-posix-vars COMMAND ${CMAKE_COMMAND} -DBIN_BUILD_DIR:PATH=${BIN_BUILD_DIR} -DSYSCONFIGDATA_PY:STRING=${_sysconfigdata_py} From b58086f702b117e77f74b386c81f69900e25214f Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Wed, 19 Oct 2016 12:09:42 +0200 Subject: [PATCH 11/22] Populate Makefile variable with MacOSX framework variables --- CMakeLists.txt | 13 +++++++++++-- cmake/libpython/CMakeLists.txt | 2 +- cmake/makefile-variables.in | 10 +++++----- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 221fb443..bdc7fd58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,11 +100,20 @@ if(APPLE) if(BUILD_FRAMEWORK) set(BUILD_LIBPYTHON_SHARED ON CACHE BOOL "Forced to ON because of BUILD_FRAMEWORK=ON" FORCE) endif() - set(FRAMEWORK_DIR_ROOT Python.framework) - set(FRAMEWORK_DIR_PREFIX ${FRAMEWORK_DIR_ROOT}/Versions/${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) else() set(BUILD_FRAMEWORK OFF) endif() +if(BUILD_FRAMEWORK) + set(FRAMEWORK_NAME Python) + set(FRAMEWORK_PREFIX ${CMAKE_INSTALL_PREFIX}) + set(FRAMEWORK_DIR_ROOT ${FRAMEWORK_NAME}.framework) + set(FRAMEWORK_DIR_PREFIX ${FRAMEWORK_DIR_ROOT}/Versions/${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}) +else() + set(FRAMEWORK_NAME "") + set(FRAMEWORK_PREFIX "") + set(FRAMEWORK_DIR_ROOT "no-framework") + set(FRAMEWORK_DIR_PREFIX "") +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) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 5ed66b5e..746d0629 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -922,7 +922,7 @@ function(add_libpython name type install component) MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" MACOSX_FRAMEWORK_BUNDLE_VERSION "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}" MACOSX_RPATH ON - OUTPUT_NAME Python + OUTPUT_NAME ${FRAMEWORK_NAME} ) endif() diff --git a/cmake/makefile-variables.in b/cmake/makefile-variables.in index 5dd942cb..a899a7cb 100644 --- a/cmake/makefile-variables.in +++ b/cmake/makefile-variables.in @@ -103,11 +103,11 @@ EXE= @CMAKE_EXECUTABLE_SUFFIX@ BUILDEXE= @CMAKE_EXECUTABLE_SUFFIX@ # Short name and location for Mac OS X Python framework -UNIVERSALSDK= -PYTHONFRAMEWORK= -PYTHONFRAMEWORKDIR= no-framework -PYTHONFRAMEWORKPREFIX= -PYTHONFRAMEWORKINSTALLDIR= +UNIVERSALSDK= @CMAKE_OSX_SYSROOT@ +PYTHONFRAMEWORK= @FRAMEWORK_NAME@ +PYTHONFRAMEWORKDIR= @FRAMEWORK_DIR_ROOT@ +PYTHONFRAMEWORKPREFIX= @FRAMEWORK_PREFIX@ +PYTHONFRAMEWORKINSTALLDIR= @FRAMEWORK_DIR_PREFIX@ # Deployment target selected during configure, to be checked # by distutils. The export statement is needed to ensure that the # deployment target is active during build. From fc5fc99c92b5c4de58aafadac90a25e28000ec51 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Tue, 15 Nov 2016 10:57:52 +0100 Subject: [PATCH 12/22] Set INSTALL_NAME_DIR only for non-frameworks on OSX --- cmake/libpython/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/libpython/CMakeLists.txt b/cmake/libpython/CMakeLists.txt index 746d0629..07a781f2 100644 --- a/cmake/libpython/CMakeLists.txt +++ b/cmake/libpython/CMakeLists.txt @@ -898,7 +898,6 @@ function(add_libpython name type install component) OUTPUT_NAME ${LIBPYTHON}${ABIFLAGS} LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR} - INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR} ) set_target_properties(${name} PROPERTIES POSITION_INDEPENDENT_CODE ON @@ -924,6 +923,10 @@ function(add_libpython name type install component) MACOSX_RPATH ON OUTPUT_NAME ${FRAMEWORK_NAME} ) + else() + set_target_properties(${name} PROPERTIES + INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR} + ) endif() if(install) From bc5950e1a2d93e997921141190f12f1d5037c740 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Thu, 23 Mar 2017 22:51:06 +0100 Subject: [PATCH 13/22] Set python exe RPATH to search for libpython in Frameworks --- cmake/python/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/python/CMakeLists.txt b/cmake/python/CMakeLists.txt index 0aedbd20..90422cc0 100644 --- a/cmake/python/CMakeLists.txt +++ b/cmake/python/CMakeLists.txt @@ -26,6 +26,12 @@ if(MSVC) set_target_properties(python PROPERTIES LINK_FLAGS /STACK:2000000) endif() +if(BUILD_FRAMEWORK) + set_target_properties(python PROPERTIES + INSTALL_RPATH "@loader_path/../../../.." + ) +endif() + # Export target set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS python) From fd1de2c873924f204192431fc61a149c0e64e0a2 Mon Sep 17 00:00:00 2001 From: Marcel Metz Date: Sun, 15 Apr 2018 20:25:24 +0200 Subject: [PATCH 14/22] Use python. as executable output name --- cmake/python/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmake/python/CMakeLists.txt b/cmake/python/CMakeLists.txt index 90422cc0..f5aa5dc1 100644 --- a/cmake/python/CMakeLists.txt +++ b/cmake/python/CMakeLists.txt @@ -3,9 +3,11 @@ set(PYTHON_SOURCES ) add_executable(python ${PYTHON_SOURCES}) -set_property( - TARGET python - PROPERTY RUNTIME_OUTPUT_DIRECTORY ${BIN_BUILD_DIR} +set_target_properties( + python + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY ${BIN_BUILD_DIR} + OUTPUT_NAME python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR} ) target_compile_definitions(python PRIVATE Py_BUILD_CORE) add_definitions(-DPy_BUILD_CORE) @@ -86,10 +88,10 @@ if(UNIX AND NOT CMAKE_CROSSCOMPILING) install(CODE "message(STATUS \"Creating Python executable symlinks...\") execute_process( - COMMAND \${CMAKE_COMMAND} -E create_symlink python + COMMAND \${CMAKE_COMMAND} -E create_symlink python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR} python${PY_VERSION_MAJOR} - COMMAND \${CMAKE_COMMAND} -E create_symlink python - python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR} + COMMAND \${CMAKE_COMMAND} -E create_symlink python${PY_VERSION_MAJOR} + python WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR} )" From bb96f7307c9852a0d763289816d27c40d54d461f Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Thu, 19 May 2022 17:35:29 +0300 Subject: [PATCH 15/22] Copy 3.6 patches to 3.7 --- ...t-include-of-io.h-found-in-libmpdec-.patch | 35 ++++++++++ ...ed-OverlappedType-symbols-with-built.patch | 65 +++++++++++++++++++ ...-inlined-functions-to-support-extens.patch | 36 ++++++++++ patches/3.7/README.rst | 8 +++ 4 files changed, 144 insertions(+) create mode 100644 patches/3.7/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch create mode 100644 patches/3.7/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch create mode 100644 patches/3.7/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch create mode 100644 patches/3.7/README.rst diff --git a/patches/3.7/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.7/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch new file mode 100644 index 00000000..0e37554f --- /dev/null +++ b/patches/3.7/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -0,0 +1,35 @@ +From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 21:44:29 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec + directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index 3aadfb0..1cc719a 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -38,7 +38,7 @@ + #include "bits.h" + #include "constants.h" + #include "typearith.h" +-#include "io.h" ++#include "mpd_io.h" + + + /* This file contains functions for decimal <-> string conversions, including +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +-- +2.5.0 + diff --git a/patches/3.7/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.7/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..6fd360a5 --- /dev/null +++ b/patches/3.7/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,65 @@ +From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index 1606f0d..d81215f 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[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]*/ + +@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1537,7 +1537,7 @@ PyInit__winapi(void) + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1545,7 +1545,7 @@ PyInit__winapi(void) + 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); +-- +2.5.0 + diff --git a/patches/3.7/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.7/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..eaa49dc0 --- /dev/null +++ b/patches/3.7/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,36 @@ +From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 328ab92..5812bcd 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -54,7 +54,7 @@ + + + #if defined(_MSC_VER) +- #define ALWAYS_INLINE __forceinline ++ #define ALWAYS_INLINE extern __forceinline + #elif defined(LEGACY_COMPILER) + #define ALWAYS_INLINE + #undef inline +-- +2.5.0 + diff --git a/patches/3.7/README.rst b/patches/3.7/README.rst new file mode 100644 index 00000000..783b640a --- /dev/null +++ b/patches/3.7/README.rst @@ -0,0 +1,8 @@ +* ``0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. From 844c8c91c70810676336678d6113d8fe4fc8d8c5 Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Wed, 25 May 2022 17:14:57 +0300 Subject: [PATCH 16/22] Copy 3.7 patches to 3.8 --- ...t-include-of-io.h-found-in-libmpdec-.patch | 35 ++++++++++ ...ed-OverlappedType-symbols-with-built.patch | 65 +++++++++++++++++++ ...-inlined-functions-to-support-extens.patch | 36 ++++++++++ patches/3.8/README.rst | 8 +++ 4 files changed, 144 insertions(+) create mode 100644 patches/3.8/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch create mode 100644 patches/3.8/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch create mode 100644 patches/3.8/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch create mode 100644 patches/3.8/README.rst diff --git a/patches/3.8/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.8/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch new file mode 100644 index 00000000..0e37554f --- /dev/null +++ b/patches/3.8/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -0,0 +1,35 @@ +From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 21:44:29 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec + directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index 3aadfb0..1cc719a 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -38,7 +38,7 @@ + #include "bits.h" + #include "constants.h" + #include "typearith.h" +-#include "io.h" ++#include "mpd_io.h" + + + /* This file contains functions for decimal <-> string conversions, including +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +-- +2.5.0 + diff --git a/patches/3.8/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.8/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..6fd360a5 --- /dev/null +++ b/patches/3.8/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,65 @@ +From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index 1606f0d..d81215f 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[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]*/ + +@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1537,7 +1537,7 @@ PyInit__winapi(void) + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1545,7 +1545,7 @@ PyInit__winapi(void) + 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); +-- +2.5.0 + diff --git a/patches/3.8/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.8/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..eaa49dc0 --- /dev/null +++ b/patches/3.8/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,36 @@ +From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 328ab92..5812bcd 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -54,7 +54,7 @@ + + + #if defined(_MSC_VER) +- #define ALWAYS_INLINE __forceinline ++ #define ALWAYS_INLINE extern __forceinline + #elif defined(LEGACY_COMPILER) + #define ALWAYS_INLINE + #undef inline +-- +2.5.0 + diff --git a/patches/3.8/README.rst b/patches/3.8/README.rst new file mode 100644 index 00000000..783b640a --- /dev/null +++ b/patches/3.8/README.rst @@ -0,0 +1,8 @@ +* ``0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. From 4fea5a0a4348b2fd29d78a439eff63b059720c77 Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Mon, 10 Apr 2023 16:31:31 +0300 Subject: [PATCH 17/22] Copy 3.8 patches to 3.9 --- ...t-include-of-io.h-found-in-libmpdec-.patch | 35 ++++++++++ ...ed-OverlappedType-symbols-with-built.patch | 65 +++++++++++++++++++ ...-inlined-functions-to-support-extens.patch | 46 +++++++++++++ patches/3.9/README.rst | 8 +++ 4 files changed, 154 insertions(+) create mode 100644 patches/3.9/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch create mode 100644 patches/3.9/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch create mode 100644 patches/3.9/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch create mode 100644 patches/3.9/README.rst diff --git a/patches/3.9/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.9/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch new file mode 100644 index 00000000..403c9255 --- /dev/null +++ b/patches/3.9/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -0,0 +1,35 @@ +From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 21:44:29 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec + directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index 3aadfb0..1cc719a 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -38,7 +38,7 @@ + #include + + #include "typearith.h" +-#include "io.h" ++#include "mpd_io.h" + + + /* This file contains functions for decimal <-> string conversions, including +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +-- +2.5.0 + diff --git a/patches/3.9/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.9/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..6fd360a5 --- /dev/null +++ b/patches/3.9/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,65 @@ +From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index 1606f0d..d81215f 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[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]*/ + +@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1537,7 +1537,7 @@ PyInit__winapi(void) + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1545,7 +1545,7 @@ PyInit__winapi(void) + 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); +-- +2.5.0 + diff --git a/patches/3.9/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.9/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..d00d4bc8 --- /dev/null +++ b/patches/3.9/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,46 @@ +From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 328ab92..5812bcd 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -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 ++static inline int + mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords) + { + assert(!mpd_isconst_data(result)); /* illegal operation for a const */ + +-- +2.5.0 + diff --git a/patches/3.9/README.rst b/patches/3.9/README.rst new file mode 100644 index 00000000..783b640a --- /dev/null +++ b/patches/3.9/README.rst @@ -0,0 +1,8 @@ +* ``0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. From 6ae664a01138dde110b926dff237b4f6be2d935f Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Sat, 22 Feb 2025 22:54:11 +0400 Subject: [PATCH 18/22] Copy patches 3.10 --- ...t-include-of-io.h-found-in-libmpdec-.patch | 35 ++++++++++ ...ed-OverlappedType-symbols-with-built.patch | 65 +++++++++++++++++++ ...-inlined-functions-to-support-extens.patch | 46 +++++++++++++ patches/3.10/README.rst | 8 +++ 4 files changed, 154 insertions(+) create mode 100644 patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch create mode 100644 patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch create mode 100644 patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch create mode 100644 patches/3.10/README.rst diff --git a/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch new file mode 100644 index 00000000..403c9255 --- /dev/null +++ b/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -0,0 +1,35 @@ +From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 21:44:29 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec + directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index 3aadfb0..1cc719a 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -38,7 +38,7 @@ + #include + + #include "typearith.h" +-#include "io.h" ++#include "mpd_io.h" + + + /* This file contains functions for decimal <-> string conversions, including +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +-- +2.5.0 + diff --git a/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..6fd360a5 --- /dev/null +++ b/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,65 @@ +From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index 1606f0d..d81215f 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[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]*/ + +@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { + {NULL} + }; + +-PyTypeObject OverlappedType = { ++PyTypeObject WinApiOverlappedType = { + PyVarObject_HEAD_INIT(NULL, 0) + /* tp_name */ "_winapi.Overlapped", + /* tp_basicsize */ sizeof(OverlappedObject), +@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) + { + OverlappedObject *self; + +- self = PyObject_New(OverlappedObject, &OverlappedType); ++ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); + if (!self) + return NULL; + self->handle = handle; +@@ -1537,7 +1537,7 @@ PyInit__winapi(void) + PyObject *d; + PyObject *m; + +- if (PyType_Ready(&OverlappedType) < 0) ++ if (PyType_Ready(&WinApiOverlappedType) < 0) + return NULL; + + m = PyModule_Create(&winapi_module); +@@ -1545,7 +1545,7 @@ PyInit__winapi(void) + 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); +-- +2.5.0 + diff --git a/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..d00d4bc8 --- /dev/null +++ b/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,46 @@ +From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index 328ab92..5812bcd 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -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 ++static inline int + mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords) + { + assert(!mpd_isconst_data(result)); /* illegal operation for a const */ + +-- +2.5.0 + diff --git a/patches/3.10/README.rst b/patches/3.10/README.rst new file mode 100644 index 00000000..783b640a --- /dev/null +++ b/patches/3.10/README.rst @@ -0,0 +1,8 @@ +* ``0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. From 6750c8c4dd9800e056d4e0aed601b71e3e7d9427 Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Sat, 22 Feb 2025 23:18:15 +0400 Subject: [PATCH 19/22] Fix 3.10 patches --- ...t-include-of-io.h-found-in-libmpdec-.patch | 22 +++---- ...ed-OverlappedType-symbols-with-built.patch | 58 ++++++------------- ...-inlined-functions-to-support-extens.patch | 15 +++-- 3 files changed, 33 insertions(+), 62 deletions(-) diff --git a/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch index 403c9255..e3f7d826 100644 --- a/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch +++ b/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -1,4 +1,4 @@ -From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001 +From 046dc697f49f13443cd9c4f7ddc76ba277c799d4 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 6 Nov 2017 21:44:29 -0500 Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec @@ -8,28 +8,22 @@ This commit improves support for building python with built-in extensions on windows where the header provided by libmpdec would be included instead of the system one. --- - Modules/_decimal/libmpdec/io.c | 2 +- - Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 - 2 files changed, 1 insertion(+), 1 deletion(-) - rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + Modules/_decimal/libmpdec/io.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c -index 3aadfb0..1cc719a 100644 +index e7bd6ae..ecebe82 100644 --- a/Modules/_decimal/libmpdec/io.c +++ b/Modules/_decimal/libmpdec/io.c -@@ -38,7 +38,7 @@ +@@ -37,7 +37,7 @@ + #include #include - #include "typearith.h" -#include "io.h" +#include "mpd_io.h" + #include "typearith.h" - /* This file contains functions for decimal <-> string conversions, including -diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h -similarity index 100% -rename from Modules/_decimal/libmpdec/io.h -rename to Modules/_decimal/libmpdec/mpd_io.h -- -2.5.0 +2.47.2 diff --git a/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch index 6fd360a5..90346086 100644 --- a/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch +++ b/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -1,4 +1,4 @@ -From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001 +From edf0fce3fd17e5823a8db463e2404993ee2a3de7 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 6 Nov 2017 10:37:50 -0500 Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in @@ -8,14 +8,15 @@ This commit improves support for building python with built-in extensions on windows where the symbol from overlapped.c would clash with the one from _winapi.c --- - Modules/_winapi.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) + Modules/_winapi.c | 2 +- + Modules/overlapped.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_winapi.c b/Modules/_winapi.c -index 1606f0d..d81215f 100644 +index f6bb07f..5164899 100644 --- a/Modules/_winapi.c +++ b/Modules/_winapi.c -@@ -147,7 +147,7 @@ overlapped_dealloc(OverlappedObject *self) +@@ -175,7 +175,7 @@ overlapped_dealloc(OverlappedObject *self) /*[clinic input] module _winapi @@ -24,42 +25,19 @@ index 1606f0d..d81215f 100644 [clinic start generated code]*/ /*[clinic end generated code: output=da39a3ee5e6b4b0d input=c13d3f5fd1dabb84]*/ -@@ -295,7 +295,7 @@ static PyMemberDef overlapped_members[] = { - {NULL} - }; +diff --git a/Modules/overlapped.c b/Modules/overlapped.c +index b9ca86c..ae0d96c 100644 +--- a/Modules/overlapped.c ++++ b/Modules/overlapped.c +@@ -62,7 +62,7 @@ class BOOL_converter(CConverter): --PyTypeObject OverlappedType = { -+PyTypeObject WinApiOverlappedType = { - PyVarObject_HEAD_INIT(NULL, 0) - /* tp_name */ "_winapi.Overlapped", - /* tp_basicsize */ sizeof(OverlappedObject), -@@ -341,7 +341,7 @@ new_overlapped(HANDLE handle) - { - OverlappedObject *self; - -- self = PyObject_New(OverlappedObject, &OverlappedType); -+ self = PyObject_New(OverlappedObject, &WinApiOverlappedType); - if (!self) - return NULL; - self->handle = handle; -@@ -1537,7 +1537,7 @@ PyInit__winapi(void) - PyObject *d; - PyObject *m; - -- if (PyType_Ready(&OverlappedType) < 0) -+ if (PyType_Ready(&WinApiOverlappedType) < 0) - return NULL; - - m = PyModule_Create(&winapi_module); -@@ -1545,7 +1545,7 @@ PyInit__winapi(void) - return NULL; - d = PyModule_GetDict(m); - -- PyDict_SetItemString(d, "Overlapped", (PyObject *) &OverlappedType); -+ PyDict_SetItemString(d, "Overlapped", (PyObject *) &WinApiOverlappedType); + /*[clinic input] + module _overlapped +-class _overlapped.Overlapped "OverlappedObject *" "&OverlappedType" ++class _overlapped.Overlapped "OverlappedObject *" "&WinApiOverlappedType" + [clinic start generated code]*/ + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=92e5a799db35b96c]*/ - /* constants */ - WINAPI_CONSTANT(F_DWORD, CREATE_NEW_CONSOLE); -- -2.5.0 +2.47.2 diff --git a/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch index d00d4bc8..e50ffec9 100644 --- a/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch +++ b/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -1,4 +1,4 @@ -From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001 +From cb3cc08e5a1cf54d0d348d1597c828d85bdbef88 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 6 Nov 2017 11:27:32 -0500 Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension @@ -15,11 +15,11 @@ with CMakeBuild\libpython\_freeze_importlib.vcxproj: 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string --- - Modules/_decimal/libmpdec/mpdecimal.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Modules/_decimal/libmpdec/mpdecimal.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c -index 328ab92..5812bcd 100644 +index f1626df..1dbc85b 100644 --- a/Modules/_decimal/libmpdec/mpdecimal.c +++ b/Modules/_decimal/libmpdec/mpdecimal.c @@ -63,7 +63,7 @@ @@ -28,10 +28,10 @@ index 328ab92..5812bcd 100644 #if defined(_MSC_VER) - #define ALWAYS_INLINE __forceinline + #define ALWAYS_INLINE extern __forceinline - #elif defined(__IBMC__) || defined(LEGACY_COMPILER) + #elif defined (__IBMC__) || defined(LEGACY_COMPILER) #define ALWAYS_INLINE #undef inline -@@ -517,7 +517,7 @@ +@@ -517,7 +517,7 @@ mpd_qresize(mpd_t *result, mpd_ssize_t nwords, uint32_t *status) } /* Same as mpd_qresize, but do not set the result no NaN on failure. */ @@ -40,7 +40,6 @@ index 328ab92..5812bcd 100644 mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords) { assert(!mpd_isconst_data(result)); /* illegal operation for a const */ - -- -2.5.0 +2.47.2 From bc5207eef2cacb4d03d8b379eb76b387ae1da00f Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Sat, 22 Feb 2025 23:29:08 +0400 Subject: [PATCH 20/22] Fix 3.10 patches again --- ...ncorrect-include-of-io.h-found-in-libmpdec-.patch | 12 +++++++++--- ...uplicated-OverlappedType-symbols-with-built.patch | 2 +- ...-Export-inlined-functions-to-support-extens.patch | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch index e3f7d826..4071d4c8 100644 --- a/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch +++ b/patches/3.10/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -1,4 +1,4 @@ -From 046dc697f49f13443cd9c4f7ddc76ba277c799d4 Mon Sep 17 00:00:00 2001 +From 3c373cfd1c38b0ab69f5f268dc67cf45ae8933b1 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 6 Nov 2017 21:44:29 -0500 Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec @@ -8,8 +8,10 @@ This commit improves support for building python with built-in extensions on windows where the header provided by libmpdec would be included instead of the system one. --- - Modules/_decimal/libmpdec/io.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c index e7bd6ae..ecebe82 100644 @@ -24,6 +26,10 @@ index e7bd6ae..ecebe82 100644 #include "typearith.h" +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h -- 2.47.2 diff --git a/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch index 90346086..7e20b4a9 100644 --- a/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch +++ b/patches/3.10/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -1,4 +1,4 @@ -From edf0fce3fd17e5823a8db463e2404993ee2a3de7 Mon Sep 17 00:00:00 2001 +From de2c387f6734745b5b5d0df0ee9291c2821174a9 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 6 Nov 2017 10:37:50 -0500 Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in diff --git a/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch index e50ffec9..51da2779 100644 --- a/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch +++ b/patches/3.10/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -1,4 +1,4 @@ -From cb3cc08e5a1cf54d0d348d1597c828d85bdbef88 Mon Sep 17 00:00:00 2001 +From f5f464c478f754a8f25c7fa4ddf37e7b41540885 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Mon, 6 Nov 2017 11:27:32 -0500 Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension From 959dc2819f3b062b7530978db4cd54718aff5d16 Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Sun, 23 Feb 2025 16:40:57 +0400 Subject: [PATCH 21/22] Copy patches 3.11 --- ...t-include-of-io.h-found-in-libmpdec-.patch | 35 +++++++++++++++ ...ed-OverlappedType-symbols-with-built.patch | 43 ++++++++++++++++++ ...-inlined-functions-to-support-extens.patch | 45 +++++++++++++++++++ patches/3.11/README.rst | 8 ++++ 4 files changed, 131 insertions(+) create mode 100644 patches/3.11/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch create mode 100644 patches/3.11/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch create mode 100644 patches/3.11/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch diff --git a/patches/3.11/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch b/patches/3.11/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch new file mode 100644 index 00000000..4071d4c8 --- /dev/null +++ b/patches/3.11/0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch @@ -0,0 +1,35 @@ +From 3c373cfd1c38b0ab69f5f268dc67cf45ae8933b1 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 21:44:29 -0500 +Subject: [PATCH 1/3] Prevent incorrect include of "io.h" found in libmpdec + directory + +This commit improves support for building python with built-in extensions +on windows where the header provided by libmpdec would be included instead +of the system one. +--- + Modules/_decimal/libmpdec/io.c | 2 +- + Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%) + +diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c +index e7bd6ae..ecebe82 100644 +--- a/Modules/_decimal/libmpdec/io.c ++++ b/Modules/_decimal/libmpdec/io.c +@@ -37,7 +37,7 @@ + #include + #include + +-#include "io.h" ++#include "mpd_io.h" + #include "typearith.h" + + +diff --git a/Modules/_decimal/libmpdec/io.h b/Modules/_decimal/libmpdec/mpd_io.h +similarity index 100% +rename from Modules/_decimal/libmpdec/io.h +rename to Modules/_decimal/libmpdec/mpd_io.h +-- +2.47.2 + diff --git a/patches/3.11/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch b/patches/3.11/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch new file mode 100644 index 00000000..7e20b4a9 --- /dev/null +++ b/patches/3.11/0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch @@ -0,0 +1,43 @@ +From de2c387f6734745b5b5d0df0ee9291c2821174a9 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 10:37:50 -0500 +Subject: [PATCH 2/3] Prevent duplicated OverlappedType symbols with built-in + extension on windows + +This commit improves support for building python with built-in extensions +on windows where the symbol from overlapped.c would clash with the one +from _winapi.c +--- + Modules/_winapi.c | 2 +- + Modules/overlapped.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Modules/_winapi.c b/Modules/_winapi.c +index f6bb07f..5164899 100644 +--- a/Modules/_winapi.c ++++ b/Modules/_winapi.c +@@ -175,7 +175,7 @@ overlapped_dealloc(OverlappedObject *self) + + /*[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]*/ + +diff --git a/Modules/overlapped.c b/Modules/overlapped.c +index b9ca86c..ae0d96c 100644 +--- a/Modules/overlapped.c ++++ b/Modules/overlapped.c +@@ -62,7 +62,7 @@ class BOOL_converter(CConverter): + + /*[clinic input] + module _overlapped +-class _overlapped.Overlapped "OverlappedObject *" "&OverlappedType" ++class _overlapped.Overlapped "OverlappedObject *" "&WinApiOverlappedType" + [clinic start generated code]*/ + /*[clinic end generated code: output=da39a3ee5e6b4b0d input=92e5a799db35b96c]*/ + +-- +2.47.2 + diff --git a/patches/3.11/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch b/patches/3.11/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch new file mode 100644 index 00000000..51da2779 --- /dev/null +++ b/patches/3.11/0003-mpdecimal-Export-inlined-functions-to-support-extens.patch @@ -0,0 +1,45 @@ +From f5f464c478f754a8f25c7fa4ddf37e7b41540885 Mon Sep 17 00:00:00 2001 +From: Jean-Christophe Fillion-Robin +Date: Mon, 6 Nov 2017 11:27:32 -0500 +Subject: [PATCH 3/3] mpdecimal: Export inlined functions to support extension + built-in on windows + +This commit ensures that symbols are available when building _freeze_importlib +with all extensions built-in on windows. + +It addresses the following link error associated +with CMakeBuild\libpython\_freeze_importlib.vcxproj: + + 3>_decimal.obj : error LNK2019: unresolved external symbol _mpd_del referenced in function _PyDec_AsTuple + 3>io.obj : error LNK2001: unresolved external symbol _mpd_del + 3>basearith.obj : error LNK2019: unresolved external symbol _mpd_uint_zero referenced in function __mpd_baseshiftl + 3>io.obj : error LNK2019: unresolved external symbol _mpd_qresize referenced in function _mpd_qset_string +--- + Modules/_decimal/libmpdec/mpdecimal.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c +index f1626df..1dbc85b 100644 +--- a/Modules/_decimal/libmpdec/mpdecimal.c ++++ b/Modules/_decimal/libmpdec/mpdecimal.c +@@ -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 @@ mpd_qresize(mpd_t *result, mpd_ssize_t nwords, uint32_t *status) + } + + /* Same as mpd_qresize, but do not set the result no NaN on failure. */ +-static ALWAYS_INLINE int ++static inline int + mpd_qresize_cxx(mpd_t *result, mpd_ssize_t nwords) + { + assert(!mpd_isconst_data(result)); /* illegal operation for a const */ +-- +2.47.2 + diff --git a/patches/3.11/README.rst b/patches/3.11/README.rst index 5aea2bea..7be318eb 100644 --- a/patches/3.11/README.rst +++ b/patches/3.11/README.rst @@ -1 +1,9 @@ * ``0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch``: _bootstrap_python: Fix execution on windows disabling site import. +* ``0001-Prevent-incorrect-include-of-io.h-found-in-libmpdec-.patch``: Rename header files found in + ``Modules/_decimal/libmpdec`` directory to avoid conflicts with system headers of the same name. + +* ``0002-Prevent-duplicated-OverlappedType-symbols-with-built.patch``: Prevent duplicated OverlappedType + symbols with built-in extension on Windows. + +* ``0003-mpdecimal-Export-inlined-functions-to-support-extens.patch``: Export inlined functions to + support extension built-in on Windows. From dbf1fc5c32ec820505707e2decc8e795efd0376b Mon Sep 17 00:00:00 2001 From: O01eg <397177+o01eg@users.noreply.github.com> Date: Sun, 3 May 2026 11:28:19 +0400 Subject: [PATCH 22/22] Fix Windows build --- cmake/extensions/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/extensions/CMakeLists.txt b/cmake/extensions/CMakeLists.txt index 10f3245d..c5d74b19 100644 --- a/cmake/extensions/CMakeLists.txt +++ b/cmake/extensions/CMakeLists.txt @@ -373,7 +373,7 @@ add_python_extension(_xxtestfuzz _xxtestfuzz/fuzzer.c ) -if (NOT ANDROID) +if (NOT ANDROID AND NOT WIN32) # Python 3.8 set(_wide_char_modifier "L") add_python_extension(_testinternalcapi