This commit is contained in:
2026-02-28 14:40:03 +08:00
parent 6a80e6c76b
commit 6ceef5119d
58 changed files with 13236 additions and 0 deletions
+217
View File
@@ -0,0 +1,217 @@
version: 2.1
orbs:
win: circleci/windows@2.4
jobs:
build-test-python:
parameters:
python_version:
description: "Python version specified as X.Y.Z"
type: string
python_arch:
description: "Python arch specified as x64 or x86"
type: string
working_directory: /work
docker:
- image: dockcross/linux-<< parameters.python_arch >>
steps:
- checkout
- run:
name: Install Dependencies
command: |
sudo apt-get update
sudo apt-get install -y \
libbz2-dev \
libdb-dev \
libffi-dev \
libgdbm-compat-dev \
libgdbm-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
tcl-dev \
tk-dev
- run:
name: download dashboard scripts
command: |
git clone git@github.com:python-cmake-buildsystem/python-cmake-buildsystem --branch dashboard --depth 1 scripts
- run:
name: build and test
command: |
set -e
ctest --timeout 360 -S /work/scripts/circle_dashboard.cmake -VV
environment:
PY_VERSION: << parameters.python_version >>
build-test-python-win:
parameters:
python_version:
description: "Python version specified as X.Y.Z"
type: string
python_arch:
description: "Python arch specified as x64 or Win32"
type: string
generator:
description: "CMake generator"
type: string
executor:
name: win/default
shell: powershell.exe
working_directory: C:/Users/circleci/project/src
steps:
- checkout
- run:
name: Install dependencies
command: |
choco install --no-progress cmake
if (-not $?) { throw "Failed to install CMake" }
- run:
name: download dashboard scripts
command: |
git clone git@github.com:python-cmake-buildsystem/python-cmake-buildsystem --branch dashboard --depth 1 ../scripts
- run:
name: build and test
command: |
$Env:PATH += ";C:\Program Files\CMake\bin"
ctest -C $Env:CONFIGURATION -S C:/Users/circleci/project/scripts/circle_win_dashboard.cmake -VV
environment:
PY_VERSION: << parameters.python_version >>
CONFIGURATION: Release
GENERATOR: << parameters.generator >>
PLATFORM: << parameters.python_arch >>
workflows:
build-and-test:
jobs:
# 3.12.10
- build-test-python:
name: python-3.12.10-x64
python_version: 3.12.10
python_arch: x64
- build-test-python:
name: python-3.12.10-x86
python_version: 3.12.10
python_arch: x86
# 3.11.12
- build-test-python:
name: python-3.11.12-x64
python_version: 3.11.12
python_arch: x64
- build-test-python:
name: python-3.11.12-x86
python_version: 3.11.12
python_arch: x86
# 3.10.17
- build-test-python:
name: python-3.10.17-x64
python_version: 3.10.17
python_arch: x64
- build-test-python:
name: python-3.10.17-x86
python_version: 3.10.17
python_arch: x86
# 3.9.22
- build-test-python:
name: python-3.9.22-x64
python_version: 3.9.22
python_arch: x64
- build-test-python:
name: python-3.9.22-x86
python_version: 3.9.22
python_arch: x86
# 3.8.20
- build-test-python:
name: python-3.8.20-x64
python_version: 3.8.20
python_arch: x64
- build-test-python:
name: python-3.8.20-x86
python_version: 3.8.20
python_arch: x86
# 3.7.17
- build-test-python:
name: python-3.7.17-x64
python_version: 3.7.17
python_arch: x64
- build-test-python:
name: python-3.7.17-x86
python_version: 3.7.17
python_arch: x86
# 3.6.15
- build-test-python:
name: python-3.6.15-x64
python_version: 3.6.15
python_arch: x64
- build-test-python:
name: python-3.6.15-x86
python_version: 3.6.15
python_arch: x86
build-and-test-win:
jobs:
# 3.12.10
- build-test-python-win:
name: python-3.12.10-win-x64
python_version: 3.12.10
python_arch: x64
generator: "Visual Studio 16 2019"
# 3.11.12
- build-test-python-win:
name: python-3.11.12-win-x64
python_version: 3.11.12
python_arch: x64
generator: "Visual Studio 16 2019"
# 3.10.17
- build-test-python-win:
name: python-3.10.17-win-x64
python_version: 3.10.17
python_arch: x64
generator: "Visual Studio 16 2019"
# 3.9.22
- build-test-python-win:
name: python-3.9.22-win-x64
python_version: 3.9.22
python_arch: x64
generator: "Visual Studio 16 2019"
# 3.8.20
- build-test-python-win:
name: python-3.8.20-win-x64
python_version: 3.8.20
python_arch: x64
generator: "Visual Studio 16 2019"
# 3.7.17
- build-test-python-win:
name: python-3.7.17-win-x64
python_version: 3.7.17
python_arch: x64
generator: "Visual Studio 16 2019"
# 3.6.15
- build-test-python-win:
name: python-3.6.15-win-x64
python_version: 3.6.15
python_arch: x64
generator: "Visual Studio 16 2019"
+27
View File
@@ -0,0 +1,27 @@
#
# This file lists revisions that should be ignored when considering
# attribution for the actual code written. Code style changes should
# not be considered as modifications with regards to attribution.
#
# To see clean and meaningful blame information.
# $ git blame important.py --ignore-revs-file .git-blame-ignore-revs
#
# To configure git to automatically ignore revisions listed in a file on every call to git blame.
# $ git config blame.ignoreRevsFile .git-blame-ignore-revs
#
# Ignore changes introduced when doing global file format changes
# style: Strip trailing spaces from CMake files
69065ad9923a96440d4542ca31ade487fd5d386b
# style: Indent add_python_extension parameters anticipating updates
c978a31af114d512fd30c974f6f4137f5982336d
# style: Indent add_python_extension parameters anticipating updates
12eb75b97df18c28af676503976969eda768d098
# style: Indent add_python_extension parameters anticipating updates
08bf81fe995484092de5d40ca528de377d18c17f
# style: Dedent extension inclusion anticipating use of IS_PY variable
568146eb073f4ba9c4304dd7b510a17cb53c91f5
# style: Indent parameter associated with python3 dll anticipating updates
bb0eb202b170b97003e4b3636e982408fed65fb2
# style: Indent add_python_extension parameters anticipating updates
6708b3e446189164badfe465bb8df7447a96a0ff
+1
View File
@@ -0,0 +1 @@
*.patch text eol=lf
+9
View File
@@ -0,0 +1,9 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
+74
View File
@@ -0,0 +1,74 @@
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
tests:
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: [macos-latest]
python-version: [3.7.17, 3.8.20, 3.9.22, 3.10.17, 3.11.12, 3.12.10]
include:
- runs-on: macos-latest
c-compiler: "clang"
cxx-compiler: "clang++"
initial-dashboard-cache: "CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.13"
name: python-${{ matrix.python-version }}-${{ matrix.runs-on }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
path: src
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@3a6cbe35ba64df7ca70c51365c4aff65db9a9037 # v2.1.1
with:
cmake-version: 3.20.6
- name: Setup ninja
uses: ashutoshvarma/setup-ninja@66ad2db9ed7d211c065daeeb849e9c8c895773c9 # master
with:
version: 1.10.0
- name: Download dashboard script
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: 'python-cmake-buildsystem/python-cmake-buildsystem'
ref: dashboard
fetch-depth: 0
path: scripts
- name: Writing initial dashboard cache
shell: bash
run: |
cat > scripts/initial-dashboard-cache.txt << EOF
${{ matrix.initial-dashboard-cache }}
EOF
cat scripts/initial-dashboard-cache.txt
- name: Build & Test
run: ctest --timeout 360 -S scripts/github_actions_dashboard.cmake -VV
env:
PY_VERSION: ${{ matrix.python-version }}
CC: ${{ matrix.c-compiler }}
CXX: ${{ matrix.cxx-compiler }}
pass: # This job does nothing and is only used for the branch protection
if: always()
needs:
- tests
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@2765efec08f0fd63e83ad900f5fd75646be69ff6 # v1.2.2
with:
jobs: ${{ toJSON(needs) }}
+45
View File
@@ -0,0 +1,45 @@
# Ignore in source build files and directories ...
/cmake_install.cmake
/CMakeBuild
/CMakeCache.txt
/CMakeFiles
/CTestTestfile.cmake
/DartConfiguration.tcl
/install_manifest.txt
Makefile
/bin
/lib
/Misc/
/share/
# Ignore all dotfiles...
.*
!.git-blame-ignore-revs
!.gitattributes
!.circleci
!.github/
# Ignore all back-up files...
*~
*.bak
# except for .gitignore
!.gitignore
# Exclude QtCreator files
CMakeLists.txt.user*
# Ignore ctags file
tags
# Ignore pyc files
*.pyc
# Ignore Python source directories
cython-*/
Python-*/
# Ignore Python source archives
Python-*.tgz
Python-*.zip
+939
View File
@@ -0,0 +1,939 @@
cmake_minimum_required(VERSION 3.20.6)
set(PYTHON_VERSION "3.12.10" CACHE STRING "The version of Python to build.")
string(REPLACE "." ";" VERSION_LIST ${PYTHON_VERSION})
list(GET VERSION_LIST 0 PY_VERSION_MAJOR)
list(GET VERSION_LIST 1 PY_VERSION_MINOR)
list(GET VERSION_LIST 2 PY_VERSION_PATCH)
set(PY_VERSION "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.${PY_VERSION_PATCH}")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "Release configuration" FORCE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release")
endif()
if(APPLE)
set(_msg "Checking which MACOSX_DEPLOYMENT_TARGET to use")
message(STATUS "${_msg}")
include(cmake/PythonAutoDetectOSX.cmake)
set(MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
message(STATUS "${_msg} - ${MACOSX_DEPLOYMENT_TARGET}")
endif()
project(Python C ASM)
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH "")
endif()
if(NOT DEFINED CMAKE_BUILD_WITH_INSTALL_NAME_DIR)
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
endif()
# Include helper functions
include(cmake/Extensions.cmake)
include(CMakeDependentOption)
include(CMakeParseArguments)
include(CTest)
# Options
option(DOWNLOAD_SOURCES "Automatically download the Python sources" ON)
set(_build_libpython_shared_default 0)
set(_build_libpython_shared_desc "Build libpython as a shared library")
if(DEFINED BUILD_SHARED OR DEFINED BUILD_STATIC)
message(AUTHOR_WARNING "Deprecated options `BUILD_SHARED` or `BUILD_STATIC` are set, "
"please change configure options to use `BUILD_LIBPYTHON_SHARED` instead.")
if(BUILD_SHARED AND BUILD_STATIC)
message(AUTHOR_WARNING "Both BUILD_SHARED and BUILD_STATIC options are set to ON. Forcing BUILD_SHARED to OFF")
endif()
if(BUILD_STATIC)
set(_build_libpython_shared_default 0)
set(_build_libpython_shared_desc "Intialized from `BUILD_STATIC` (deprecated)")
elseif(BUILD_SHARED)
set(_build_libpython_shared_default 1)
set(_build_libpython_shared_desc "Intialized from `BUILD_SHARED` (deprecated)")
endif()
message(AUTHOR_WARNING "Unsetting cache variables BUILD_SHARED and BUILD_STATIC")
unset(BUILD_SHARED CACHE)
unset(BUILD_STATIC CACHE)
endif()
option(BUILD_LIBPYTHON_SHARED ${_build_libpython_shared_desc} ${_build_libpython_shared_default})
option(BUILD_EXTENSIONS_AS_BUILTIN "Default all modules as builtin to libpython" OFF)
option(USE_LIB64 "Search for dependencies and install to prefix/lib64 instead of prefix/lib" OFF)
if(WIN32)
option(INSTALL_WINDOWS_TRADITIONAL "Install the executable and extensions in the traditional location" OFF)
else()
set(INSTALL_WINDOWS_TRADITIONAL OFF)
endif()
if(WIN32 AND PY_VERSION VERSION_GREATER_EQUAL "3.10")
if(DEFINED BUILD_WININST)
message(AUTHOR_WARNING "BUILD_WININST option is *NOT* supported with Python >= 3.10. Current version is ${PY_VERSION}")
message(AUTHOR_WARNING "Unsetting cache variable BUILD_WININST")
unset(BUILD_WININST CACHE)
endif()
if(DEFINED BUILD_WININST_ALWAYS)
message(AUTHOR_WARNING "BUILD_WININST_ALWAYS option is *NOT* supported with Python >= 3.10. Current version is ${PY_VERSION}")
message(AUTHOR_WARNING "Unsetting cache variable BUILD_WININST_ALWAYS")
unset(BUILD_WININST_ALWAYS CACHE)
endif()
endif()
if(WIN32 AND PY_VERSION VERSION_LESS "3.10")
set(_build_wininst_default ON)
if(CMAKE_CROSSCOMPILING)
set(_build_wininst_default OFF)
endif()
option(BUILD_WININST "Build 'Windows Installer' program for distutils if not already provided in the source tree." ${_build_wininst_default})
cmake_dependent_option(BUILD_WININST_ALWAYS "Always build 'Windows installer' program even if provided in the source tree." OFF "BUILD_WININST" OFF)
else()
set(BUILD_WININST OFF)
set(BUILD_WININST_ALWAYS 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)
# Append an item to a string if it does not already contain it. Any additional
# arguments are treated as extra "set" arguments
macro(append_if_absent VARNAME VALUE)
if(NOT ${VARNAME} MATCHES "(^| )${VALUE}($| )")
if(${VARNAME})
set(${VARNAME} "${${VARNAME}} ${VALUE}" ${ARGN})
else()
set(${VARNAME} "${VALUE}" ${ARGN})
endif()
endif()
endmacro()
option(USE_SYSTEM_LIBRARIES "Use system libraries" ON)
# Set platform dependent defaults
set(_use_builtin_zlib_default OFF)
set(_use_system_zlib_default ON)
if(WIN32 AND "${PY_VERSION}" VERSION_LESS "3.7.0")
set(_use_builtin_zlib_default ON)
set(_use_system_zlib_default OFF)
endif()
cmake_dependent_option(USE_SYSTEM_BZip2 "Use system BZip2" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_Curses "Use system Curses" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_EXPAT "Use system EXPAT" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_LibFFI "Use system LibFFI" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_OpenSSL "Use system OpenSSL" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_TCL "Use system TCL" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_ZLIB "Use system ZLIB" ${_use_system_zlib_default} "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_GDBM "Use system GDBM" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_READLINE "Use system READLINE" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_SQLite3 "Use system SQLITE3" ON "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_SYSTEM_LIBMPDEC "Use system LIBMPDEC" OFF "USE_SYSTEM_LIBRARIES" OFF)
cmake_dependent_option(USE_BUILTIN_ZLIB "Use builtin ZLIB" ${_use_builtin_zlib_default} "NOT USE_SYSTEM_ZLIB" OFF)
option(USE_LIBEDIT "Use libedit instead of readline" OFF)
option(WITH_TSC "profile with the Pentium timestamp counter" OFF)
option(ENABLE_IPV6 "Enable IP v6" ON)
option(WITH_DOC_STRINGS "Enable if you want documentation strings in extension modules" ON)
set(Py_DEBUG OFF) # TODO - Build debugging interpreter
option(WITH_PYMALLOC "Define if you want to compile in Python-specific mallocs" ON)
if(UNIX)
option(WITH_STATIC_DEPENDENCIES "Restrict extensions and external dependencies to static libraries" OFF)
if(WITH_STATIC_DEPENDENCIES)
set(_reason " because of WITH_STATIC_DEPENDENCIES=ON")
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
message(STATUS "Setting CMAKE_FIND_LIBRARY_SUFFIXES to \"${CMAKE_STATIC_LIBRARY_SUFFIX}\"${_reason}")
set(BUILD_EXTENSIONS_AS_BUILTIN ON CACHE BOOL "Forced to ON${_reason}" FORCE)
message(STATUS "Setting BUILD_EXTENSIONS_AS_BUILTIN to ON${_reason}")
set(BUILD_LIBPYTHON_SHARED OFF CACHE BOOL "Forced to OFF${_reason}" FORCE)
message(STATUS "Setting BUILD_LIBPYTHON_SHARED to OFF${_reason}")
append_if_absent(CMAKE_EXE_LINKER_FLAGS "-static")
message(STATUS "Appending -static to CMAKE_EXE_LINKER_FLAGS${_reason}")
endif()
else()
set(WITH_STATIC_DEPENDENCIES 0)
endif()
# Detect source directory
set(_landmark "pyconfig.h.in") # CMake will look for this file.
if(NOT (SRC_DIR AND EXISTS ${SRC_DIR}/${_landmark}))
foreach(dirname
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cpython-${PY_VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/Python-${PY_VERSION}
${CMAKE_CURRENT_BINARY_DIR}/../cpython-${PY_VERSION}
${CMAKE_CURRENT_BINARY_DIR}/../Python-${PY_VERSION})
set(SRC_DIR ${dirname})
if(EXISTS ${SRC_DIR}/${_landmark})
break()
endif()
endforeach()
endif()
# Download sources
get_filename_component(_parent_dir ${CMAKE_CURRENT_BINARY_DIR} PATH)
string(REGEX REPLACE "[a-z]+[1-9]$" "" _py_version_patch_no_rc ${PY_VERSION_PATCH})
set(_py_version_no_rc "${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}.${_py_version_patch_no_rc}")
set(_download_link "https://www.python.org/ftp/python/${_py_version_no_rc}/Python-${PY_VERSION}.tgz")
# Variable below represent the set of available python version.
# 3.5.x
set(_download_3.5.1_md5 "be78e48cdfc1a7ad90efff146dce6cfe")
set(_download_3.5.2_md5 "3fe8434643a78630c61c6464fe2e7e72")
set(_download_3.5.3_md5 "6192f0e45f02575590760e68c621a488")
set(_download_3.5.4_md5 "2ed4802b7a2a7e40d2e797272bf388ec")
set(_download_3.5.5_md5 "7c825b747d25c11e669e99b912398585")
set(_download_3.5.6_md5 "99a7e803633a627b264a42ce976d8c19")
set(_download_3.5.7_md5 "92f4c16c55429bf986f5ab45fe3a6659")
set(_download_3.5.8_md5 "c52ac1fc37e5daebb08069ea0e27d293")
set(_download_3.5.9_md5 "5a58675043bde569d235f41dadeada42")
set(_download_3.5.10_md5 "01a2d18075243bef5ef3363f62bf3247")
# 3.6.x
set(_download_3.6.0_md5 "3f7062ccf8be76491884d0e47ac8b251")
set(_download_3.6.1_md5 "2d0fc9f3a5940707590e07f03ecb08b9")
set(_download_3.6.2_md5 "e1a36bfffdd1d3a780b1825daf16e56c")
set(_download_3.6.3_md5 "e9180c69ed9a878a4a8a3ab221e32fa9")
set(_download_3.6.4_md5 "9de6494314ea199e3633211696735f65")
set(_download_3.6.5_md5 "ab25d24b1f8cc4990ade979f6dc37883")
set(_download_3.6.6_md5 "9a080a86e1a8d85e45eee4b1cd0a18a2")
set(_download_3.6.7_md5 "c83551d83bf015134b4b2249213f3f85")
set(_download_3.6.8_md5 "48f393a04c2e66c77bfc114e589ec630")
set(_download_3.6.9_md5 "ff7cdaef4846c89c1ec0d7b709bbd54d")
set(_download_3.6.10_md5 "df5f494ef9fbb03a0264d1e9d406aada")
set(_download_3.6.11_md5 "74763db01ec961ff194eea9ccc001a80")
set(_download_3.6.12_md5 "00c3346f314072fcc810d4a51d06f04e")
set(_download_3.6.13_md5 "92fcbf417c691d42c47a3d82f9c255fd")
set(_download_3.6.14_md5 "54a320cffe046bbbe4321896d67bde2b")
set(_download_3.6.15_md5 "f9e6f91c754a604f4fc6f6c7683723fb")
# 3.7.x
set(_download_3.7.0_md5 "41b6595deb4147a1ed517a7d9a580271")
set(_download_3.7.1_md5 "99f78ecbfc766ea449c4d9e7eda19e83")
set(_download_3.7.2_md5 "02a75015f7cd845e27b85192bb0ca4cb")
set(_download_3.7.3_md5 "2ee10f25e3d1b14215d56c3882486fcf")
set(_download_3.7.4_md5 "68111671e5b2db4aef7b9ab01bf0f9be")
set(_download_3.7.5_md5 "1cd071f78ff6d9c7524c95303a3057aa")
set(_download_3.7.6_md5 "3ef90f064506dd85b4b4ab87a7a83d44")
set(_download_3.7.7_md5 "d348d978a5387512fbc7d7d52dd3a5ef")
set(_download_3.7.8_md5 "4d5b16e8c15be38eb0f4b8f04eb68cd0")
set(_download_3.7.9_md5 "bcd9f22cf531efc6f06ca6b9b2919bd4")
set(_download_3.7.10_md5 "0b19e34a6dabc4bf15fdcdf9e77e9856")
set(_download_3.7.11_md5 "a7e66953dba909d395755b3f2e491f6e")
set(_download_3.7.12_md5 "6fe83678c085a7735a943cf1e4d41c14")
set(_download_3.7.13_md5 "e0d3321026d4a5f3a3890b5d821ad762")
set(_download_3.7.14_md5 "dd65d6708e9c28a9e4fd2e986776ad14")
set(_download_3.7.15_md5 "beff0cd66129ad1761632aafd72ac866")
set(_download_3.7.16_md5 "f21656b51c9907fc6993b64ef216d994")
set(_download_3.7.17_md5 "19726591b0fb1a9658de68955fa8392a")
# 3.8.x
set(_download_3.8.0_md5 "e18a9d1a0a6d858b9787e03fc6fdaa20")
set(_download_3.8.1_md5 "f215fa2f55a78de739c1787ec56b2bcd")
set(_download_3.8.2_md5 "f9f3768f757e34b342dbc06b41cbc844")
set(_download_3.8.3_md5 "a7c10a2ac9d62de75a0ca5204e2e7d07")
set(_download_3.8.4_md5 "387e63fe42c40a29e3408ce231315516")
set(_download_3.8.5_md5 "e2f52bcf531c8cc94732c0b6ff933ff0")
set(_download_3.8.6_md5 "ea132d6f449766623eee886966c7d41f")
set(_download_3.8.7_md5 "e1f40f4fc9ccc781fcbf8d4e86c46660")
set(_download_3.8.8_md5 "d3af3b87e134c01c7f054205703adda2")
set(_download_3.8.9_md5 "41a5eaa15818cee7ea59e578564a2629")
set(_download_3.8.10_md5 "83d71c304acab6c678e86e239b42fa7e")
set(_download_3.8.11_md5 "f22ef46ebf8d15d8e495a237277bf2fa")
set(_download_3.8.12_md5 "f7890dd43302daa5fcb7b0254b4d0f33")
set(_download_3.8.13_md5 "3c49180c6b43df3519849b7e390af0b9")
set(_download_3.8.14_md5 "a82168eb586e19122b747b84038825f2")
set(_download_3.8.15_md5 "28b111e1e97a9e5acb62e1d153f188d9")
set(_download_3.8.16_md5 "060040f864f1003b849b33393c9605df")
set(_download_3.8.17_md5 "d3e789ab828016927a122a0ae9b0e6b0")
set(_download_3.8.18_md5 "1c611d70ba4d0ec32da3a364490fc6f4")
set(_download_3.8.19_md5 "5e3188ce73865fa4545d9e3e89bcd26c")
set(_download_3.8.20_md5 "7e0ff9088be5a3c2fd9b7d8b4b632b5e")
# 3.9.x
set(_download_3.9.0_md5 "e19e75ec81dd04de27797bf3f9d918fd")
set(_download_3.9.1_md5 "429ae95d24227f8fa1560684fad6fca7")
set(_download_3.9.2_md5 "8cf053206beeca72c7ee531817dc24c7")
# 3.9.3: This release has been recalled. See https://www.python.org/downloads/release/python-393/
set(_download_3.9.4_md5 "cc8507b3799ed4d8baa7534cd8d5b35f")
set(_download_3.9.5_md5 "364158b3113cf8ac8db7868ce40ebc7b")
set(_download_3.9.6_md5 "798b9d3e866e1906f6e32203c4c560fa")
set(_download_3.9.7_md5 "5f463f30b1fdcb545f156583630318b3")
set(_download_3.9.8_md5 "83419bd73655813223c2cf2afb11f83c")
set(_download_3.9.9_md5 "a2da2a456c078db131734ff62de10ed5")
set(_download_3.9.10_md5 "1440acb71471e2394befdb30b1a958d1")
set(_download_3.9.11_md5 "daca49063ced330eb933a0fb437dee50")
set(_download_3.9.12_md5 "abc7f7f83ea8614800b73c45cf3262d3")
set(_download_3.9.13_md5 "eafda83543bad127cadef4d288fdab87")
set(_download_3.9.14_md5 "324a9dcaaa11b2b0dafe5614e8f01145")
set(_download_3.9.15_md5 "3e13283a5f4e089db508bf81b60a5cca")
set(_download_3.9.16_md5 "38c99c7313f416dcf3238f5cf444c6c2")
set(_download_3.9.17_md5 "ded6379983f364cf790793ca24dcfe3e")
set(_download_3.9.18_md5 "c3a3e67e35838cadca247237a5a279a7")
set(_download_3.9.19_md5 "b4d723903d0a8266b110c3da2f992416")
set(_download_3.9.20_md5 "896c19e5815ba990a3d1261502ea9f83")
set(_download_3.9.21_md5 "e61b3568082b57d55fd74cfc7ca020b4")
set(_download_3.9.22_md5 "8fe76e248a0e149ac23e8e4886397475")
# 3.10.x
set(_download_3.10.0_md5 "729e36388ae9a832b01cf9138921b383")
set(_download_3.10.1_md5 "91822157a97da16203877400c810d93e")
set(_download_3.10.2_md5 "67c92270be6701f4a6fed57c4530139b")
set(_download_3.10.3_md5 "f276ffcd05bccafe46da023d0a5bb04a")
set(_download_3.10.4_md5 "7011fa5e61dc467ac9a98c3d62cfe2be")
set(_download_3.10.5_md5 "d87193c077541e22f892ff1353fac76c")
set(_download_3.10.6_md5 "d76638ca8bf57e44ef0841d2cde557a0")
set(_download_3.10.7_md5 "1aea68575c0e97bc83ff8225977b0d46")
set(_download_3.10.8_md5 "fbe3fff11893916ad1756b15c8a48834")
set(_download_3.10.9_md5 "25eb3686327c157dcb8ac9f01105c306")
set(_download_3.10.10_md5 "6dbe644dd1a520d9853cf6648084c346")
set(_download_3.10.11_md5 "7e25e2f158b1259e271a45a249cb24bb")
set(_download_3.10.12_md5 "1d64320e0b0df6e9ab7e611bacb2178d")
set(_download_3.10.13_md5 "cbcad7f5e759176bf8ce8a5f9d487087")
set(_download_3.10.14_md5 "f67d78c8323a18fe6b945914c51a7aa6")
set(_download_3.10.15_md5 "b6a2b570ea75ef55f50bfe79d778eb01")
set(_download_3.10.16_md5 "2515d8571c6fdd7fc620aa9e1cc6d202")
set(_download_3.10.17_md5 "763324aa2b396ee10a51bfa6c645d8e9")
# 3.11.x
set(_download_3.11.0_md5 "c5f77f1ea256dc5bdb0897eeb4d35bb0")
set(_download_3.11.1_md5 "5c986b2865979b393aa50a31c65b64e8")
set(_download_3.11.2_md5 "f6b5226ccba5ae1ca9376aaba0b0f673")
set(_download_3.11.3_md5 "016ba65bc80411f9ec20c614ab385e81")
set(_download_3.11.4_md5 "bf6ec50f2f3bfa6ffbdb385286f2c628")
set(_download_3.11.5_md5 "b628f21aae5e2c3006a12380905bb640")
set(_download_3.11.6_md5 "ed23dadb9f1b9fd2e4e7d78619685c79")
set(_download_3.11.7_md5 "ef61f81ec82c490484219c7f0ec96783")
set(_download_3.11.8_md5 "7fb0bfaa2f6aae4aadcdb51abe957825")
set(_download_3.11.9_md5 "bfd4d3bfeac4216ce35d7a503bf02d5c")
set(_download_3.11.10_md5 "35c36069a43dd57a7e9915deba0f864e")
set(_download_3.11.11_md5 "9a5b43fcc06810b8ae924b0a080e6569")
set(_download_3.11.12_md5 "b8bb496014f05f5be180fab74810f40b")
# 3.12.x
set(_download_3.12.0_md5 "d6eda3e1399cef5dfde7c4f319b0596c")
set(_download_3.12.1_md5 "51c5c22dcbc698483734dff5c8028606")
set(_download_3.12.2_md5 "4e64a004f8ad9af1a75607cfd0d5a8c8")
set(_download_3.12.3_md5 "3c5498a34d5226c9b746b1199f0bf2d9")
set(_download_3.12.4_md5 "ead819dab6d165937138daa9e51ccb54")
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")
set(_download_3.12.9_md5 "ce613c72fa9b32fb4f109762d61b249b")
set(_download_3.12.10_md5 "35c03f014408e26e2b06d576c19cac54")
set(_extracted_dir "Python-${PY_VERSION}")
if(NOT EXISTS ${SRC_DIR}/${_landmark} AND DOWNLOAD_SOURCES)
get_filename_component(_filename ${_download_link} NAME)
set(_archive_filepath ${CMAKE_CURRENT_BINARY_DIR}/../${_filename})
if(EXISTS "${_archive_filepath}")
message(STATUS "${_filename} already downloaded")
else()
message(STATUS "Downloading ${_download_link}")
if(NOT DEFINED _download_${PY_VERSION}_md5)
message(FATAL_ERROR "Selected PY_VERSION [${PY_VERSION}] is not associated with any checksum. Consider updating this CMakeLists.txt setting _download_${PY_VERSION}_md5 variable")
endif()
file(
DOWNLOAD ${_download_link} ${_archive_filepath}
EXPECTED_MD5 ${_download_${PY_VERSION}_md5}
SHOW_PROGRESS
)
endif()
message(STATUS "Extracting ${_filename}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz ${_archive_filepath}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
RESULT_VARIABLE rv)
if(NOT rv EQUAL 0)
message(FATAL_ERROR "error: extraction of '${_filename}' failed")
endif()
set(SRC_DIR ${CMAKE_CURRENT_BINARY_DIR}/../${_extracted_dir})
endif()
get_filename_component(SRC_DIR "${SRC_DIR}" ABSOLUTE)
if(NOT EXISTS ${SRC_DIR}/${_landmark})
message(FATAL_ERROR "Failed to locate python source.
The searched locations were:
<CMAKE_CURRENT_SOURCE_DIR>
<CMAKE_CURRENT_SOURCE_DIR>/cpython-${PY_VERSION}
<CMAKE_CURRENT_SOURCE_DIR>/Python-${PY_VERSION}
<CMAKE_CURRENT_BINARY_DIR>/../cpython-${PY_VERSION}
<CMAKE_CURRENT_BINARY_DIR>/../Python-${PY_VERSION}
<SRC_DIR>
You could try to:
1) download ${_download_link}
2) extract the archive in folder: ${_parent_dir}
3) Check that file \"${_parent_dir}/${_extracted_dir}/${_landmark}\" exists.
4) re-configure.
If you already downloaded the source, you could try to re-configure this project passing -DSRC_DIR:PATH=/path/to/Python-{PY_VERSION} using cmake or adding an PATH entry named SRC_DIR from cmake-gui.")
endif()
message(STATUS "SRC_DIR: ${SRC_DIR}")
# Extract version string from python source (Copied from FindPythonLibs.cmake)
file(STRINGS "${SRC_DIR}/Include/patchlevel.h" python_version_str
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
PY_VERSION_LONG "${python_version_str}")
# Extract version info and set variables PY_VERSION, PY_VERSION_(MAJOR|MINOR|PATCH), PY_RELEASE_(LEVEL|SERIAL)
include(cmake/PythonExtractVersionInfo.cmake)
python_extract_version_info(
VERSION_STRING "${PY_VERSION_LONG}"
)
message(STATUS "PY_VERSION : ${PY_VERSION}")
message(STATUS "PY_VERSION_LONG: ${PY_VERSION_LONG}")
# Extract "Field3" value and set variable PY_FIELD3_VALUE
python_compute_release_field3_value(
VERSION_PATCH "${PY_VERSION_PATCH}"
RELEASE_LEVEL "${PY_RELEASE_LEVEL}"
RELEASE_SERIAL "${PY_RELEASE_SERIAL}"
)
message(STATUS "PY_FIELD3_VALUE: ${PY_FIELD3_VALUE}")
# Check version
if(NOT DEFINED _download_${PY_VERSION_LONG}_md5)
message(WARNING "warning: selected python version '${PY_VERSION_LONG}' is not tested.")
endif()
if(NOT "${PYTHON_VERSION}" STREQUAL "${PY_VERSION}")
message(STATUS "Overwriting PYTHON_VERSION with value read from 'patchlevel.h': ${PYTHON_VERSION} -> ${PY_VERSION}")
set(PYTHON_VERSION "${PY_VERSION}" CACHE STRING "The version of Python to build." FORCE)
endif()
# Apply patches
option(PYTHON_APPLY_PATCHES "Apply patches" ON)
if(PYTHON_APPLY_PATCHES)
include(cmake/PythonApplyPatches.cmake)
endif()
# Enable CXX language to support building of _distutils_findvs extension
if(WIN32)
enable_language(CXX)
endif()
# Options depending of the python version
if(DEFINED USE_SYSTEM_DB)
message(AUTHOR_WARNING "USE_SYSTEM_DB option is *NOT* supported with Python 3. Current version is ${PY_VERSION}")
endif()
if(DEFINED Py_USING_UNICODE)
message(AUTHOR_WARNING "Py_USING_UNICODE option is *NOT* supported with Python 3. Current version is ${PY_VERSION}")
endif()
if(PY_VERSION VERSION_GREATER_EQUAL "3.7")
option(WITH_C_LOCALE_COERCION "Enable C locale coercion to a UTF-8 based locale" ON)
else()
if(DEFINED WITH_C_LOCALE_COERCION)
message(AUTHOR_WARNING "WITH_C_LOCALE_COERCION option is *NOT* supported with Python < 3.7. Current version is ${PY_VERSION}")
endif()
endif()
# See "Improving performance in Python 2.7" - http://lwn.net/Articles/646888/
option(WITH_COMPUTED_GOTOS "Improve performance enabling the computed goto based dispatch" OFF)
set(USE_COMPUTED_GOTOS ${WITH_COMPUTED_GOTOS})
set(WITH_HASH_ALGORITHM "default" CACHE STRING "Define hash algorithm for str, bytes and memoryview.")
set_property(CACHE WITH_HASH_ALGORITHM PROPERTY STRINGS "default" "siphash24" "fnv")
if(PY_VERSION VERSION_LESS "3.7")
option(WITH_THREAD "Compile in rudimentary thread support" ON)
else()
if(DEFINED WITH_THREAD)
message(AUTHOR_WARNING "WITH_THREAD option is *NOT* supported. Threading is always built-in with Python >= 3.7. Current version is ${PY_VERSION}")
endif()
endif()
if(PY_VERSION VERSION_GREATER_EQUAL "3.10")
option(WITH_VALGRIND "Enable to disable pymalloc when running under valgrind" OFF)
else()
if(DEFINED WITH_VALGRIND)
message(AUTHOR_WARNING "WITH_VALGRIND option is *NOT* supported with Python < 3.10. Current version is ${PY_VERSION}")
endif()
endif()
if(PY_VERSION VERSION_GREATER_EQUAL "3.7")
set(WITH_SSL_DEFAULT_SUITES "python" CACHE STRING "Override default cipher suites string: python, openssl or a custom string")
if("${WITH_SSL_DEFAULT_SUITES}" STREQUAL "python")
set(PY_SSL_DEFAULT_CIPHERS 1)
elseif("${WITH_SSL_DEFAULT_SUITES}" STREQUAL "openssl")
set(PY_SSL_DEFAULT_CIPHERS 2)
else()
set(PY_SSL_DEFAULT_CIPHERS 0)
set(PY_SSL_DEFAULT_CIPHER_STRING "${WITH_SSL_DEFAULT_SUITES}")
endif()
message(STATUS "Setting PY_SSL_DEFAULT_CIPHER_STRING to '${WITH_SSL_DEFAULT_SUITES}'")
endif()
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
option(WITH_DECIMAL_CONTEXTVAR "Build _decimal module using a coroutine-local rather than a thread-local context" ON)
else()
if(DEFINED WITH_DECIMAL_CONTEXTVAR)
message(AUTHOR_WARNING "WITH_DECIMAL_CONTEXTVAR option is *NOT* supported with Python < 3.8. Current version is ${PY_VERSION}")
endif()
endif()
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
option(WITH_TRACE_REFS "Enable tracing references for debugging purpose" OFF)
else()
if(DEFINED WITH_TRACE_REFS)
message(AUTHOR_WARNING "WITH_TRACE_REFS option is *NOT* supported with Python < 3.8. Current version is ${PY_VERSION}")
endif()
endif()
# This is the major version number of Python
set(LIBPYTHON_VERSION ${PY_VERSION_MAJOR}.${PY_VERSION_MINOR})
if(WIN32)
set(LIBPYTHON_VERSION ${PY_VERSION_MAJOR}${PY_VERSION_MINOR})
endif()
set(LIBPYTHON python${LIBPYTHON_VERSION})
# Proceed to the configure checks
include(cmake/ConfigureChecks.cmake)
# Set PYTHONHOME
set(LIBDIR "Lib") # See Lib/distutils/sysconfig.py - function 'get_python_lib'
if(UNIX)
set(LIBDIR "lib")
endif()
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()
# Install tree directory
set(BIN_INSTALL_DIR bin) # Contains the python executable
if(INSTALL_WINDOWS_TRADITIONAL)
set(BIN_INSTALL_DIR .) # Contains the python executable
endif()
set(LD_VERSION ${LIBPYTHON_VERSION}${ABIFLAGS})
set(CONFIG_INSTALL_DIR share/${LIBPYTHON})
set(EXTENSION_INSTALL_DIR ${PYTHONHOME}/lib-dynload)
if (${LIBPYTHON_VERSION} GREATER 3.1)
set(LIB_CONFIG_INSTALL_DIR ${PYTHONHOME}/config-${LD_VERSION})
else()
set(LIB_CONFIG_INSTALL_DIR ${PYTHONHOME}/config)
endif()
if(INSTALL_WINDOWS_TRADITIONAL)
set(EXTENSION_INSTALL_DIR DLLs)
endif()
set(INCLUDE_INSTALL_DIR include/python${LD_VERSION})
if(MSVC)
set(INCLUDE_INSTALL_DIR include)
endif()
# Build tree directory
set(BIN_BUILD_DIR ${PROJECT_BINARY_DIR}/bin)
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)
# Directories specific to 'libpython'
set(LIBPYTHON_LIBDIR ${LIBDIR})
set(LIBPYTHON_ARCHIVEDIR ${LIBDIR})
set(LIBPYTHON_STATIC_ARCHIVEDIR ${LIBDIR})
if(WIN32)
set(LIBPYTHON_LIBDIR ${BIN_INSTALL_DIR})
set(LIBPYTHON_ARCHIVEDIR ${ARCHIVEDIR})
set(LIBPYTHON_STATIC_ARCHIVEDIR static-${ARCHIVEDIR})
endif()
set(EXTRA_PYTHONPATH "" CACHE STRING
"A colon (:) separated list of extra paths to add to the PYTHONPATH")
# Configure 'pyconfig.h'
if(UNIX)
set(PYCONFIG_BUILD_DIR ${BIN_BUILD_DIR})
configure_file(cmake/config-unix/pyconfig.h.in
${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.
# See function '_init_posix()' and '_init_non_posix()'
# in 'Lib/sysconfig.py'
if(MINGW)
set(PYCONFIG_BUILD_DIR cmake/config-mingw)
endif()
endif()
# Install 'pyconfig.h'
if(INSTALL_DEVELOPMENT)
install(FILES ${PYCONFIG_BUILD_DIR}/pyconfig.h
DESTINATION ${INCLUDE_INSTALL_DIR}/
COMPONENT Development)
endif()
# Set include directories
include_directories(${INCLUDE_BUILD_DIR})
include_directories(${INCLUDE_BUILD_DIR}/internal)
include_directories(${PYCONFIG_BUILD_DIR})
include_directories(${SRC_DIR}/Python)
include_directories(${SRC_DIR}) # Introduced in Python 3.11 for "Python/frozen_modules/.h"
# Set cflags used by all components
if(CMAKE_C_COMPILER_ID MATCHES GNU)
if(PY_VERSION VERSION_GREATER_EQUAL "3.11")
append_if_absent(CMAKE_C_FLAGS "-std=c11")
elseif(PY_VERSION VERSION_GREATER_EQUAL "3.6")
append_if_absent(CMAKE_C_FLAGS "-std=c99")
endif()
append_if_absent(CMAKE_C_FLAGS "-Wall")
append_if_absent(CMAKE_C_FLAGS "-Wstrict-prototypes")
append_if_absent(CMAKE_C_FLAGS "-fno-strict-aliasing")
append_if_absent(CMAKE_C_FLAGS "-fwrapv")
append_if_absent(CMAKE_C_FLAGS "-g")
elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
append_if_absent(CMAKE_C_FLAGS "-Wall")
append_if_absent(CMAKE_C_FLAGS "-g")
elseif(CMAKE_C_COMPILER_ID MATCHES Intel)
append_if_absent(CMAKE_C_FLAGS "-Wall")
append_if_absent(CMAKE_C_FLAGS "-no-ansi-alias")
elseif(CMAKE_C_COMPILER_ID MATCHES PGI)
append_if_absent(CMAKE_C_FLAGS "-alias=traditional")
endif()
if(MSVC)
append_if_absent(CMAKE_C_FLAGS "/Zm200")
string(REPLACE "/Ob2" "/Ob1" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) # InlineFunctionExpansion=1
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "Flags used by the compiler during release builds" FORCE)
endif()
# Useful additional variables that extensions can use.
if(CMAKE_SYSTEM MATCHES Linux)
set(LINUX ON)
else()
set(LINUX OFF)
endif()
# Clear PythonTargets.cmake
file(WRITE ${CONFIG_BUILD_DIR}/PythonTargets.cmake "")
# Define python executable wrapper command to ensure
# python executable resolves the expected python library.
set(PYTHON_WRAPPER_COMMAND )
if(BUILD_LIBPYTHON_SHARED AND UNIX)
set(_envvar LD_LIBRARY_PATH)
if(APPLE)
set(_envvar DYLD_LIBRARY_PATH)
endif()
set(PYTHON_WRAPPER_COMMAND env ${_envvar}=${PROJECT_BINARY_DIR}/${LIBPYTHON_LIBDIR})
endif()
# Add extension modules
set(extensions_enabled "" CACHE INTERNAL "" FORCE)
set(extensions_disabled "" CACHE INTERNAL "" FORCE)
add_subdirectory(cmake/extensions CMakeBuild/extensions)
# Add the other subdirectories
add_subdirectory(cmake/libpython CMakeBuild/libpython)
add_subdirectory(cmake/python CMakeBuild/python)
add_subdirectory(cmake/include CMakeBuild/include)
add_subdirectory(cmake/lib CMakeBuild/lib)
add_subdirectory(cmake/tools CMakeBuild/tools)
if(BUILD_WININST)
add_subdirectory(cmake/PC/bdist_wininst CMakeBuild/bdist_wininst)
endif()
if(WIN32)
add_subdirectory(cmake/PC/launcher CMakeBuild/launcher)
endif()
# Ensure the "_testcapi" extension introduced in Python 3.12 can find
# find "Python3.lib" as it is specified in "PC/pyconfig." using
# `pragma comment(lib,"python3.lib")`.
if(WIN32 AND TARGET extension_testcapi)
set(libpython_output_dir "${PROJECT_BINARY_DIR}/CMakeBuild/libpython/$<CONFIG>")
target_link_directories(extension_testcapi PRIVATE ${libpython_output_dir})
# Ensure import library is generated before linking the extension
add_dependencies(extension_testcapi libpython3-shared)
endif()
# Add target to run "Argument Clinic" over all source files
add_custom_target(clinic
COMMAND python ${SRC_DIR}/Tools/clinic/clinic.py --make
DEPENDS python
WORKING_DIRECTORY ${SRC_DIR}
COMMENT "Running 'Argument Clinic' over all source files"
VERBATIM
)
# Add target to generate 'Include/graminit.h' and 'Python/graminit.c'
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
set(generate_graminit_command python -m Parser.pgen)
else()
set(generate_graminit_command pgen)
endif()
add_custom_target(generate_graminit
COMMAND ${generate_graminit_command}
${SRC_DIR}/Grammar/Grammar
$<$<VERSION_GREATER_EQUAL:${PY_VERSION},3.8>:${SRC_DIR}/Grammar/Tokens>
${PROJECT_BINARY_DIR}/CMakeFiles/graminit.h
${PROJECT_BINARY_DIR}/CMakeFiles/graminit.c
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/CMakeFiles/graminit.h
${SRC_DIR}/Include/graminit.h
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/CMakeFiles/graminit.c
${SRC_DIR}/Python/graminit.c
DEPENDS $<IF:$<VERSION_GREATER_EQUAL:${PY_VERSION},3.8>,python,pgen>
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating '${SRC_DIR}/Include/graminit.h' and '${SRC_DIR}/Python/graminit.c'."
VERBATIM
)
if(PY_VERSION VERSION_GREATER_EQUAL "3.9")
# Add target to generate `Tools/peg_generator/pegen/grammar_parser.py`
add_custom_target(generate_pegen_metaparser
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${SRC_DIR}/Tools/peg_generator
${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:python> -m pegen
-q python
${SRC_DIR}/Tools/peg_generator/pegen/metagrammar.gram
-o ${PROJECT_BINARY_DIR}/CMakeFiles/grammar_parser.py
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/CMakeFiles/grammar_parser.py
${SRC_DIR}/Tools/peg_generator/pegen/grammar_parser.py
DEPENDS python
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating '${SRC_DIR}/Tools/peg_generator/pegen/grammar_parser.py'"
VERBATIM
)
# Add target to generate `Parser/pegen/parse.c`
add_custom_target(generate_pegen_parse
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${SRC_DIR}/Tools/peg_generator
${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:python> -m pegen
-q c
${SRC_DIR}/Grammar/python.gram
${SRC_DIR}/Grammar/Tokens
-o ${PROJECT_BINARY_DIR}/CMakeFiles/parse.c
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/CMakeFiles/parse.c
${SRC_DIR}/Parser/pegen/parse.c
DEPENDS python
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating '${SRC_DIR}/Parser/pegen/parse.c'"
VERBATIM
)
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
${SRC_DIR}/Lib/opcode.py
${PROJECT_BINARY_DIR}/CMakeFiles/opcode.h
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${PROJECT_BINARY_DIR}/CMakeFiles/opcode.h
${SRC_DIR}/Include/opcode.h
DEPENDS python
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating '${SRC_DIR}/Include/opcode.h'."
VERBATIM
)
# 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
-h ${SRC_DIR}/Include
${SRC_DIR}/Parser/Python.asdl
DEPENDS python
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating '${SRC_DIR}/Include/Python-ast.h'"
VERBATIM
)
# 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
-c ${SRC_DIR}/Python
${SRC_DIR}/Parser/Python.asdl
DEPENDS python
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating '${SRC_DIR}/Python/Python-ast.c'"
VERBATIM
)
# If needed, copy 'asdl.py' and 'Python.asdl' into build directory so that 'test_asdl_parser' passes.
set(_asdl_subdir ${LIBDIR})
if(WIN32)
set(_asdl_subdir )
endif()
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${LIBDIR}/Parser)
configure_file(
${SRC_DIR}/Parser/Python.asdl
${PROJECT_BINARY_DIR}/${_asdl_subdir}/Parser/Python.asdl
COPYONLY
)
configure_file(
${SRC_DIR}/Parser/asdl.py
${PROJECT_BINARY_DIR}/${_asdl_subdir}/Parser/asdl.py
COPYONLY
)
show_extension_summary()
if(UNIX)
# python.pc
configure_file(cmake/python.pc.in
${PROJECT_BINARY_DIR}/Misc/python-${LIBPYTHON_VERSION}.pc @ONLY)
configure_file(cmake/python.pc.in
${PROJECT_BINARY_DIR}/Misc/python-${PY_VERSION_MAJOR}.pc @ONLY)
configure_file(cmake/python.pc.in
${PROJECT_BINARY_DIR}/Misc/python.pc @ONLY)
if(INSTALL_DEVELOPMENT)
install(FILES
${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
COMPONENT Development)
endif()
# Makefile
set(MAKEFILE_LDSHARED_FLAGS "-shared")
if(APPLE)
set(MAKEFILE_LDSHARED_FLAGS "-dynamiclib -headerpad_max_install_names -undefined dynamic_lookup")
endif()
configure_file(cmake/makefile-variables.in
${BIN_BUILD_DIR}/Makefile @ONLY)
if(INSTALL_DEVELOPMENT)
install(FILES ${BIN_BUILD_DIR}/Makefile
DESTINATION ${LIB_CONFIG_INSTALL_DIR}
RENAME Makefile
COMPONENT Development)
endif()
# Utility scripts
if(INSTALL_DEVELOPMENT)
install(FILES ${SRC_DIR}/install-sh ${SRC_DIR}/Modules/makesetup
DESTINATION ${LIB_CONFIG_INSTALL_DIR}
COMPONENT Development)
endif()
# Install manual
if(INSTALL_MANUAL)
set(_install_man FILES ${SRC_DIR}/Misc/python.man DESTINATION share/man/man1 COMPONENT Runtime)
install(${_install_man} RENAME python${LIBPYTHON_VERSION}.1)
install(${_install_man} RENAME python${PY_VERSION_MAJOR}.1)
endif()
endif()
# Create an empty lib-dynload folder, even if we don't have any extensions
# to go in there. bin/python uses this to auto-determine the exec_prefix
# and properly generate the _sysconfigdata.py
file(MAKE_DIRECTORY "${EXTENSION_BUILD_DIR}")
install(DIRECTORY DESTINATION ${EXTENSION_INSTALL_DIR})
if(BUILD_TESTING)
set(SUPPORTED_TEST_RESOURCES network)
message(STATUS "Supported test resources: ${SUPPORTED_TEST_RESOURCES}")
list(JOIN SUPPORTED_TEST_RESOURCES "," regrtest_resources)
set(TESTOPTS
# Command line option "-l/--findleaks" of regrtest is deprecated since Python 3.7 and
# removed in Python 3.11. It is superseded by --fail-env-changed.
$<IF:$<VERSION_GREATER_EQUAL:${PY_VERSION},3.11>,--fail-env-changed,-l>
# Comma-separated list of words indicating the resources to test
-u ${regrtest_resources}
)
set(TESTPROG ${PROJECT_BINARY_DIR}/${PYTHONHOME}/test/regrtest.py)
set(TESTPYTHONOPTS )
set(TESTPYTHON $<TARGET_FILE:python> ${TESTPYTHONOPTS})
set(TESTPYTHON ${CMAKE_CROSSCOMPILING_EMULATOR} ${TESTPYTHON})
include(cmake/UnitTests.cmake)
foreach(unittest ${unittests})
set(EXTRATESTOPTS -v)
# XXX Running 'test_doctest' in verbose mode always return 1
if(unittest STREQUAL "test_doctest")
set(EXTRATESTOPTS )
endif()
add_test(NAME ${unittest} COMMAND ${PYTHON_WRAPPER_COMMAND} ${TESTPYTHON} ${TESTPROG} ${TESTOPTS} ${EXTRATESTOPTS} ${unittest})
endforeach()
function(add_cmakescript_test testname script)
add_test(cmake_${testname}_test ${CMAKE_COMMAND}
-DTEST_${testname}:BOOL=ON
-P ${PROJECT_SOURCE_DIR}/${script})
set_tests_properties(cmake_${testname}_test PROPERTIES
LABELS CMake
PASS_REGULAR_EXPRESSION "SUCCESS")
endfunction()
add_cmakescript_test(
python_extract_version_info
cmake/PythonExtractVersionInfo.cmake
)
add_cmakescript_test(
python_compute_release_field3_value
cmake/PythonExtractVersionInfo.cmake
)
endif()
include(CMakePackageConfigHelpers)
# Configure 'PythonConfig.cmake' for a build tree
set(CONFIG_DIR_CONFIG ${CONFIG_BUILD_DIR})
set(INCLUDE_DIR_CONFIG ${INCLUDE_BUILD_DIR})
set(PYTHON_CONFIG_CODE "####### Expanded from \@PYTHON_CONFIG_CODE\@ #######\n")
set(PYTHON_CONFIG_CODE "${PYTHON_CONFIG_CODE}list(APPEND PYTHON_INCLUDE_DIR \"${PYCONFIG_BUILD_DIR}\")\n")
set(PYTHON_CONFIG_CODE "${PYTHON_CONFIG_CODE}##################################################")
set(python_config ${CONFIG_BUILD_DIR}/PythonConfig.cmake)
configure_package_config_file(
cmake/PythonConfig.cmake.in
${python_config}
INSTALL_DESTINATION ${PROJECT_BINARY_DIR}
PATH_VARS CONFIG_DIR_CONFIG INCLUDE_DIR_CONFIG
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Configure 'PythonConfig.cmake' for an install tree
set(CONFIG_DIR_CONFIG ${CONFIG_INSTALL_DIR})
set(INCLUDE_DIR_CONFIG ${INCLUDE_INSTALL_DIR})
set(PYTHON_CONFIG_CODE "")
set(python_install_config ${PROJECT_BINARY_DIR}/CMakeFiles/PythonConfig.cmake)
configure_package_config_file(
cmake/PythonConfig.cmake.in
${python_install_config}
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}
PATH_VARS CONFIG_DIR_CONFIG INCLUDE_DIR_CONFIG
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
# Configure 'PythonTargets.cmake' and 'PythonConfigVersion.cmake
get_property(PYTHON_TARGETS GLOBAL PROPERTY PYTHON_TARGETS)
export(TARGETS ${PYTHON_TARGETS} APPEND FILE ${CONFIG_BUILD_DIR}/PythonTargets.cmake)
set(python_config_version ${CONFIG_BUILD_DIR}/PythonConfigVersion.cmake)
write_basic_package_version_file(
${python_config_version}
VERSION ${PY_VERSION}
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)
set(license_destination .)
endif()
install(FILES ${SRC_DIR}/LICENSE DESTINATION ${license_destination} COMPONENT Runtime RENAME LICENSE.txt)
+32
View File
@@ -0,0 +1,32 @@
Contributing
------------
[fork]: https://github.com/github/VisualStudio/fork
[pr]: https://github.com/github/VisualStudio/compare
[code-of-conduct]: http://todogroup.org/opencodeofconduct/#VisualStudio/opensource@github.com
[readme]: https://github.com/github/VisualStudio#build
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to uphold this code.
Submitting a pull request
-------------------------
0. [Fork][] and clone the repository (see Build Instructions in the [README][readme])
0. Create a new branch: `git checkout -b my-branch-name`
0. Make your change, add tests, and make sure the tests still pass
0. Push to your fork and [submit a pull request][pr]
0. Pat your self on the back and wait for your pull request to be reviewed and merged.
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
- Follow the existing code's style.
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
## Resources
- [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/)
- [Using Pull Requests](https://help.github.com/articles/using-pull-requests/)
- [GitHub Help](https://help.github.com)
+8
View File
@@ -0,0 +1,8 @@
set(CTEST_PROJECT_NAME "Python")
set(CTEST_NIGHTLY_START_TIME "3:00:00 UTC")
set(CTEST_DROP_METHOD "https")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=CPython")
set(CTEST_DROP_SITE_CDASH TRUE)
set(CTEST_TEST_TIMEOUT "60")
+192
View File
@@ -0,0 +1,192 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+280
View File
@@ -0,0 +1,280 @@
CPython CMake Buildsystem
=========================
Overview
--------
A replacement buildsystem for CPython.
This `CMake <http://cmake.org>`_ buildsystem has the following advantages:
* No compiled program for the target architecture is used in the build
itself. This makes **cross-compiling** easier, less error prone, and
reduces manual steps.
* Same build information for all platforms - there's no need to maintain the
autotools configuration separately from four different MSVC project files.
* Support for other build systems and IDE's like `Ninja
<https://ninja-build.org>`_, `Sublime Text
<https://www.sublimetext.com/>`_, and many others.
* Easily build C-extensions against other C/C++ libraries built with CMake.
* It's much faster to compile: 7 seconds instead of 58 seconds in my
unscientific test.
Usage
-----
How to use this buildsystem:
1. Checkout the buildsystem
.. code:: bash
cd ~/scratch
git clone git://github.com/python-cmake-buildsystem/python-cmake-buildsystem
2. Build
.. code:: bash
# Unix
cd ~/scratch
mkdir -p python-build && mkdir -p python-install
cd python-build
cmake -DCMAKE_INSTALL_PREFIX:PATH=${HOME}/scratch/python-install ../python-cmake-buildsystem
make -j10
make install
# Windows
cd %HOME%/scratch
mkdir python-build
mkdir python-install
cd python-build
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX:PATH=%HOME%/scratch/python-install ../python-cmake-buildsystem
cmake --build . --config Release -- /m
cmake --build . --config Release --target INSTALL
.. note::
By default, the build system will download the python 3.11.12 source from
http://www.python.org/ftp/python/
CMake Options
-------------
You can pass options to CMake to control the way Python is built. You only
need to give each option once - they get saved in `CMakeCache.txt`. Pass
options on the commandline with `-DOPTION=VALUE`, or use the "ccmake" gui.
::
PYTHON_VERSION=major.minor.patch (defaults to 3.12.10)
The version of Python to build.
PYTHON_APPLY_PATCHES=ON|OFF (defaults to ON)
Apply patches required to build CPython based on the system and compiler
found when configuring the project. Note that when cross-compiling, patches
coresponding to the target system are applied.
Patches can be found in "patches" directory.
CMAKE_BUILD_TYPE=Debug|Release
Build with debugging symbols or with optimisations.
CMAKE_INSTALL_PREFIX=<path> (defaults to /usr/local)
Path in which to install Python.
DOWNLOAD_SOURCES=ON|OFF (defaults to ON)
Download, check MD5 sum and extract python sources in the parent directory.
Source archive is downloaded from http://www.python.org/ftp/python
BUILD_LIBPYTHON_SHARED=ON|OFF (defaults to OFF)
Build libpython as a shared library (.so or .dll) or a static library
(.a).
Note that Python extensions are always built as shared libraries. On
Windows it is not possible to build shared .dll extensions against a
static libpython, so you must build any extensions you want into libpython
itself (see the BUILTIN flags below).
BUILD_EXTENSIONS_AS_BUILTIN=ON|OFF (defaults to OFF)
If enabled, all extensions are statically compiled into the built python
libraries (static and/or shared).
Note that all previously set BUILTIN_<extension> options are ignored and
reset to their original value.
WITH_STATIC_DEPENDENCIES=ON|OFF (defaults to OFF, available only on UNIX)
If this is set to ON then cmake will compile statically libpython and all
extensions. External dependencies (ncurses, sqlite, ...) will be builtin
only if they are available as static libraries.
BUILD_WININST=ON|OFF (only for windows, defaults to ON if not crosscompiling)
If enabled, build the 'Windows Installer' program for distutils if not
already provided in the source tree.
BUILD_WININST_ALWAYS=ON|OFF (only for windows, defaults to OFF)
If enabled, always build 'Windows Installer' program for distutils even
if it is already provided in the source tree.
INSTALL_DEVELOPMENT=ON|OFF (defaults to ON)
If enabled, install files required to develop C extensions.
INSTALL_MANUAL=ON|OFF (defaults to ON)
If enabled, install manuals.
INSTALL_TEST=ON|OFF (defaults to ON)
If enabled, install test files.
ENABLE_<extension>=ON|OFF (defaults to ON)
BUILTIN_<extension>=ON|OFF (defaults to OFF except for POSIX, PWD and
NT extensions which are builtin by default)
These two options control how individual python extensions are built.
<extension> is the name of the extension in upper case, and without any
leading underscore (_).
All extensions are enabled by default, but some might depend on system
libraries and will get disabled if they're not available (a list of
extensions that didn't have all their prerequisites available will be
printed when you run cmake).
By default extensions are compiled as separate shared libraries (.so or
.dll files) and installed in lib/pythonX.Y/lib-dynload. If you set
BUILTIN_<extension> to ON then the extension is compiled into libpython
instead.
USE_LIB64=ON|OFF (defaults to OFF)
If this is set to ON then cmake will look for dependencies in lib64 as
well as lib directories. Compiled python extensions will also be
installed into lib64/pythonX.Y/lib-dynload instead of
lib/pythonX.Y/lib-dynload.
Py_USING_UNICODE (only for python2, defaults to ON)
Enable unicode support. By default, ucs2 is used. It can be
forced to ucs4 setting Py_UNICODE_SIZE to 4.
WITH_C_LOCALE_COERCION (only for python3.7 and above, default to ON)
Enable C locale coercion to a UTF-8 based locale.
WITH_DECIMAL_CONTEXTVAR (only for python3.8 and above, default to ON)
Build _decimal module using a coroutine-local rather than a thread-local context.
WITH_TRACE_REFS (only for python3.8 and above, default to OFF)
Enable tracing references for debugging purpose
WITH_SSL_DEFAULT_SUITES (only for python3.7 and above, default to "python")
Override default cipher suites string:
* python: use Python's preferred selection (default)
* openssl: leave OpenSSL's defaults untouched
* STRING: use a custom string, PROTOCOL_SSLv2 ignores the setting
EXTRA_PYTHONPATH=dir1:dir2 (defaults to "")
Colon (:) separated list of extra directories to add to the compiled-in
PYTHONPATH.
USE_SYSTEM_LIBRARIES=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect system libraries will be done.
Options documented below allow to enable/disable detection of particular
libraries.
USE_SYSTEM_Curses=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect Curses libraries will be done.
Associated python extensions are: CURSES, CURSES_PANEL, READLINE
Following CMake variables can manually be set: CURSES_LIBRARIES, PANEL_LIBRARIES
USE_SYSTEM_EXPAT=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect Expat libraries will be done.
Associated python extensions are: ELEMENTTREE, PYEXPAT
Following CMake variables can manually be set: EXPAT_LIBRARIES, EXPAT_INCLUDE_DIRS
USE_SYSTEM_LibFFI=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect libffi libraries will be done.
Associated python extensions are: CTYPES
Following CMake variables can manually be set: LibFFI_LIBRARY and LibFFI_INCLUDE_DIR
USE_SYSTEM_OpenSSL=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect OpenSSL libraries will be done.
Associated python extensions are: HASHLIB, SSL, MD5, SHA, SHA256, SHA512
Following CMake variables can manually be set: OPENSSL_INCLUDE_DIR, OPENSSL_LIBRARIES
If [OPENSSL_INCLUDE_DIR, OPENSSL_LIBRARIES] are found, extensions [HASHLIB, SSL] will be built
If [OPENSSL_INCLUDE_DIR, OPENSSL_LIBRARIES] are NOT found, extensions [SHA, SHA256, SHA512] will be built
USE_SYSTEM_TCL=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect Tcl libraries will be done.
Associated python extensions are: TKINTER
Following CMake variables can manually be set: TCL_LIBRARY, TK_LIBRARY, TCL_INCLUDE_PATH, TK_INCLUDE_PATH
USE_SYSTEM_ZLIB=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect ZLIB libraries will be done.
Associated python extensions are: BINASCII, ZLIB
Following CMake variables can manually be set: ZLIB_LIBRARY, ZLIB_INCLUDE_DIR, ZLIB_ROOT
ZLIB_ROOT should be set only if USE_SYSTEM_ZLIB is ON
If [ZLIB_LIBRARY, ZLIB_INCLUDE_DIR] are found, extensions [BINASCII] will be built with ZLIB_CRC32
USE_SYSTEM_DB=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect DB libraries will be done.
Associated python extensions are: BSDDB
Following CMake variables can manually be set: DB_INCLUDE_PATH, DB_LIBRARY
USE_SYSTEM_GDBM=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect GDBM libraries will be done.
Associated python extensions are: DBM, GDBM
Following CMake variables can manually be set: GDBM_INCLUDE_PATH, GDBM_LIBRARY, GDBM_COMPAT_LIBRARY, NDBM_TAG, <NDBM_TAG>_INCLUDE_PATH
USE_SYSTEM_LZMA=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect LZMA libraries will be done.
Associated python extensions are: LZMA
Following CMake variables can manually be set: LZMA_INCLUDE_PATH, LZMA_LIBRARY
USE_SYSTEM_READLINE=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect Readline libraries will be done.
Associated python extensions are: READLINE
Following CMake variables can manually be set: READLINE_INCLUDE_PATH, READLINE_LIBRARY
USE_SYSTEM_SQLite3=ON|OFF (defaults to ON)
If set to OFF, no attempt to detect SQLite3 libraries will be done.
Associated python extensions are: SQLITE3
Following CMake variables can manually be set: SQLite3_INCLUDE_DIR, SQLite3_LIBRARY
CMAKE_OSX_SDK (MacOSX, default is autodetected, e.g 'macosx10.06')
By default, the variable is automatically set running `xcrun` and/or `xcodebuild`. Note that its
value can also be explicitly set when doing a clean configuration either by adding a cache entry in
`cmake-gui` or by passing the argument `-DCMAKE_OSX_SDK:STRING=macosx10.6` when running `cmake`.
Then, this variable is used to initialize `CMAKE_OSX_SYSROOT`, `CMAKE_OSX_DEPLOYMENT_TARGET`
and `MACOSX_DEPLOYMENT_TARGET` variables.
Licenses
--------
Materials in this repository are distributed under the following licenses:
All software is licensed under the Apache 2.0 License.
See `LICENSE_Apache_20 <LICENSE_Apache_20>`_ file for details.
FAQ
---
Why Apache 2.0 License?
.......................
From the python.org wiki, the answer to the question `What if I want to
contribute my code to the PSF
<https://wiki.python.org/moin/PythonSoftwareFoundationLicenseFaq#What_if_I_want_to_contribute_my_code_to_the_PSF.3F>`_
mentions that if code is going to end up in Python or the standard library,
the PSF will require you to license code under "Academic Free License" or
"Apache License 2.0".
Which python versions are supported?
....................................
This project supports building multiple versions of CPython 3.
See current list of supported version in top-level `CMakeLists.txt <https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/blob/master/CMakeLists.txt>`_.
Support for building CPython 2.7 was retired in April 2025. Archived version associated with tag [v2.7](https://github.com/python-cmake-buildsystem/python-cmake-buildsystem/releases/tag/v2.7).
Since this repository is maintained separately from `python/CPython <https://github.com/python/cpython>`_ itself,
it needs to be manually updated whenever there is a new release of Python.
File diff suppressed because it is too large Load Diff
+243
View File
@@ -0,0 +1,243 @@
# This function adds a python extension to the buildsystem.
#
# Usage:
#
# add_python_extension(
# extension_name
# SOURCES source1.c source2.c ...
# [ REQUIRES variable1 variable2 ... ]
# [ DEFINITIONS define1 define2 ... ]
# [ LIBRARIES lib1 lib2 ... ]
# [ INCLUDEDIRS dir1 dir2 ... ]
# [ BUILTIN | ALWAYS_BUILTIN | NEVER_BUILTIN ]
# )
#
# extension_name: the name of the library without any .so extension.
# SOURCES: a list of filenames realtive to the Modules/ directory that make
# up this extension.
# REQUIRES: this extension will not be built unless all the variables listed
# here evaluate to true. You should include any variables you use
# in the LIBRARIES and INCLUDEDIRS sections.
# DEFINITIONS: an optional list of definitions to pass to the compiler while
# building this module. Do not include the -D prefix.
# LIBRARIES: an optional list of additional libraries.
# INCLUDEDIRS: an optional list of additional include directories.
# BUILTIN: if this is set the module will be compiled statically into
# libpython by default. The user can still override by setting
# BUILTIN_[extension_name]=OFF.
# ALWAYS_BUILTIN: if this is set the module will always be compiled statically into
# libpython.
# NEVER_BUILTIN: if this is set the module will never be compiled statically into
# libpython. If WITH_STATIC_DEPENDENCIES is ON, extension is disabled.
# NO_INSTALL: do not install or package the extension.
#
# Two user-settable options are created for each extension added:
# ENABLE_[extension_name] defaults to ON. If set to OFF the extension will
# not be added at all.
# BUILTIN_[extension_name] defaults to the value of
# BUILD_EXTENSIONS_AS_BUILTIN, which defaults to OFF,
# unless BUILTIN is set when calling
# add_python_extension. Adds the extension source
# files to libpython instead of compiling a separate
# library.
# These options convert the extension_name to upper case first and remove any
# leading underscores. So add_python_extension(_foo ...) will create the
# options ENABLE_FOO and BUILTIN_FOO.
function(add_python_extension name)
set(options BUILTIN ALWAYS_BUILTIN NEVER_BUILTIN NO_INSTALL)
set(oneValueArgs)
set(multiValueArgs REQUIRES SOURCES DEFINITIONS LIBRARIES INCLUDEDIRS)
cmake_parse_arguments(ADD_PYTHON_EXTENSION
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
# Remove _ from the beginning of the name.
string(REGEX REPLACE "^_" "" pretty_name "${name}")
# Upper case the name.
string(TOUPPER "${pretty_name}" upper_name)
# Add a prefix to the target name so it doesn't clash with any system
# libraries that we might want to link against (eg. readline)
set(target_name extension_${pretty_name})
set(enable_default ON)
if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN AND WITH_STATIC_DEPENDENCIES)
set(enable_default OFF)
endif()
# Add options that the user can set to control whether this extension is
# compiled, and whether it is compiled in to libpython itself.
option(ENABLE_${upper_name}
"Controls whether the \"${name}\" extension will be built"
${enable_default}
)
if(ENABLE_${upper_name})
mark_as_advanced(FORCE ENABLE_${upper_name})
else()
mark_as_advanced(CLEAR ENABLE_${upper_name})
endif()
if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN AND WITH_STATIC_DEPENDENCIES AND ENABLE_${upper_name})
set(reason " because extension is declared as NEVER_BUILTIN and WITH_STATIC_DEPENDENCIES is ON")
set(ENABLE_${upper_name} OFF CACHE BOOL "Forced to OFF${reason}" FORCE)
message(STATUS "Setting ENABLE_${upper_name} to OFF${reason}")
endif()
# Check all the things we require are found.
set(missing_deps "")
foreach(dep ${ADD_PYTHON_EXTENSION_REQUIRES} ENABLE_${upper_name})
string(REPLACE " " ";" list_dep ${dep})
if(NOT (${list_dep}))
set(missing_deps "${missing_deps}${dep} ")
endif()
endforeach()
if(ADD_PYTHON_EXTENSION_NEVER_BUILTIN)
set(BUILTIN_${upper_name} 0)
elseif(ADD_PYTHON_EXTENSION_ALWAYS_BUILTIN)
set(BUILTIN_${upper_name} 1)
else()
# Add options that the extention is either external to libpython or
# builtin. These will be marked as advanced unless different from default
# values
if(NOT ADD_PYTHON_EXTENSION_BUILTIN)
set(ADD_PYTHON_EXTENSION_BUILTIN ${BUILD_EXTENSIONS_AS_BUILTIN})
endif()
cmake_dependent_option(
BUILTIN_${upper_name}
"If this is set the \"${name}\" extension will be compiled in to libpython"
${ADD_PYTHON_EXTENSION_BUILTIN}
"NOT missing_deps"
OFF
)
if(NOT missing_deps)
if((BUILTIN_${upper_name} AND BUILD_EXTENSIONS_AS_BUILTIN)
OR (NOT BUILTIN_${upper_name} AND NOT BUILD_EXTENSIONS_AS_BUILTIN))
mark_as_advanced(FORCE BUILTIN_${upper_name})
else()
mark_as_advanced(CLEAR BUILTIN_${upper_name})
endif()
endif()
endif()
# If any dependencies were missing don't include this extension.
if(missing_deps)
string(STRIP "${missing_deps}" missing_deps)
set(extensions_disabled "${extensions_disabled}${name} (not set: ${missing_deps});"
CACHE INTERNAL "" FORCE)
return()
else()
set(extensions_enabled "${extensions_enabled}${name};" CACHE INTERNAL "" FORCE)
endif()
# Callers to this function provide source files relative to the Modules/
# directory. We need to get absolute paths for them all.
set(absolute_sources "")
foreach(source ${ADD_PYTHON_EXTENSION_SOURCES})
get_filename_component(ext ${source} EXT)
# Treat assembler sources differently
if(ext STREQUAL ".S")
set_source_files_properties(Modules/${source} PROPERTIES LANGUAGE ASM)
endif()
set(absolute_src ${source})
if(NOT IS_ABSOLUTE ${source})
set(absolute_src ${SRC_DIR}/Modules/${source})
endif()
list(APPEND absolute_sources ${absolute_src})
endforeach()
if(BUILTIN_${upper_name})
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
list(APPEND ADD_PYTHON_EXTENSION_DEFINITIONS Py_BUILD_CORE_BUILTIN)
endif()
# This will be compiled into libpython instead of as a separate library
set_property(GLOBAL APPEND PROPERTY builtin_extensions ${name})
set_property(GLOBAL APPEND PROPERTY extension_${name}_sources ${absolute_sources})
set_property(GLOBAL APPEND PROPERTY extension_${name}_link_libraries ${ADD_PYTHON_EXTENSION_LIBRARIES})
set_property(GLOBAL APPEND PROPERTY extension_${name}_includedirs ${ADD_PYTHON_EXTENSION_INCLUDEDIRS})
set_property(GLOBAL APPEND PROPERTY extension_${name}_definitions ${ADD_PYTHON_EXTENSION_DEFINITIONS})
elseif(WIN32 AND NOT BUILD_LIBPYTHON_SHARED)
# Extensions cannot be built against a static libpython on windows
else()
add_library(${target_name} SHARED ${absolute_sources})
target_include_directories(${target_name} PUBLIC "${ADD_PYTHON_EXTENSION_INCLUDEDIRS}")
if(PY_VERSION VERSION_GREATER_EQUAL "3.8")
list(APPEND ADD_PYTHON_EXTENSION_DEFINITIONS Py_BUILD_CORE_MODULE)
endif()
if(WIN32)
string(REGEX MATCH "Py_LIMITED_API" require_limited_api "${ADD_PYTHON_EXTENSION_DEFINITIONS}")
if(require_limited_api STREQUAL "")
list(APPEND ADD_PYTHON_EXTENSION_LIBRARIES libpython-shared)
else()
list(APPEND ADD_PYTHON_EXTENSION_LIBRARIES libpython3-shared)
endif()
endif()
target_link_libraries(${target_name} ${ADD_PYTHON_EXTENSION_LIBRARIES})
if(WIN32)
#list(APPEND ADD_PYTHON_EXTENSION_DEFINITIONS Py_NO_ENABLE_SHARED)
if(MINGW)
set_target_properties(${target_name} PROPERTIES
LINK_FLAGS -Wl,--enable-auto-import
)
endif()
set_target_properties(${target_name} PROPERTIES
SUFFIX .pyd
)
endif()
if(APPLE)
set_target_properties(${target_name} PROPERTIES
LINK_FLAGS -Wl,-undefined,dynamic_lookup
SUFFIX .so
)
endif()
# Turn off the "lib" prefix and add any compiler definitions
set_target_properties(${target_name} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${ARCHIVEDIR}
LIBRARY_OUTPUT_DIRECTORY ${EXTENSION_BUILD_DIR}
RUNTIME_OUTPUT_DIRECTORY ${EXTENSION_BUILD_DIR}
OUTPUT_NAME "${name}$<$<AND:$<BOOL:${UNIX}>,$<VERSION_GREATER_EQUAL:${PY_VERSION},3.8>>:.${SOABI}>"
PREFIX ""
)
set_target_properties(${target_name} PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
if(ADD_PYTHON_EXTENSION_DEFINITIONS)
set_target_properties(${target_name} PROPERTIES
COMPILE_DEFINITIONS "${ADD_PYTHON_EXTENSION_DEFINITIONS}")
endif()
if(NOT ADD_PYTHON_EXTENSION_NO_INSTALL)
install(TARGETS ${target_name}
ARCHIVE DESTINATION ${ARCHIVEDIR}
LIBRARY DESTINATION ${EXTENSION_INSTALL_DIR}
RUNTIME DESTINATION ${EXTENSION_INSTALL_DIR})
endif()
endif()
endfunction()
function(show_extension_summary)
if(extensions_disabled)
message(STATUS "")
message(STATUS "The following extensions will NOT be built:")
message(STATUS "")
foreach(line ${extensions_disabled})
message(STATUS " ${line}")
endforeach()
message(STATUS "")
endif()
endfunction()
+79
View File
@@ -0,0 +1,79 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#.rst:
# FindPatch
# ---------
#
# The module defines the following variables:
#
# ``Patch_EXECUTABLE``
# Path to patch command-line executable.
# ``Patch_FOUND``
# True if the patch command-line executable was found.
#
# The following :prop_tgt:`IMPORTED` targets are also defined:
#
# ``Patch::patch``
# The command-line executable.
#
# Example usage:
#
# .. code-block:: cmake
#
# find_package(Patch)
# if(Patch_FOUND)
# message("Patch found: ${Patch_EXECUTABLE}")
# endif()
set(_doc "Patch command line executable")
set(_patch_path )
if(CMAKE_HOST_WIN32)
set(_patch_path
"$ENV{LOCALAPPDATA}/Programs/Git/bin"
"$ENV{LOCALAPPDATA}/Programs/Git/usr/bin"
"$ENV{APPDATA}/Programs/Git/bin"
"$ENV{APPDATA}/Programs/Git/usr/bin"
)
endif()
# First search the PATH
find_program(Patch_EXECUTABLE
NAME patch
PATHS ${_patch_path}
DOC ${_doc}
)
if(CMAKE_HOST_WIN32)
# Now look for installations in Git/ directories under typical installation
# prefixes on Windows.
find_program(Patch_EXECUTABLE
NAMES patch
PATH_SUFFIXES Git/usr/bin Git/bin GnuWin32/bin
DOC ${_doc}
)
endif()
if(Patch_EXECUTABLE AND NOT TARGET Patch::patch)
add_executable(Patch::patch IMPORTED)
set_property(TARGET Patch::patch PROPERTY IMPORTED_LOCATION ${Patch_EXECUTABLE})
execute_process(COMMAND ${Patch_EXECUTABLE} --version
OUTPUT_VARIABLE patch_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(_patch_version_regex ".*patch ([0-9]+\\.[0-9]+\\.[0-9]+)")
if(patch_version MATCHES "${_patch_version_regex}")
set(Patch_VERSION ${CMAKE_MATCH_1})
endif()
endif()
unset(_patch_path)
unset(_doc)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Patch
REQUIRED_VARS Patch_EXECUTABLE
VERSION_VAR Patch_VERSION)
@@ -0,0 +1,93 @@
# For building the bdist_wininst subdir
include_directories(
${SRC_DIR}/Include
${SRC_DIR}/Modules/zlib
)
set(WININST_HEADERS
${SRC_DIR}/PC/bdist_wininst/archive.h
${SRC_DIR}/PC/bdist_wininst/resource.h
)
set(WININST_SOURCES
${SRC_DIR}/PC/bdist_wininst/extract.c
${SRC_DIR}/PC/bdist_wininst/install.c
${SRC_DIR}/Modules/zlib/adler32.c
${SRC_DIR}/Modules/zlib/crc32.c
${SRC_DIR}/Modules/zlib/inffast.c
${SRC_DIR}/Modules/zlib/inflate.c
${SRC_DIR}/Modules/zlib/inftrees.c
${SRC_DIR}/Modules/zlib/zutil.c
)
# Install tree directory
set(WININST_INSTALL_DIR ${PYTHONHOME}/distutils/command)
# Build tree directory
set(WININST_BUILD_DIR ${PROJECT_BINARY_DIR}/${WININST_INSTALL_DIR})
# Compiler version
set(version "unknown")
foreach(msvcmajver IN ITEMS 90 10 11 12 14)
if(${MSVC${msvcmajver}})
string(REGEX REPLACE "0$" "" msvcmajver ${msvcmajver})
set(version "${msvcmajver}.0")
endif()
endforeach()
# System architecture
set(arch "")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(arch "-amd64")
endif()
# Set installer executable name
set(WININST_EXE_NAME "wininst-${version}${arch}")
message(STATUS "bdist_wininst: Generated 'Windows Installer' name is '${WININST_EXE_NAME}'")
# Check if windows installer is already bundled in the source tree
set(_have_wininst_in_source 0)
set(_msg "bdist_wininst: Looking for executable named '${WININST_EXE_NAME}${CMAKE_EXECUTABLE_SUFFIX}' in source tree")
message(STATUS "${_msg}")
set(_expected_wininst ${SRC_DIR}/${WININST_INSTALL_DIR}/${WININST_EXE_NAME}${CMAKE_EXECUTABLE_SUFFIX})
if(EXISTS ${_expected_wininst})
set(_have_wininst_in_source 1)
message(STATUS "${_msg} - found \"${_expected_wininst}\"")
else()
message(STATUS "${_msg} - not found")
endif()
# Skip if installer is already bundled in the source tree and BUILD_WININST_ALWAYS is OFF
set(_configure_reason "")
if(_have_wininst_in_source)
if(NOT BUILD_WININST_ALWAYS)
message(STATUS "bdist_wininst: Skipping installer configuration because it is already provided in the source tree.")
return()
else()
set(_configure_reason " because BUILD_WININST_ALWAYS is ON")
endif()
endif()
message(STATUS "bdist_wininst: Configuring 'Windows Installer' named '${WININST_EXE_NAME}'${_configure_reason}")
# Configure installer
add_executable(bdist_wininst WIN32 ${WININST_HEADERS} ${WININST_SOURCES})
target_link_libraries(bdist_wininst
imagehlp
comctl32
)
set_target_properties(bdist_wininst PROPERTIES
OUTPUT_NAME ${WININST_EXE_NAME}
RUNTIME_OUTPUT_DIRECTORY ${WININST_BUILD_DIR}
)
if(CMAKE_CONFIGURATION_TYPES)
add_custom_command(TARGET bdist_wininst POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:bdist_wininst>
${WININST_BUILD_DIR}/${WININST_EXE_NAME}${CMAKE_EXECUTABLE_SUFFIX}
COMMENT "bdist_wininst: Copying installer into '${WININST_INSTALL_DIR}'"
)
endif()
install(TARGETS bdist_wininst DESTINATION ${WININST_INSTALL_DIR})
+139
View File
@@ -0,0 +1,139 @@
function(_add_executable_without_windows target_name)
# Work around the lack of a "target_remove_definitions()" CMake command by
# explicitly undefining _WINDOWS. The following alternatives are either ineffective
# or not applicable:
#
# (1) Modifying and restoring CMAKE_C_FLAGS does not work reliably, as CMake appears
# to apply cached values during the generation step after the function executes.
#
# (2) Using get_target_property/set_property to manipulate COMPILE_DEFINITIONS
# is ineffective, since /D_WINDOWS is introduced via CMAKE_C_FLAGS and not
# associated with the target's properties.
#
# See: https://gitlab.kitware.com/cmake/cmake/-/issues/19796
add_executable(${target_name} ${ARGN})
# Note: /U_WINDOWS overrides the implicit /D_WINDOWS flag, resulting in MSVC warning D9025.
# This warning is harmless and cannot be suppressed directly.
target_compile_options(${target_name} PRIVATE /U_WINDOWS)
endfunction()
# Install tree directory
set(LAUNCHER_INSTALL_DIR ${BIN_BUILD_DIR})
# Build tree directory
set(LAUNCHER_BUILD_DIR ${PROJECT_BINARY_DIR}/${LAUNCHER_INSTALL_DIR})
set(launcher_targets)
set(build_venvlauncher 0)
# While support for building "venvlauncher" was introduced in Python 3.3,
# we require at least Python 3.9 to avoid the need to generate "pythonnt_rc.h",
# which was removed in python/cpython@4efc3360c9a ("bpo-41054: Simplify resource compilation on Windows (GH-21004)", 2020-06-24).
if(PY_VERSION VERSION_GREATER_EQUAL "3.9")
set(build_venvlauncher 1)
endif()
if(build_venvlauncher)
set(target_sources
${SRC_DIR}/PC/launcher.c
${SRC_DIR}/PC/pylauncher.rc
)
set(target_include_dirs
${SRC_DIR}/PC/
)
set(target_libraries
version
)
# venvlauncher
set(target_name "venvlauncher")
_add_executable_without_windows(${target_name} ${target_sources})
target_include_directories(${target_name} PRIVATE ${target_include_dirs})
target_link_libraries(${target_name} PRIVATE ${target_libraries})
target_compile_definitions(${target_name}
PRIVATE
_CONSOLE
_UNICODE
VENV_REDIRECT
PY_ICON # For "PC/pylauncher.rc"
FIELD3=${PY_FIELD3_VALUE}
)
list(APPEND launcher_targets ${target_name})
# venvwlauncher
set(target_name "venvwlauncher")
add_executable(${target_name} WIN32 ${target_sources})
target_include_directories(${target_name} PRIVATE ${target_include_dirs})
target_link_libraries(${target_name} PRIVATE ${target_libraries})
target_compile_definitions(${target_name}
PRIVATE
_UNICODE
_WINDOWS
VENV_REDIRECT
PYW_ICON # For "PC/pylauncher.rc"
FIELD3=${PY_FIELD3_VALUE}
)
list(APPEND launcher_targets ${target_name})
endif()
set(build_pylauncher 0)
if(PY_VERSION VERSION_GREATER_EQUAL "3.11")
set(build_pylauncher 1)
endif()
if(build_pylauncher)
set(target_sources
${SRC_DIR}/PC/launcher2.c
${SRC_DIR}/PC/pylauncher.rc
)
set(target_include_dirs
${SRC_DIR}/PC/
)
set(target_libraries
pathcch
shell32
)
# pylauncher
set(target_name "pylauncher")
_add_executable_without_windows(${target_name} ${target_sources})
target_include_directories(${target_name} PRIVATE ${target_include_dirs})
target_link_libraries(${target_name} PRIVATE ${target_libraries})
target_compile_definitions(${target_name}
PRIVATE
_CONSOLE
_UNICODE
FIELD3=${PY_FIELD3_VALUE}
)
list(APPEND launcher_targets ${target_name})
# pywlauncher
set(target_name "pywlauncher")
add_executable(${target_name} WIN32 ${target_sources})
target_include_directories(${target_name} PRIVATE ${target_include_dirs})
target_link_libraries(${target_name} PRIVATE ${target_libraries})
target_compile_definitions(${target_name}
PRIVATE
_UNICODE
_WINDOWS
FIELD3=${PY_FIELD3_VALUE}
)
list(APPEND launcher_targets ${target_name})
endif()
if(launcher_targets)
set_target_properties(${launcher_targets}
PROPERTIES
LINK_FLAGS "/MANIFEST:NO"
RUNTIME_OUTPUT_DIRECTORY ${LAUNCHER_INSTALL_DIR}
)
install(TARGETS ${launcher_targets} RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
endif()
+187
View File
@@ -0,0 +1,187 @@
include(CMakeExpandImportedTargets)
macro(python_platform_test var description srcfile invert)
if(NOT DEFINED "${var}_COMPILED")
message(STATUS "${description}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${var} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
# this one translates potentially used imported library targets to their files on disk
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
else()
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
endif()
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
else()
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
endif()
try_compile(${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${srcfile}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
# OUTPUT_VARIABLE OUTPUT # Do NOT use to make cross-compiling easier
)
if(${invert} MATCHES INVERT)
if(${var}_COMPILED)
message(STATUS "${description} - no")
else()
message(STATUS "${description} - yes")
endif()
else()
if(${var}_COMPILED)
message(STATUS "${description} - yes")
else()
message(STATUS "${description} - no")
endif()
endif()
endif()
if(${invert} MATCHES INVERT)
if(${var}_COMPILED)
SET(${var} 0)
else()
SET(${var} 1)
endif()
else()
if(${var}_COMPILED)
SET(${var} 1)
else()
SET(${var} 0)
endif()
endif()
endmacro()
macro(python_platform_test_run var description srcfile invert)
if(NOT DEFINED "${var}")
message(STATUS "${description}")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${var} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LIBRARIES)
# this one translates potentially used imported library targets to their files on disk
CMAKE_EXPAND_IMPORTED_TARGETS(_ADJUSTED_CMAKE_REQUIRED_LIBRARIES LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CONFIGURATION "${CMAKE_TRY_COMPILE_CONFIGURATION}")
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${_ADJUSTED_CMAKE_REQUIRED_LIBRARIES}")
else()
set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
endif()
if(CMAKE_REQUIRED_INCLUDES)
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
else()
set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
endif()
try_run(${var} ${var}_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${srcfile}
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
"${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}"
"${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
# OUTPUT_VARIABLE OUTPUT # Do NOT use to make cross-compiling easier
)
# Note that ${var} will be a 0 return value on success.
if(NOT ${var}_COMPILED)
set(${var} -1 CACHE INTERNAL "${description} failed to compile.")
endif()
if(${invert} MATCHES INVERT)
if(${var}_COMPILED)
if(${var})
message(STATUS "${description} - yes")
else()
message(STATUS "${description} - no")
endif()
else()
message(STATUS "${description} - failed to compile")
endif()
else()
if(${var}_COMPILED)
if(${var})
message(STATUS "${description} - no")
else()
message(STATUS "${description} - yes")
endif()
else()
message(STATUS "${description} - failed to compile")
endif()
endif()
endif()
if(${invert} MATCHES INVERT)
if(${var}_COMPILED)
if(${var})
SET(${var} 1)
else()
SET(${var} 0)
endif()
else()
SET(${var} 1)
endif()
else()
if(${var}_COMPILED)
if(${var})
SET(${var} 0)
else()
SET(${var} 1)
endif()
else()
SET(${var} 0)
endif()
endif()
endmacro()
macro(python_check_function name var)
set(check_src ${PROJECT_BINARY_DIR}/CMakeFiles/ac_fn_c_check_func_${name}.c)
file(WRITE ${check_src} "
/* Define ${name} to an innocuous variant, in case <limits.h> declares ${name}.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define ${name} innocuous_${name}
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char ${name} (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef ${name}
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern \"C\"
#endif
char ${name} ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_${name} || defined __stub___${name}
choke me
#endif
int main () { return ${name} (); }
")
python_platform_test(
${var}
"Checking for ${name}"
${check_src}
DIRECT
)
endmacro()
+110
View File
@@ -0,0 +1,110 @@
set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_MODULE_PATH}
)
if(NOT DEFINED PATCH_COMMAND)
find_package(Git)
if(Git_FOUND OR GIT_FOUND)
set(PATCH_COMMAND ${GIT_EXECUTABLE} apply --whitespace=fix)
# Initialize Git repo to ensure "git apply" works when source tree
# is located within an already versioned tree.
if(NOT EXISTS "${SRC_DIR}/.git")
execute_process(
COMMAND ${GIT_EXECUTABLE} init
WORKING_DIRECTORY ${SRC_DIR}
RESULT_VARIABLE result
ERROR_VARIABLE error
ERROR_STRIP_TRAILING_WHITESPACE
OUTPUT_QUIET
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "${output}\n${error}")
endif()
endif()
else()
find_package(Patch)
if(Patch_FOUND OR PATCH_FOUND)
# Since support for git diffs which copy or rename files was
# added in patch 2.7, we can not use older version.
if("${Patch_VERSION}" VERSION_GREATER_EQUAL "2.7.0")
set(PATCH_COMMAND ${Patch_EXECUTABLE} --quiet -p1 -i)
else()
set(_reason "Found Patch executable [${Patch_EXECUTABLE}] version [${Patch_VERSION}] older than 2.7.0 missing support for copy or rename files.")
endif()
endif()
endif()
endif()
if(NOT DEFINED PATCH_COMMAND)
message(FATAL_ERROR "Could NOT find a suitable version of Git or Patch executable to apply patches. ${_reason}")
endif()
set(patches_dir "${Python_SOURCE_DIR}/patches")
function(_apply_patches _subdir)
if(NOT EXISTS ${patches_dir}/${_subdir})
message(STATUS "Skipping patches: Directory '${patches_dir}/${_subdir}' does not exist")
return()
endif()
file(GLOB _patches RELATIVE ${patches_dir} "${patches_dir}/${_subdir}/*.patch")
if(NOT _patches)
return()
endif()
message(STATUS "")
list(SORT _patches)
foreach(patch IN LISTS _patches)
set(msg "Applying '${patch}'")
message(STATUS "${msg}")
set(applied ${SRC_DIR}/.patches/${patch}.applied)
# Handle case where source tree was patched using the legacy approach.
set(legacy_applied ${PROJECT_BINARY_DIR}/CMakeFiles/patches/${patch}.applied)
if(EXISTS ${legacy_applied})
set(applied ${legacy_applied})
endif()
if(EXISTS ${applied})
message(STATUS "${msg} - skipping (already applied)")
continue()
endif()
execute_process(
COMMAND ${PATCH_COMMAND} ${patches_dir}/${patch}
WORKING_DIRECTORY ${SRC_DIR}
RESULT_VARIABLE result
ERROR_VARIABLE error
ERROR_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE output
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(result EQUAL 0)
message(STATUS "${msg} - done")
#get_filename_component(_dir ${applied} DIRECTORY)
get_filename_component(_dir ${applied} PATH)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_dir})
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${applied})
else()
message(STATUS "${msg} - failed")
message(FATAL_ERROR "${output}\n${error}")
endif()
endforeach()
message(STATUS "")
endfunction()
set(_py_version ${PY_VERSION})
# Apply patches
_apply_patches("${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}")
_apply_patches("${_py_version}")
_apply_patches("${_py_version}/${CMAKE_SYSTEM_NAME}")
_apply_patches("${_py_version}/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}")
set(_version ${CMAKE_C_COMPILER_VERSION})
if(MSVC)
set(_version ${MSVC_VERSION})
if ("${MSVC_VERSION}" VERSION_LESS "2000" AND
("${MSVC_VERSION}" VERSION_GREATER_EQUAL "1900"))
set(_version "1900")
else()
set(_version ${MSVC_VERSION})
endif()
endif()
_apply_patches("${_py_version}/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}/${_version}")
+66
View File
@@ -0,0 +1,66 @@
if(APPLE)
if(NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "By default, build for 64-bit")
endif()
if(NOT CMAKE_OSX_SDK)
execute_process(
COMMAND xcrun
--show-sdk-version
OUTPUT_VARIABLE
SDK_VERSION
RESULT_VARIABLE
res
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Transform into a two-component string (e.g "10.15.6" -> "10.15")
string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*$" "\\1" SDK_VERSION "${SDK_VERSION}")
if(res)
# Probably running on an older version of XCode, instead try to list all available
# SDKs and extract the version of the first one.
execute_process(
COMMAND xcodebuild
-showsdks
OUTPUT_VARIABLE
xcodebuild_sdks
RESULT_VARIABLE
res
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "sdk macosx([0-9\\. ]+)" output "${xcodebuild_sdks}")
if(res OR output STREQUAL "")
message(FATAL_ERROR "Failed to detect CMAKE_OSX_SDK; please set manually (e.g. \"macosx10.6\")")
endif()
set(SDK_VERSION ${CMAKE_MATCH_1})
endif()
set(CMAKE_OSX_SDK macosx${SDK_VERSION})
endif()
if(NOT CMAKE_OSX_SYSROOT)
execute_process(
COMMAND xcodebuild
-sdk ${CMAKE_OSX_SDK}
-version Path
OUTPUT_VARIABLE
CMAKE_OSX_SYSROOT
RESULT_VARIABLE
res
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res)
message(FATAL_ERROR "Cannot determine SDK path for SDK: ${CMAKE_OSX_SDK}")
endif()
endif()
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
execute_process(
COMMAND xcodebuild
-sdk ${CMAKE_OSX_SDK}
-version SDKVersion
OUTPUT_VARIABLE
CMAKE_OSX_DEPLOYMENT_TARGET
RESULT_VARIABLE
res
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(res)
message(FATAL_ERROR "Cannot determine SDK version for SDK: ${CMAKE_OSX_SDK}")
endif()
endif()
endif()
+51
View File
@@ -0,0 +1,51 @@
# PYTHON_USE_STATIC_LIB - Set to ON to force the use of the static
# library. Default is OFF.
@PACKAGE_INIT@
set(BUILD_LIBPYTHON_SHARED @BUILD_LIBPYTHON_SHARED@)
if(BUILD_LIBPYTHON_SHARED)
set(PYTHON_BUILD_SHARED 1)
set(PYTHON_BUILD_STATIC 0)
else()
set(PYTHON_BUILD_SHARED 0)
set(PYTHON_BUILD_STATIC 1)
endif()
set_and_check(PYTHON_CONFIG_DIR "@PACKAGE_CONFIG_DIR_CONFIG@")
set_and_check(PYTHON_INCLUDE_DIR "@PACKAGE_INCLUDE_DIR_CONFIG@")
set_and_check(PYTHON_TARGETS "@PACKAGE_CONFIG_DIR_CONFIG@/PythonTargets.cmake")
@PYTHON_CONFIG_CODE@
if(NOT PYTHON_TARGETS_IMPORTED)
set(PYTHON_TARGETS_IMPORTED 1)
include(${PYTHON_TARGETS})
endif()
if(TARGET libpython-shared)
set(PYTHON_LIBRARY_SHARED libpython-shared)
endif()
if(TARGET libpython-static)
set(PYTHON_LIBRARY_STATIC libpython-static)
endif()
if(NOT Python_USE_STATIC_LIB)
if(PYTHON_LIBRARY_SHARED)
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_SHARED})
elseif(PYTHON_LIBRARY_STATIC)
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_STATIC})
endif()
else()
if(PYTHON_LIBRARY_STATIC)
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_STATIC})
else()
set(PYTHON_LIBRARIES ${PYTHON_LIBRARY_SHARED})
endif()
endif()
if(NOT Python_FIND_QUIETLY)
message(STATUS "PYTHON_LIBRARIES set to ${PYTHON_LIBRARIES}")
endif()
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
+269
View File
@@ -0,0 +1,269 @@
# Given a version string of the form "X.Y.Z[rcN|[a-z]N]", extract
# major, minor, patch version as well as release level (rc, any letter)
# and serial (an integer)
#
# The function will systematically set the following variable in the caller
# scope:
#
# PY_VERSION_MAJOR - X
# PY_VERSION_MINOR - Y
# PY_VERSION_PATCH - Z
# PY_RELEASE_LEVEL - rc, a, b, c, ..., z or an empty string
# PY_RELEASE_SERIAL - an integer or an empty string
# PY_VERSION - X.Y.Z
#
function(python_extract_version_info)
set(options)
set(oneValueArgs
VERSION_STRING
)
set(multiValueArgs)
cmake_parse_arguments(MY
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
# Sanity checks
# XXX TBD
set(version_str ${MY_VERSION_STRING})
# version_str : 2.7.14 | 2.7.14rc1 | 3.6.0a4 | 3.7.0b1
# version_major : 2 | 2 | 3 | 3
# version_minor : 7 | 7 | 6 | 7
# version_patch : 14 | 14 | 0 | 0
# release_level_and_serial: | rc1 | a4 | b1
# release_level : | rc | a | b
# release_serial : | 1 | 4 | 1
# version : 2.7.14 | 2.7.14 | 3.6.0 | 3.7.0
# Code adpated from FindPythonLibs.cmake
string(REGEX REPLACE "([0-9]+)\\..+" "\\1" version_major ${version_str})
string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\..+" "\\1" version_minor ${version_str})
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" version_patch ${version_str})
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" release_level_and_serial ${version_str})
string(REGEX REPLACE "([a-z]+)[0-9]+" "\\1" release_level "${release_level_and_serial}")
string(REGEX REPLACE "[a-z]+([0-9]+)" "\\1" release_serial "${release_level_and_serial}")
set(version "${version_major}.${version_minor}.${version_patch}")
set(PY_VERSION_MAJOR ${version_major} PARENT_SCOPE)
set(PY_VERSION_MINOR ${version_minor} PARENT_SCOPE)
set(PY_VERSION_PATCH ${version_patch} PARENT_SCOPE)
set(PY_RELEASE_LEVEL ${release_level} PARENT_SCOPE)
set(PY_RELEASE_SERIAL ${release_serial} PARENT_SCOPE)
set(PY_VERSION ${version} PARENT_SCOPE)
endfunction()
#
# cmake -DTEST_python_extract_version_info:BOOL=ON -P PythonExtractVersionInfo.cmake
#
function(python_extract_version_info_test)
function(display_output_values)
foreach(varname
VERSION_MAJOR
VERSION_MINOR
VERSION_PATCH
RELEASE_LEVEL
RELEASE_SERIAL
VERSION
)
message("PY_${varname}: ${PY_${varname}}")
endforeach()
endfunction()
set(id 1)
set(case${id}_input_version_long "2.7.14")
set(case${id}_expected_PY_VERSION_MAJOR "2")
set(case${id}_expected_PY_VERSION_MINOR "7")
set(case${id}_expected_PY_VERSION_PATCH "14")
set(case${id}_expected_PY_RELEASE_LEVEL "")
set(case${id}_expected_PY_RELEASE_SERIAL "")
set(case${id}_expected_PY_VERSION "2.7.14")
set(id 2)
set(case${id}_input_version_long "2.7.14rc1")
set(case${id}_expected_PY_VERSION_MAJOR "2")
set(case${id}_expected_PY_VERSION_MINOR "7")
set(case${id}_expected_PY_VERSION_PATCH "14")
set(case${id}_expected_PY_RELEASE_LEVEL "rc")
set(case${id}_expected_PY_RELEASE_SERIAL "1")
set(case${id}_expected_PY_VERSION "2.7.14")
set(id 3)
set(case${id}_input_version_long "3.6.0a4")
set(case${id}_expected_PY_VERSION_MAJOR "3")
set(case${id}_expected_PY_VERSION_MINOR "6")
set(case${id}_expected_PY_VERSION_PATCH "0")
set(case${id}_expected_PY_RELEASE_LEVEL "a")
set(case${id}_expected_PY_RELEASE_SERIAL "4")
set(case${id}_expected_PY_VERSION "3.6.0")
set(id 4)
set(case${id}_input_version_long "10.744.42b66")
set(case${id}_expected_PY_VERSION_MAJOR "10")
set(case${id}_expected_PY_VERSION_MINOR "744")
set(case${id}_expected_PY_VERSION_PATCH "42")
set(case${id}_expected_PY_RELEASE_LEVEL "b")
set(case${id}_expected_PY_RELEASE_SERIAL "66")
set(case${id}_expected_PY_VERSION "10.744.42")
foreach(caseid RANGE 1 ${id})
set(input "${case${caseid}_input_version_long}")
python_extract_version_info(VERSION_STRING "${input}")
foreach(varname
VERSION_MAJOR
VERSION_MINOR
VERSION_PATCH
RELEASE_LEVEL
RELEASE_SERIAL
VERSION
)
set(expected_varname "case${caseid}_expected_PY_${varname}")
set(current_varname "PY_${varname}")
if(NOT "${${expected_varname}}" STREQUAL "${${current_varname}}")
message("input: ${input}")
display_output_values()
message(FATAL_ERROR "error: case ${caseid}: \n expected: ${expected_varname} [${${expected_varname}}]\n current: ${current_varname} [${${current_varname}}]")
endif()
endforeach()
endforeach()
message("SUCCESS")
endfunction()
if(TEST_python_extract_version_info)
python_extract_version_info_test()
endif()
# Compute the "Field3" value from a Python version's patch, release level, and serial.
#
# The Field3 value is defined as:
# Field3 = patch * 1000 + release_level_number * 10 + release_serial
#
# Where release_level_number is:
# - 10 for alpha (a)
# - 11 for beta (b)
# - 12 for release candidate (rc)
# - 15 for final (no pre-release tag)
#
# Arguments:
# VERSION_PATCH - Patch version (Z in X.Y.Z)
# RELEASE_LEVEL - One of 'a', 'b', 'rc', or empty
# RELEASE_SERIAL - An integer (or empty for final)
#
# Output:
# Sets variable PY_FIELD3_VALUE in the caller's scope.
function(python_compute_release_field3_value)
set(options)
set(oneValueArgs
VERSION_PATCH
RELEASE_LEVEL
RELEASE_SERIAL
)
set(multiValueArgs)
cmake_parse_arguments(MY
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
# Default ReleaseLevelNumber = 15 (final release)
set(_level_number 15)
# Map release level string to numeric code
if(MY_RELEASE_LEVEL STREQUAL "a")
set(_level_number 10)
elseif(MY_RELEASE_LEVEL STREQUAL "b")
set(_level_number 11)
elseif(MY_RELEASE_LEVEL STREQUAL "rc")
set(_level_number 12)
endif()
# Fallback for empty serial
if("${MY_RELEASE_SERIAL}" STREQUAL "")
set(MY_RELEASE_SERIAL 0)
endif()
# Convert to integers
set(_patch "${MY_VERSION_PATCH}")
set(_serial "${MY_RELEASE_SERIAL}")
math(EXPR _field3 "${_patch} * 1000 + ${_level_number} * 10 + ${_serial}")
# Return in the variable specified by caller
set(PY_FIELD3_VALUE "${_field3}" PARENT_SCOPE)
endfunction()
#
# cmake -DTEST_python_compute_release_field3_value:BOOL=ON -P PythonExtractVersionInfo.cmake
#
function(python_compute_release_field3_value_test)
function(display_field3_test_values)
message(" PATCH: ${patch}")
message(" LEVEL: ${level}")
message(" SERIAL: ${serial}")
message(" Expected: ${expected}")
message(" Computed: ${PY_FIELD3_VALUE}")
endfunction()
set(id 1)
set(case${id}_patch 2)
set(case${id}_level "") # final release
set(case${id}_serial "") # default to 0
set(case${id}_expected 2150) # 2*1000 + 15*10 + 0
set(id 2)
set(case${id}_patch 2)
set(case${id}_level a)
set(case${id}_serial 1)
set(case${id}_expected 2101) # 2*1000 + 10*10 + 1
set(id 3)
set(case${id}_patch 5)
set(case${id}_level b)
set(case${id}_serial 0)
set(case${id}_expected 5110) # 5*1000 + 11*10 + 0
set(id 4)
set(case${id}_patch 14)
set(case${id}_level rc)
set(case${id}_serial 3)
set(case${id}_expected 14123) # 14*1000 + 12*10 + 3
set(id 5)
set(case${id}_patch 0)
set(case${id}_level "") # final
set(case${id}_serial "") # default 0
set(case${id}_expected 150) # 0 * 1000 + 15 * 10 + 0
foreach(caseid RANGE 1 ${id})
set(patch "${case${caseid}_patch}")
set(level "${case${caseid}_level}")
set(serial "${case${caseid}_serial}")
set(expected "${case${caseid}_expected}")
python_compute_release_field3_value(
VERSION_PATCH "${patch}"
RELEASE_LEVEL "${level}"
RELEASE_SERIAL "${serial}"
)
if(NOT "${PY_FIELD3_VALUE}" STREQUAL "${expected}")
message("FAILED: case ${caseid}")
display_field3_test_values()
message(FATAL_ERROR "Test failed at case ${caseid}")
endif()
endforeach()
message("SUCCESS")
endfunction()
if(TEST_python_compute_release_field3_value)
python_compute_release_field3_value_test()
endif()
+53
View File
@@ -0,0 +1,53 @@
file(GLOB filenames "${PROJECT_BINARY_DIR}/${PYTHONHOME}/test/test_*.py")
list(SORT filenames)
set(unittests)
set(skipped_unittests)
# Since some tests call "support.requires(...)" spliting its arguments
# over multiple lines and the current parsing does not support the arguments
# extraction, the associated resource name is hard-coded below.
set(test_zipfile64_resource "extralargefile")
foreach(filename IN LISTS filenames)
get_filename_component(unittest ${filename} NAME_WE)
set(skip_unittest 0)
# Match only unindented support.requires(...) calls
file(STRINGS "${filename}" matches REGEX "^(support\\.requires|requires)\\([^\\)]*\\)")
if(matches) # There are support.requires() calls
foreach(match IN LISTS matches)
# Extract the FIRST quoted argument only
string(REGEX MATCH "['\"]([^'\"]*)['\"]" args "${match}")
set(expected_resource ${CMAKE_MATCH_1})
# if not in SUPPORTED_TEST_RESOURCES, skip
if(NOT "${expected_resource}" IN_LIST SUPPORTED_TEST_RESOURCES)
set(skip_unittest 1)
break()
endif()
endforeach()
endif()
# Handle hardcoded resource override (e.g., due to unsupported multi-line call)
if(DEFINED "${unittest}_resource")
set(expected_resource "${${unittest}_resource}")
if(NOT "${expected_resource}" IN_LIST SUPPORTED_TEST_RESOURCES)
set(skip_unittest 1)
endif()
endif()
if(skip_unittest)
list(APPEND skipped_unittests ${unittest})
message(STATUS " Ignoring '${unittest}' requiring '${expected_resource}' resource")
continue()
endif()
list(APPEND unittests ${unittest})
endforeach()
list(LENGTH skipped_unittests skippedcount)
list(LENGTH filenames testcount)
message(STATUS "Discovered ${testcount} tests (skipping ${skippedcount})")
+44
View File
@@ -0,0 +1,44 @@
#
# Required by Python >= 2.7.5
#
# This cmake script allows to adapt the output of sysconfig._generate_posix_vars()
# function to play nice with CMake build system.
#
# 1. Backup original pybuilddir.txt to pybuilddir.txt.backup
# 2. Read the value PYBUILDDIR written in pybuilddir.txt
# 3. Copy the file <PYBUILDDIR>/<SYSCONFIGDATA_PY> to <EXTENSION_INSTALL_DIR>
# 4. Create a new pybuilddir.txt file with <EXTENSION_INSTALL_DIR>
#
# Sanity checks
foreach(var BIN_BUILD_DIR PYTHON_BINARY_DIR EXTENSION_INSTALL_DIR SYSCONFIGDATA_PY)
if(NOT DEFINED ${var})
message(FATAL_ERROR "CMake parameter -D${var} is missing !")
endif()
endforeach()
set(_pybuilddir ${BIN_BUILD_DIR}/pybuilddir.txt)
if(NOT EXISTS ${_pybuilddir})
message(FATAL_ERROR "File ${_pybuilddir} does NOT exist")
endif()
# Backup file
if(NOT EXISTS ${_pybuilddir}.backup)
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy
${_pybuilddir} ${_pybuilddir}.backup
)
endif()
# Read PYBUILDDIR value
file(READ ${_pybuilddir}.backup PYBUILDDIR)
# Copy SYSCONFIGDATA_PY
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${BIN_BUILD_DIR}/${PYBUILDDIR}/${SYSCONFIGDATA_PY}
${PYTHON_BINARY_DIR}/${EXTENSION_INSTALL_DIR}/${SYSCONFIGDATA_PY}
)
# Create new file
file(WRITE "${_pybuilddir}" "${EXTENSION_INSTALL_DIR}")
+1
View File
@@ -0,0 +1 @@
#include "../PC/errmap.h"
+576
View File
@@ -0,0 +1,576 @@
#ifndef Py_CONFIG_H
#define Py_CONFIG_H
/* pyconfig.h. NOT Generated automatically by configure.
This is a manually maintained version (initially based
on "PC/pyconfig.h") used for (i686|x86_64)-w64-mingw32
toolchains (provided by MXE).
WINDOWS DEFINES:
The code specific to Windows should be wrapped around one of
the following #defines
MS_WIN64 - Code specific to the MS Win64 API
MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs)
MS_WINDOWS - Code specific to Windows, but all versions.
Py_ENABLE_SHARED - Code if the Python core is built as a DLL.
NOTE: The following symbols are deprecated:
NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT
MS_CORE_DLL.
WIN32 is still required for the locale module.
*/
/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */
#ifdef USE_DL_EXPORT
# define Py_BUILD_CORE
#endif /* USE_DL_EXPORT */
/* Define if you have the `hypot' function. [Python <= 3.10] */
#define HAVE_HYPOT
#define HAVE_STRFTIME
#define DONT_HAVE_SIG_ALARM
#define DONT_HAVE_SIG_PAUSE
#define LONG_BIT 32
#define WORD_BIT 32
#define PREFIX ""
#define EXEC_PREFIX ""
#define MS_WIN32 /* only support win32 and greater. */
#define MS_WINDOWS
#ifndef PYTHONPATH
# define PYTHONPATH ".\\DLLs;.\\lib;.\\lib\\plat-win;.\\lib\\lib-tk"
#endif
#define NT_THREADS
#define WITH_THREAD
#ifndef NETSCAPE_PI
#define USE_SOCKET
#endif
/* ------------------------------------------------------------------------*/
/* (i686|x86_64)-w64-mingw32 toolchains defines __MINGW32__ */
#ifndef __MINGW32__
# error "This file is should be used with MingW compiler"
#endif
#define _Py_PASTE_VERSION(SUFFIX) \
("\n[GCC v" __VERSION__ " " SUFFIX "]")
#ifndef COMPILER
# ifdef __MINGW64__
# define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
# else
# define COMPILER _Py_PASTE_VERSION("32 bit (i686)")
# endif
#endif /* !COMPILER */
/* MinGW defines __MINGWxx__ to differentiate the windows platform types
Note that for compatibility reasons __MINGW32__ is defined on Win32
*and* on Win64. For the same reasons, in Python, MS_WIN32 is
defined on Win32 *and* Win64. Win32 only code must therefore be
guarded as follows:
#if defined(MS_WIN32) && !defined(MS_WIN64)
*/
#if !defined(MS_WIN64) && defined(__MINGW64__)
# define MS_WIN64
#endif
#ifdef MS_WIN64
# define MS_WINX64
#endif
/* set the version macros for the windows headers */
#ifdef MS_WINX64
/* 64 bit only runs on XP or greater */
# define Py_WINVER _WIN32_WINNT_WINXP
# define Py_NTDDI NTDDI_WINXP
#else
/* Python 2.6+ requires Windows 2000 or greater */
# ifdef _WIN32_WINNT_WIN2K
# define Py_WINVER _WIN32_WINNT_WIN2K
# else
# define Py_WINVER 0x0500
# endif
# define Py_NTDDI NTDDI_WIN2KSP4
#endif
/* We only set these values when building Python - we don't want to force
these values on extensions, as that will affect the prototypes and
structures exposed in the Windows headers. Even when building Python, we
allow a single source file to override this - they may need access to
structures etc so it can optionally use new Windows features if it
determines at runtime they are available.
*/
#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE)
# ifndef NTDDI_VERSION
# define NTDDI_VERSION Py_NTDDI
# endif
# ifndef WINVER
# define WINVER Py_WINVER
# endif
# ifndef _WIN32_WINNT
# define _WIN32_WINNT Py_WINVER
# endif
#endif /* defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_MODULE) */
/* Define like size_t, omitting the "unsigned" */
#define HAVE_SSIZE_T 1
#include <float.h>
#define Py_IS_NAN _isnan
#define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
#define Py_IS_FINITE(X) _finite(X)
#define copysign _copysign
#include <basetsd.h>
/* ------------------------------------------------------------------------*/
/* End of compilers - finish up */
#define HAVE_IO_H
#define HAVE_SYS_UTIME_H
#define HAVE_TEMPNAM
#define HAVE_TMPFILE
#define HAVE_TMPNAM
#define HAVE_CLOCK
#define HAVE_STRERROR
#include <io.h>
#include <stdio.h>
/* 64 bit ints are usually spelt __int64 unless compiler has overridden */
/* Define this if you have the type long long. [Python <= 3.5] */
#define HAVE_LONG_LONG 1
#ifndef PY_LONG_LONG
# define PY_LONG_LONG __int64
# define PY_LLONG_MAX _I64_MAX
# define PY_LLONG_MIN _I64_MIN
# define PY_ULLONG_MAX _UI64_MAX
#endif
/* For Windows the Python core is in a DLL by default. Test
Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
# define MS_COREDLL /* deprecated old symbol */
#endif /* !MS_NO_COREDLL && ... */
/* All windows compilers that use this header support __declspec */
#define HAVE_DECLSPEC_DLL
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
#ifdef MS_COREDLL
# ifndef Py_BUILD_CORE /* not building the core - must be an ext */
# if defined(_MSC_VER)
/* So MSVC users need not specify the .lib file in
their Makefile (other compilers are generally
taken care of by distutils.) */
# ifdef _DEBUG
# pragma comment(lib,"python27_d.lib")
# else
# pragma comment(lib,"python27.lib")
# endif /* _DEBUG */
# endif /* _MSC_VER */
# endif /* Py_BUILD_CORE */
#endif /* MS_COREDLL */
#if defined(MS_WIN64)
/* maintain "win32" sys.platform for backward compatibility of Python code,
the Win64 API should be close enough to the Win32 API to make this
preferable */
# define SIZEOF_VOID_P 8
# define SIZEOF_TIME_T 8
# define SIZEOF_OFF_T 4
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 8
# define SIZEOF_SIZE_T 8
# define ALIGNOF_SIZE_T 8
/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff HAVE_LONG_LONG,
sizeof(off_t) > sizeof(long), and sizeof(PY_LONG_LONG) >= sizeof(off_t).
On Win64 the second condition is not true, but if fpos_t replaces off_t
then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64
should define this. */
# define HAVE_LARGEFILE_SUPPORT
#elif defined(MS_WIN32)
# define HAVE_LARGEFILE_SUPPORT
# define SIZEOF_VOID_P 4
# define SIZEOF_OFF_T 4
# define SIZEOF_FPOS_T 8
# define SIZEOF_HKEY 4
# define SIZEOF_SIZE_T 4
# define ALIGNOF_SIZE_T 4
# define SIZEOF_TIME_T 8
#endif
#ifdef _DEBUG
# define Py_DEBUG
#endif
#ifdef MS_WIN32
#define SIZEOF_SHORT 2
#define SIZEOF_INT 4
#define SIZEOF_LONG 4
#define ALIGNOF_LONG 4
#define SIZEOF_LONG_LONG 8
#define SIZEOF_DOUBLE 8
#define SIZEOF_FLOAT 4
/* Define to 1 if the system has the type `uintptr_t'. [Python <= 3.5] */
#define HAVE_UINTPTR_T 1
#define HAVE_INTPTR_T 1
#endif /* MS_WIN32 */
/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the
implementation of Python long integers. */
#ifndef PY_UINT32_T
#if SIZEOF_INT == 4
/* Define if your compiler provides uint32_t. [Python <= 3.5] */
#define HAVE_UINT32_T 1
#define PY_UINT32_T unsigned int
#elif SIZEOF_LONG == 4
/* Define if your compiler provides uint32_t. [Python <= 3.5] */
#define HAVE_UINT32_T 1
#define PY_UINT32_T unsigned long
#endif
#endif
#ifndef PY_UINT64_T
#if SIZEOF_LONG_LONG == 8
/* Define if your compiler provides uint64_t. [Python <= 3.5] */
#define HAVE_UINT64_T 1
#define PY_UINT64_T unsigned PY_LONG_LONG
#endif
#endif
#ifndef PY_INT32_T
#if SIZEOF_INT == 4
/* Define if your compiler provides int32_t. [Python <= 3.5] */
#define HAVE_INT32_T 1
#define PY_INT32_T int
#elif SIZEOF_LONG == 4
/* Define if your compiler provides int32_t. [Python <= 3.5] */
#define HAVE_INT32_T 1
#define PY_INT32_T long
#endif
#endif
#ifndef PY_INT64_T
#if SIZEOF_LONG_LONG == 8
#define HAVE_INT64_T 1
#define PY_INT64_T PY_LONG_LONG
#endif
#endif
/* Fairly standard from here! */
/* Define to 1 if you have the `copysign' function. [Python <= 3.10] */
#define HAVE_COPYSIGN 1
/* Define to 1 if you have the `round' function. [Python <= 3.10] */
#define HAVE_ROUND 1
/* Define to 1 if you have the `isinf' macro. [Python <= 3.10] */
#define HAVE_DECL_ISINF 1
/* Define to 1 if you have the `isnan' function. [Python <= 3.10] */
#define HAVE_DECL_ISNAN 1
/* Define if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
/* #undef _ALL_SOURCE */
#endif
/* Define to empty if the keyword does not work. */
/* #define const */
/* Define to 1 if you have the <conio.h> header file. */
#define HAVE_CONIO_H 1
/* Define to 1 if you have the <direct.h> header file. */
#define HAVE_DIRECT_H 1
/* Define if you have dirent.h. */
#define HAVE_DIRENT_H 1
/* Define to the type of elements in the array set by `getgroups'.
Usually this is either `int' or `gid_t'. */
/* #undef GETGROUPS_T */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef gid_t */
/* Define if your struct tm has tm_zone. */
/* #undef HAVE_TM_ZONE */
/* Define if you don't have tm_zone but do have the external array
tzname. */
#define HAVE_TZNAME
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef mode_t */
/* Define if you don't have dirent.h, but have ndir.h. */
/* #undef NDIR */
/* Define to `long' if <sys/types.h> doesn't define. */
/* #undef off_t */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef pid_t */
/* Define if the system does not provide POSIX.1 features except
with this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define if you need to in order for stat and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define to `unsigned' if <sys/types.h> doesn't define. */
/* #undef size_t */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you don't have dirent.h, but have sys/dir.h. */
/* #undef SYSDIR */
/* Define if you don't have dirent.h, but have sys/ndir.h. */
/* #undef SYSNDIR */
/* Define if you can safely include both <sys/time.h> and <time.h>. [Python <= 3.11] */
/* #undef TIME_WITH_SYS_TIME */
/* Define if your <sys/time.h> declares struct tm. */
/* #define TM_IN_SYS_TIME 1 */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef uid_t */
/* Define if the closedir function returns void instead of int. */
/* #undef VOID_CLOSEDIR */
/* Define if getpgrp() must be called as getpgrp(0)
and (consequently) setpgrp() as setpgrp(0, 0). */
/* #undef GETPGRP_HAVE_ARGS */
/* Define this if your time.h defines altzone */
/* #define HAVE_ALTZONE */
/* Define if you have the putenv function. [Python <= 3.8] */
#define HAVE_PUTENV
/* Define if your compiler supports function prototypes */
#define HAVE_PROTOTYPES
/* Define if you can safely include both <sys/select.h> and <sys/time.h>
(which you can't on SCO ODT 3.0). */
/* #undef SYS_SELECT_WITH_SYS_TIME */
/* Define if you want documentation strings in extension modules */
#define WITH_DOC_STRINGS 1
/* Define if you want to compile in rudimentary thread support */
/* #undef WITH_THREAD */
/* Define if you want to use the GNU readline library */
/* #define WITH_READLINE 1 */
/* Define as the size of the unicode type. [Python 2.7 to 3.2] */
/* This is enough for unicodeobject.h to do the "right thing" on Windows. */
#define Py_UNICODE_SIZE 2
/* Use Python's own small-block memory-allocator. */
#define WITH_PYMALLOC 1
/* Define if you want to compile in object freelists optimization [Python 3.11] */
#define WITH_FREELISTS 1
/* Define if you have clock. */
/* #define HAVE_CLOCK */
/* Define when any dynamic module loading is enabled */
#define HAVE_DYNAMIC_LOADING
/* Define if you have ftime. */
#define HAVE_FTIME
/* Define if you have getpeername. */
#define HAVE_GETPEERNAME
/* Define if you have getpgrp. */
/* #undef HAVE_GETPGRP */
/* Define if you have getpid. */
#define HAVE_GETPID
/* Define if you have gettimeofday. [Python <= 3.8] */
/* #undef HAVE_GETTIMEOFDAY */
/* Define if you have getwd. */
/* #undef HAVE_GETWD */
/* Define if you have lstat. */
/* #undef HAVE_LSTAT */
/* Define if you have the mktime function. */
#define HAVE_MKTIME
/* Define if you have nice. */
/* #undef HAVE_NICE */
/* Define if you have readlink. */
/* #undef HAVE_READLINK */
/* Define if you have select. [Python <= 3.6] */
/* #undef HAVE_SELECT */
/* Define if you have setpgid. */
/* #undef HAVE_SETPGID */
/* Define if you have setpgrp. */
/* #undef HAVE_SETPGRP */
/* Define if you have setsid. */
/* #undef HAVE_SETSID */
/* Define if you have setvbuf. */
#define HAVE_SETVBUF
/* Define if you have siginterrupt. */
/* #undef HAVE_SIGINTERRUPT */
/* Define if you have symlink. */
/* #undef HAVE_SYMLINK */
/* Define if you have tcgetpgrp. */
/* #undef HAVE_TCGETPGRP */
/* Define if you have tcsetpgrp. */
/* #undef HAVE_TCSETPGRP */
/* Define if you have times. */
/* #undef HAVE_TIMES */
/* Define if you have uname. */
/* #undef HAVE_UNAME */
/* Define if you have waitpid. */
/* #undef HAVE_WAITPID */
/* Define to 1 if you have the `wcscoll' function. */
#define HAVE_WCSCOLL 1
/* Define if the zlib library has inflateCopy */
#define HAVE_ZLIB_COPY 1
/* Define if you have the <dlfcn.h> header file. */
/* #undef HAVE_DLFCN_H */
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <process.h> header file. */
#define HAVE_PROCESS_H 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <stdarg.h> prototypes. [Python <= 3.11] */
#define HAVE_STDARG_PROTOTYPES
/* Define if you have the <stddef.h> header file. */
#define HAVE_STDDEF_H 1
/* Define if you have the <sys/audioio.h> header file. */
/* #undef HAVE_SYS_AUDIOIO_H */
/* Define if you have the <sys/param.h> header file. */
/* #define HAVE_SYS_PARAM_H 1 */
/* Define if you have the <sys/select.h> header file. */
/* #define HAVE_SYS_SELECT_H 1 */
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
/* #define HAVE_SYS_TIME_H 1 */
/* Define if you have the <sys/times.h> header file. */
/* #define HAVE_SYS_TIMES_H 1 */
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/un.h> header file. */
/* #define HAVE_SYS_UN_H 1 */
/* Define if you have the <sys/utime.h> header file. */
/* #define HAVE_SYS_UTIME_H 1 */
/* Define if you have the <sys/utsname.h> header file. */
/* #define HAVE_SYS_UTSNAME_H 1 */
/* Define if you have the <unistd.h> header file. */
/* #define HAVE_UNISTD_H 1 */
/* Define if you have the <utime.h> header file. */
/* #define HAVE_UTIME_H 1 */
/* Define if the compiler provides a wchar.h header file. */
#define HAVE_WCHAR_H 1
/* Define if you have the dl library (-ldl). */
/* #undef HAVE_LIBDL */
/* Define if you have the mpc library (-lmpc). */
/* #undef HAVE_LIBMPC */
/* Define if you have the nsl library (-lnsl). */
#define HAVE_LIBNSL 1
/* Define if you have the seq library (-lseq). */
/* #undef HAVE_LIBSEQ */
/* Define if you have the socket library (-lsocket). */
#define HAVE_LIBSOCKET 1
/* Define if you have the sun library (-lsun). */
/* #undef HAVE_LIBSUN */
/* Define if you have the termcap library (-ltermcap). */
/* #undef HAVE_LIBTERMCAP */
/* Define if you have the termlib library (-ltermlib). */
/* #undef HAVE_LIBTERMLIB */
/* Define if you have the thread library (-lthread). */
/* #undef HAVE_LIBTHREAD */
/* WinSock does not use a bitmask in select, and uses
socket handles greater than FD_SETSIZE */
#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
least significant byte first */
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1
#endif /* !Py_CONFIG_H */
File diff suppressed because it is too large Load Diff
+58
View File
@@ -0,0 +1,58 @@
#include "Python.h"
#ifdef __cplusplus
extern "C" {
#endif
@config_inits@
/* -- ADDMODULE MARKER 1 -- */
extern PyObject* PyMarshal_Init(void);
extern PyObject* @PyInit_imp@(void);
extern PyObject* PyInit_gc(void);
extern PyObject* PyInit__ast(void);
extern PyObject* _PyWarnings_Init(void);
extern PyObject* PyInit__string(void);
extern PyObject* PyInit__signal(void);
struct _inittab _PyImport_Inittab[] = {
@config_entries@
/* -- ADDMODULE MARKER 2 -- */
/* This module lives in marshal.c */
{"marshal", PyMarshal_Init},
/* This lives in import.c */
{"_imp", @PyInit_imp@},
/* This lives in Python/Python-ast.c */
{"_ast", PyInit__ast},
/* These entries are here for sys.builtin_module_names */
{"builtins", NULL},
{"sys", NULL},
/* This lives in gcmodule.c */
{"gc", PyInit_gc},
/* This lives in _warnings.c */
{"_warnings", _PyWarnings_Init},
/* This lives in Objects/unicodeobject.c */
{"_string", PyInit__string},
{"_signal", PyInit__signal},
/* Sentinel */
{0, 0}
};
#ifdef __cplusplus
}
#endif
View File
File diff suppressed because it is too large Load Diff
+402
View File
@@ -0,0 +1,402 @@
/* -----------------------------------------------------------------*-C-*-
libffi 3.0.10rc0 - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/* -------------------------------------------------------------------
The basic API is described in the README file.
The raw API is designed to bypass some of the argument packing
and unpacking on architectures for which it can be avoided.
The closure API allows interpreted functions to be packaged up
inside a C function pointer, so that they can be called as C functions,
with no understanding on the client side that they are interpreted.
It can also be used in other cases in which it is necessary to package
up a user specified parameter and a function pointer as a single
function pointer.
The closure API must be implemented in order to get its functionality,
e.g. for use by gij. Routines are provided to emulate the raw API
if the underlying platform doesn't allow faster implementation.
More details on the raw and cloure API can be found in:
http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
and
http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
-------------------------------------------------------------------- */
#ifndef LIBFFI_H
#define LIBFFI_H
#ifdef __cplusplus
extern "C" {
#endif
/* Specify which architecture libffi is configured for. */
#define X86_64
/* ---- System configuration information --------------------------------- */
#include <ffitarget.h>
#ifndef LIBFFI_ASM
#ifdef _MSC_VER
#define __attribute__(X)
#endif
#include <stddef.h>
#include <limits.h>
/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
But we can find it either under the correct ANSI name, or under GNU
C's internal name. */
#ifdef LONG_LONG_MAX
# define FFI_LONG_LONG_MAX LONG_LONG_MAX
#else
# ifdef LLONG_MAX
# define FFI_LONG_LONG_MAX LLONG_MAX
# else
# ifdef __GNUC__
# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
# endif
# endif
#endif
/* The closure code assumes that this works on pointers, i.e. a size_t */
/* can hold a pointer. */
typedef struct _ffi_type
{
size_t size;
unsigned short alignment;
unsigned short type;
struct _ffi_type **elements;
} ffi_type;
#ifndef LIBFFI_HIDE_BASIC_TYPES
#if SCHAR_MAX == 127
# define ffi_type_uchar ffi_type_uint8
# define ffi_type_schar ffi_type_sint8
#else
#error "char size not supported"
#endif
#if SHRT_MAX == 32767
# define ffi_type_ushort ffi_type_uint16
# define ffi_type_sshort ffi_type_sint16
#elif SHRT_MAX == 2147483647
# define ffi_type_ushort ffi_type_uint32
# define ffi_type_sshort ffi_type_sint32
#else
#error "short size not supported"
#endif
#if INT_MAX == 32767
# define ffi_type_uint ffi_type_uint16
# define ffi_type_sint ffi_type_sint16
#elif INT_MAX == 2147483647
# define ffi_type_uint ffi_type_uint32
# define ffi_type_sint ffi_type_sint32
#elif INT_MAX == 9223372036854775807
# define ffi_type_uint ffi_type_uint64
# define ffi_type_sint ffi_type_sint64
#else
#error "int size not supported"
#endif
#if LONG_MAX == 2147483647
# if FFI_LONG_LONG_MAX != 9223372036854775807
#error "no 64-bit data type supported"
# endif
#elif LONG_MAX != 9223372036854775807
#error "long size not supported"
#endif
#if LONG_MAX == 2147483647
# define ffi_type_ulong ffi_type_uint32
# define ffi_type_slong ffi_type_sint32
#elif LONG_MAX == 9223372036854775807
# define ffi_type_ulong ffi_type_uint64
# define ffi_type_slong ffi_type_sint64
#else
#error "long size not supported"
#endif
/* These are defined in types.c */
extern ffi_type ffi_type_void;
extern ffi_type ffi_type_uint8;
extern ffi_type ffi_type_sint8;
extern ffi_type ffi_type_uint16;
extern ffi_type ffi_type_sint16;
extern ffi_type ffi_type_uint32;
extern ffi_type ffi_type_sint32;
extern ffi_type ffi_type_uint64;
extern ffi_type ffi_type_sint64;
extern ffi_type ffi_type_float;
extern ffi_type ffi_type_double;
extern ffi_type ffi_type_pointer;
#if 1
extern ffi_type ffi_type_longdouble;
#else
#define ffi_type_longdouble ffi_type_double
#endif
#endif /* LIBFFI_HIDE_BASIC_TYPES */
typedef enum {
FFI_OK = 0,
FFI_BAD_TYPEDEF,
FFI_BAD_ABI
} ffi_status;
typedef unsigned FFI_TYPE;
typedef struct {
ffi_abi abi;
unsigned nargs;
ffi_type **arg_types;
ffi_type *rtype;
unsigned bytes;
unsigned flags;
#ifdef FFI_EXTRA_CIF_FIELDS
FFI_EXTRA_CIF_FIELDS;
#endif
} ffi_cif;
/* ---- Definitions for the raw API -------------------------------------- */
#ifndef FFI_SIZEOF_ARG
# if LONG_MAX == 2147483647
# define FFI_SIZEOF_ARG 4
# elif LONG_MAX == 9223372036854775807
# define FFI_SIZEOF_ARG 8
# endif
#endif
#ifndef FFI_SIZEOF_JAVA_RAW
# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG
#endif
typedef union {
ffi_sarg sint;
ffi_arg uint;
float flt;
char data[FFI_SIZEOF_ARG];
void* ptr;
} ffi_raw;
#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8
/* This is a special case for mips64/n32 ABI (and perhaps others) where
sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */
typedef union {
signed int sint;
unsigned int uint;
float flt;
char data[FFI_SIZEOF_JAVA_RAW];
void* ptr;
} ffi_java_raw;
#else
typedef ffi_raw ffi_java_raw;
#endif
void ffi_raw_call (ffi_cif *cif,
void (*fn)(void),
void *rvalue,
ffi_raw *avalue);
void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
size_t ffi_raw_size (ffi_cif *cif);
/* This is analogous to the raw API, except it uses Java parameter */
/* packing, even on 64-bit machines. I.e. on 64-bit machines */
/* longs and doubles are followed by an empty 64-bit word. */
void ffi_java_raw_call (ffi_cif *cif,
void (*fn)(void),
void *rvalue,
ffi_java_raw *avalue);
void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw);
void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args);
size_t ffi_java_raw_size (ffi_cif *cif);
/* ---- Definitions for closures ----------------------------------------- */
#if FFI_CLOSURES
#ifdef _MSC_VER
__declspec(align(8))
#endif
typedef struct {
char tramp[FFI_TRAMPOLINE_SIZE];
ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data;
#ifdef __GNUC__
} ffi_closure __attribute__((aligned (8)));
#else
} ffi_closure;
#endif
void *ffi_closure_alloc (size_t size, void **code);
void ffi_closure_free (void *);
ffi_status
ffi_prep_closure (ffi_closure*,
ffi_cif *,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data);
ffi_status
ffi_prep_closure_loc (ffi_closure*,
ffi_cif *,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data,
void*codeloc);
typedef struct {
char tramp[FFI_TRAMPOLINE_SIZE];
ffi_cif *cif;
#if !FFI_NATIVE_RAW_API
/* if this is enabled, then a raw closure has the same layout
as a regular closure. We use this to install an intermediate
handler to do the transaltion, void** -> ffi_raw*. */
void (*translate_args)(ffi_cif*,void*,void**,void*);
void *this_closure;
#endif
void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
void *user_data;
} ffi_raw_closure;
typedef struct {
char tramp[FFI_TRAMPOLINE_SIZE];
ffi_cif *cif;
#if !FFI_NATIVE_RAW_API
/* if this is enabled, then a raw closure has the same layout
as a regular closure. We use this to install an intermediate
handler to do the transaltion, void** -> ffi_raw*. */
void (*translate_args)(ffi_cif*,void*,void**,void*);
void *this_closure;
#endif
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*);
void *user_data;
} ffi_java_raw_closure;
ffi_status
ffi_prep_raw_closure (ffi_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data);
ffi_status
ffi_prep_raw_closure_loc (ffi_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data,
void *codeloc);
ffi_status
ffi_prep_java_raw_closure (ffi_java_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data);
ffi_status
ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*),
void *user_data,
void *codeloc);
#endif /* FFI_CLOSURES */
/* ---- Public interface definition -------------------------------------- */
ffi_status ffi_prep_cif(ffi_cif *cif,
ffi_abi abi,
unsigned int nargs,
ffi_type *rtype,
ffi_type **atypes);
void ffi_call(ffi_cif *cif,
void (*fn)(void),
void *rvalue,
void **avalue);
/* Useful for eliminating compiler warnings */
#define FFI_FN(f) ((void (*)(void))f)
/* ---- Definitions shared with assembly code ---------------------------- */
#endif
/* If these change, update src/mips/ffitarget.h. */
#define FFI_TYPE_VOID 0
#define FFI_TYPE_INT 1
#define FFI_TYPE_FLOAT 2
#define FFI_TYPE_DOUBLE 3
#if 1
#define FFI_TYPE_LONGDOUBLE 4
#else
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
#endif
#define FFI_TYPE_UINT8 5
#define FFI_TYPE_SINT8 6
#define FFI_TYPE_UINT16 7
#define FFI_TYPE_SINT16 8
#define FFI_TYPE_UINT32 9
#define FFI_TYPE_SINT32 10
#define FFI_TYPE_UINT64 11
#define FFI_TYPE_SINT64 12
#define FFI_TYPE_STRUCT 13
#define FFI_TYPE_POINTER 14
/* This should always refer to the last type code (for sanity checks) */
#define FFI_TYPE_LAST FFI_TYPE_POINTER
#ifdef __cplusplus
}
#endif
#endif
+207
View File
@@ -0,0 +1,207 @@
/* fficonfig.h. Generated from fficonfig.h.in by configure. */
/* fficonfig.h.in. Generated from configure.ac by autoheader. */
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
/* #undef CRAY_STACKSEG_END */
/* Define to 1 if using `alloca.c'. */
/* #undef C_ALLOCA */
/* Define to the flags needed for the .section .eh_frame directive. */
#define EH_FRAME_FLAGS "aw"
/* Define this if you want extra debugging. */
/* #undef FFI_DEBUG */
/* Cannot use PROT_EXEC on this target, so, we revert to alternative means */
#cmakedefine FFI_EXEC_TRAMPOLINE_TABLE 1
/* Define this if you want to enable pax emulated trampolines */
#cmakedefine FFI_MMAP_EXEC_EMUTRAMP_PAX 1
/* Cannot use malloc on this target, so, we revert to alternative means */
/* #undef FFI_MMAP_EXEC_WRIT */
/* Define this if you do not want support for the raw API. */
/* #undef FFI_NO_RAW_API */
/* Define this if you do not want support for aggregate types. */
/* #undef FFI_NO_STRUCTS */
/* Define to 1 if you have `alloca', as a function or macro. */
#cmakedefine HAVE_ALLOCA 1
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#cmakedefine HAVE_ALLOCA_H 1
/* Define if your assembler supports .ascii. */
#cmakedefine HAVE_AS_ASCII_PSEUDO_OP 1
/* Define if your assembler supports .cfi_* directives. */
#cmakedefine HAVE_AS_CFI_PSEUDO_OP 1
/* Define if your assembler supports .register. */
/* #undef HAVE_AS_REGISTER_PSEUDO_OP */
/* Define if your assembler and linker support unaligned PC relative relocs.
*/
/* #undef HAVE_AS_SPARC_UA_PCREL */
/* Define if your assembler supports .string. */
#cmakedefine HAVE_AS_STRING_PSEUDO_OP 1
/* Define if your assembler supports unwind section type. */
#cmakedefine HAVE_AS_X86_64_UNWIND_SECTION_TYPE 1
/* Define if your assembler supports PC relative relocs. */
#cmakedefine HAVE_AS_X86_PCREL 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H 1
/* Define if __attribute__((visibility("hidden"))) is supported. */
#cmakedefine HAVE_HIDDEN_VISIBILITY_ATTRIBUTE 1
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H 1
/* Define if you have the long double type and it is bigger than a double */
#cmakedefine HAVE_LONG_DOUBLE 1
/* Define if you support more than one size of the long double type */
#cmakedefine HAVE_LONG_DOUBLE_VARIANT 1
/* Define to 1 if you have the `memcpy' function. */
#cmakedefine HAVE_MEMCPY 1
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H 1
/* Define to 1 if you have the `mmap' function. */
#cmakedefine HAVE_MMAP 1
/* Define if mmap with MAP_ANON(YMOUS) works. */
#cmakedefine HAVE_MMAP_ANON 1
/* Define if mmap of /dev/zero works. */
#cmakedefine HAVE_MMAP_DEV_ZERO 1
/* Define if read-only mmap of a plain file works. */
#cmakedefine HAVE_MMAP_FILE 1
/* Define if .eh_frame sections should be read-only. */
#cmakedefine HAVE_RO_EH_FRAME 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */
#cmakedefine HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Name of package */
#define PACKAGE "libffi"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "http://github.com/atgreen/libffi/issues"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libffi"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libffi @LIBFFI_VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libffi"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "@LIBFFI_VERSION@"
/* The size of `double', as computed by sizeof. */
#cmakedefine SIZEOF_DOUBLE @SIZEOF_DOUBLE@
/* The size of `long double', as computed by sizeof. */
#cmakedefine SIZEOF_LONG_DOUBLE @SIZEOF_LONG_DOUBLE@
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
/* #undef STACK_DIRECTION */
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine STDC_HEADERS 1
/* Define if symbols are underscored. */
#cmakedefine SYMBOL_UNDERSCORE 1
/* Define this if you are using Purify and want to suppress spurious messages.
*/
/* #undef USING_PURIFY */
/* Version number of package */
#define VERSION "@LIBFFI_VERSION@"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
#ifdef HAVE_HIDDEN_VISIBILITY_ATTRIBUTE
#ifdef LIBFFI_ASM
#define FFI_HIDDEN(name) .hidden name
#else
#define FFI_HIDDEN __attribute__ ((visibility ("hidden")))
#endif
#else
#ifdef LIBFFI_ASM
#define FFI_HIDDEN(name)
#else
#define FFI_HIDDEN
#endif
#endif
+14
View File
@@ -0,0 +1,14 @@
# Install all the header files in Include/
set(includedir ${INCLUDE_BUILD_DIR})
file(GLOB_RECURSE hfiles RELATIVE ${includedir} "${includedir}/*")
foreach(file ${hfiles})
get_filename_component(path ${file} PATH)
if(WIN32)
file(COPY ${includedir}/${file} DESTINATION ${PROJECT_BINARY_DIR}/${INCLUDE_INSTALL_DIR}/${path})
endif()
if(INSTALL_DEVELOPMENT)
install(FILES ${includedir}/${file} DESTINATION ${INCLUDE_INSTALL_DIR}/${path} COMPONENT Development)
endif()
endforeach()
+56
View File
@@ -0,0 +1,56 @@
# Install all the python module source from Lib/
set(libdir ${SRC_DIR}/Lib)
file(GLOB_RECURSE libfiles RELATIVE ${libdir} "${libdir}/*")
if(UNIX)
set(plat_subdir "plat-linux")
endif()
foreach(file ${libfiles})
# Don't install files for other platforms
string(REGEX MATCH "^plat-" is_platform_file "${file}")
if(plat_subdir)
string(REGEX MATCH "^${plat_subdir}" is_matching_platform_file "${file}")
endif()
# Exclude tests if BUILD_TESTING is OFF
string(REGEX MATCH "^test" is_test "${file}")
set(include_file 1)
if(is_test AND (NOT BUILD_TESTING OR NOT INSTALL_TEST))
set(include_file 0)
endif()
if(include_file AND (NOT is_platform_file OR is_matching_platform_file))
get_filename_component(path ${file} PATH)
# Copy lib files to build tree
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${PYTHONHOME}/${path})
file(COPY ${libdir}/${file} DESTINATION ${PROJECT_BINARY_DIR}/${PYTHONHOME}/${path})
# Install
install(FILES ${libdir}/${file} DESTINATION ${PYTHONHOME}/${path})
endif()
endforeach()
# Generate grammar tables in install directory
# XXX Should a custom target be added to generate file at built time ?
install(CODE "find_program(
PYTHON_EXECUTABLE python
HINTS \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}
NO_DEFAULT_PATH)
set(wrapper)
if(UNIX)
set(_envvar LD_LIBRARY_PATH)
if(APPLE)
set(_envvar DYLD_LIBRARY_PATH)
endif()
set(wrapper env \${_envvar}=\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${LIBPYTHON_LIBDIR})
endif()
execute_process(COMMAND \${wrapper} \${PYTHON_EXECUTABLE} -m lib2to3.pgen2.driver
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${PYTHONHOME}/lib2to3/Grammar.txt)
execute_process(COMMAND \${wrapper} \${PYTHON_EXECUTABLE} -m lib2to3.pgen2.driver
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${PYTHONHOME}/lib2to3/PatternGrammar.txt)
")
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,16 @@
# Sanity checks
foreach(varname INPUT_DEF_FILE OUTPUT_DEF_FILE)
if(NOT DEFINED ${varname})
message(FATAL_ERROR "Variable '${varname}' is not defined.")
endif()
endforeach()
file(STRINGS ${INPUT_DEF_FILE} def_lines REGEX "^ (.+)=.+$")
set(stub_def_lines "EXPORTS\n")
foreach(line IN LISTS def_lines)
string(REGEX MATCH "^ (.+)=.+$" output ${line})
if(NOT "${output}" STREQUAL "")
set(stub_def_lines "${stub_def_lines}${CMAKE_MATCH_1}\n")
endif()
endforeach()
file(WRITE ${OUTPUT_DEF_FILE} "${stub_def_lines}")
+203
View File
@@ -0,0 +1,203 @@
# === Variables set by makesetup ===
MODOBJS=
MODLIBS=
# === Variables set by configure
VERSION= @LIBPYTHON_VERSION@
srcdir= @SRC_DIR@
CC= @CMAKE_C_COMPILER@ @CMAKE_C_COMPILER_ARG1@ -pthread
CXX= @CMAKE_CXX_COMPILER@ @CMAKE_CXX_COMPILER_ARG1@ -pthread
MAINCC= $(CC)
LINKCC= $(PURIFY) $(MAINCC)
AR= @CMAKE_AR@
RANLIB= @CMAKE_RANLIB@
SOABI= @SOABI@
LDVERSION= $(VERSION)$(ABIFLAGS)
SVNVERSION= svnversion $(srcdir)
HGVERSION=
HGTAG=
HGBRANCH=
GNULD= yes
# Shell used by make (some versions default to the login shell, which is bad)
SHELL= /bin/sh
# Use this to make a link between python$(VERSION) and python in $(BINDIR)
LN= ln
# Portable install script (configure doesn't always guess right)
INSTALL= /usr/bin/install -c
INSTALL_PROGRAM=${INSTALL}
INSTALL_SCRIPT= ${INSTALL}
INSTALL_DATA= ${INSTALL} -m 644
# Shared libraries must be installed with executable mode on some systems;
# rather than figuring out exactly which, we always give them executable mode.
# Also, making them read-only seems to be a good idea...
INSTALL_SHARED= ${INSTALL} -m 555
MAKESETUP= $(srcdir)/Modules/makesetup
# Compiler options
OPT= @CMAKE_C_FLAGS@ -DNDEBUG
BASECFLAGS= -Wno-unused-result -Wsign-compare -Wunreachable-code
CFLAGS= @CMAKE_C_FLAGS@
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
# be able to build extension modules using the directories specified in the
# environment variables
CPPFLAGS= @CMAKE_CXX_FLAGS@
LDFLAGS=
LDLAST=
SGI_ABI=
CCSHARED= -fPIC
LINKFORSHARED= -Xlinker -export-dynamic
ARFLAGS= rc
# Extra C flags added for building the interpreter object files.
CFLAGSFORSHARED=
# C flags used for building the interpreter object files
PY_CFLAGS= @CMAKE_C_FLAGS@ -DPy_BUILD_CORE
# Machine-dependent subdirectories
MACHDEP= @PY_PLATFORM@
# Install prefix for architecture-independent files
prefix= @CMAKE_INSTALL_PREFIX@
# Install prefix for architecture-dependent files
exec_prefix= ${prefix}
# Install prefix for data files
datarootdir= ${prefix}/share
# Expanded directories
BINDIR= ${exec_prefix}/bin
LIBDIR= ${exec_prefix}/lib
MANDIR= ${datarootdir}/man
INCLUDEDIR= ${prefix}/include
CONFINCLUDEDIR= $(exec_prefix)/include
SCRIPTDIR= $(prefix)/lib
ABIFLAGS= @ABIFLAGS@
# Detailed destination directories
BINLIBDEST= $(LIBDIR)/python$(VERSION)
LIBDEST= $(SCRIPTDIR)/python$(VERSION)
INCLUDEPY= $(INCLUDEDIR)/python$(LDVERSION)
CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION)
LIBP= $(LIBDIR)/python$(VERSION)
# Symbols used for using shared libraries
SHLIB_SUFFIX= .so
EXT_SUFFIX= .$(SOABI).so
SO= .so
LDSHARED= $(CC) @MAKEFILE_LDSHARED_FLAGS@ $(LDFLAGS)
BLDSHARED= $(CC) @MAKEFILE_LDSHARED_FLAGS@ $(LDFLAGS)
LDCXXSHARED= $(CXX) @MAKEFILE_LDSHARED_FLAGS@
DESTSHARED= $(BINLIBDEST)/lib-dynload
# Executable suffix (.exe on Windows and Mac OS X)
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=
# 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.
MACOSX_DEPLOYMENT_TARGET=@CMAKE_OSX_DEPLOYMENT_TARGET@
#export MACOSX_DEPLOYMENT_TARGET
# Environment to run shared python without installed libraries
RUNSHARED=
# Modes for directories, executables and data files created by the
# install process. Default to user-only-writable for all file types.
DIRMODE= 755
EXEMODE= 755
FILEMODE= 644
# configure script arguments
CONFIG_ARGS= '--prefix' '@CMAKE_INSTALL_PREFIX@'
# Subdirectories with code
SRCDIRS= Parser Grammar Objects Python Modules Mac
# Other subdirectories
SUBDIRSTOO= Include Lib Misc Demo
# Files and directories to be distributed
CONFIGFILES= configure configure.in acconfig.h pyconfig.h.in Makefile.pre.in
DISTFILES= README ChangeLog $(CONFIGFILES)
DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
DIST= $(DISTFILES) $(DISTDIRS)
LIBRARY= libpython$(VERSION)$(ABIFLAGS).a
LDLIBRARY= libpython$(VERSION)$(ABIFLAGS).a
BLDLIBRARY= $(LDLIBRARY)
DLLLIBRARY=
LDLIBRARYDIR=
INSTSONAME= $(LDLIBRARY)
LIBS= -lpthread -ldl -lutil
LIBM= -lm
LIBC=
SYSLIBS= $(LIBM) $(LIBC)
SHLIBS= $(LIBS)
PYTHON= python$(EXE)
BUILDPYTHON= python$(BUILDEXE)
PYTHON_FOR_BUILD=./$(BUILDPYTHON) -E
_PYTHON_HOST_PLATFORM=
BUILD_GNU_TYPE= x86_64-unknown-linux-gnu
HOST_GNU_TYPE= x86_64-unknown-linux-gnu
# === Definitions added by makesetup ===
LOCALMODLIBS=
BASEMODLIBS=
GLHACK=-Dclear=__GLclear
PYTHONPATH=$(COREPYTHONPATH)
COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH)
OLDPATH=:lib-old
TKPATH=:lib-tk
EXTRAMACHDEPPATH=
MACHDEPPATH=:plat-$(MACHDEP)
TESTPATH=
SITEPATH=
DESTPATH=
MACHDESTLIB=$(BINLIBDEST)
DESTLIB=$(LIBDEST)
LIBFFI_INCLUDEDIR=
#########################################################################
# Rules
# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
# minimal framework (not including the Lib directory and such) in the current
# directory.
RESSRCDIR=Mac/Resources/framework
# Install the library
PLATDIR= plat-$(MACHDEP)
EXTRAPLATDIR=
EXTRAMACHDEPPATH=
# Install the library and miscellaneous stuff needed for extending/embedding
# This goes into $(exec_prefix)
LIBPL= $(LIBP)/config
# pkgconfig directory
LIBPC= $(LIBDIR)/pkgconfig
+125
View File
@@ -0,0 +1,125 @@
// Based on code in Python's `configure` script (see conftest.c)
#include <stdio.h>
#undef bfin
#undef cris
#undef fr30
#undef linux
#undef hppa
#undef hpux
#undef i386
#undef mips
#undef powerpc
#undef sparc
#undef unix
char *PLATFORM_TRIPLET =
#if defined(__linux__)
# if defined(__x86_64__) && defined(__LP64__)
"x86_64-linux-gnu"
# elif defined(__x86_64__) && defined(__ILP32__)
"x86_64-linux-gnux32"
# elif defined(__i386__)
"i386-linux-gnu"
# elif defined(__aarch64__) && defined(__AARCH64EL__)
# if defined(__ILP32__)
"aarch64_ilp32-linux-gnu"
# else
"aarch64-linux-gnu"
# endif
# elif defined(__aarch64__) && defined(__AARCH64EB__)
# if defined(__ILP32__)
"aarch64_be_ilp32-linux-gnu"
# else
"aarch64_be-linux-gnu"
# endif
# elif defined(__alpha__)
"alpha-linux-gnu"
# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)
# if defined(__ARMEL__)
"arm-linux-gnueabihf"
# else
"armeb-linux-gnueabihf"
# endif
# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
# if defined(__ARMEL__)
"arm-linux-gnueabi"
# else
"armeb-linux-gnueabi"
# endif
# elif defined(__hppa__)
"hppa-linux-gnu"
# elif defined(__ia64__)
"ia64-linux-gnu"
# elif defined(__m68k__) && !defined(__mcoldfire__)
"m68k-linux-gnu"
# elif defined(__mips_hard_float) && defined(_MIPSEL)
# if _MIPS_SIM == _ABIO32
"mipsel-linux-gnu"
# elif _MIPS_SIM == _ABIN32
"mips64el-linux-gnuabin32"
# elif _MIPS_SIM == _ABI64
"mips64el-linux-gnuabi64"
# else
# "unknown platform triplet"
# endif
# elif defined(__mips_hard_float)
# if _MIPS_SIM == _ABIO32
"mips-linux-gnu"
# elif _MIPS_SIM == _ABIN32
"mips64-linux-gnuabin32"
# elif _MIPS_SIM == _ABI64
"mips64-linux-gnuabi64"
# else
# "unknown platform triplet"
# endif
# elif defined(__or1k__)
"or1k-linux-gnu"
# elif defined(__powerpc__) && defined(__SPE__)
"powerpc-linux-gnuspe"
# elif defined(__powerpc64__)
# if defined(__LITTLE_ENDIAN__)
"powerpc64le-linux-gnu"
# else
"powerpc64-linux-gnu"
# endif
# elif defined(__powerpc__)
"powerpc-linux-gnu"
# elif defined(__s390x__)
"s390x-linux-gnu"
# elif defined(__s390__)
"s390-linux-gnu"
# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
"sh4-linux-gnu"
# elif defined(__sparc__) && defined(__arch64__)
"sparc64-linux-gnu"
# elif defined(__sparc__)
"sparc-linux-gnu"
# else
# "unknown platform triplet"
# endif
#elif defined(__FreeBSD_kernel__)
# if defined(__LP64__)
"x86_64-kfreebsd-gnu"
# elif defined(__i386__)
"i386-kfreebsd-gnu"
# else
# "unknown platform triplet"
# endif
#elif defined(__gnu_hurd__)
"i386-gnu"
#elif defined(__APPLE__)
"darwin"
#else
# "unknown platform triplet"
#endif
;
int main()
{
printf("%s", PLATFORM_TRIPLET);
return 0;
}
+12
View File
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: Python
Description: Python library
Requires:
Version: @LIBPYTHON_VERSION@
Libs.private: -lpthread -ldl -lutil
Libs: -L${libdir} -l@LIBPYTHON@
Cflags: -I${includedir}/@LIBPYTHON@
+107
View File
@@ -0,0 +1,107 @@
set(PYTHON_SOURCES
${SRC_DIR}/$<IF:$<VERSION_GREATER_EQUAL:${PY_VERSION},3.5>,Programs,Modules>/python.c
)
add_executable(python ${PYTHON_SOURCES})
set_property(
TARGET python
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${BIN_BUILD_DIR}
)
target_compile_definitions(python PRIVATE Py_BUILD_CORE)
add_definitions(-DPy_BUILD_CORE)
# Link against the shared libpython if it was built, otherwise use the static
# version.
if(BUILD_LIBPYTHON_SHARED)
target_link_libraries(python libpython-shared)
else()
target_link_libraries(python libpython-static)
set_target_properties(python PROPERTIES
COMPILE_DEFINITIONS Py_NO_ENABLE_SHARED
ENABLE_EXPORTS ON
)
endif()
if(MSVC)
set_target_properties(python PROPERTIES LINK_FLAGS /STACK:2000000)
endif()
# Export target
set_property(GLOBAL APPEND PROPERTY PYTHON_TARGETS python)
install(TARGETS python EXPORT PythonTargets RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
# See "is_python_build()" in sysconfig.py
add_custom_command(TARGET python PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/Modules
COMMAND ${CMAKE_COMMAND} -E touch ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/Modules/Setup.local
COMMENT "Creating '${BIN_INSTALL_DIR}/${CMAKE_CFG_INTDIR}/Modules/Setup.local'"
)
if(WIN32)
# See "get_config_h_filename()" in sysconfig.py
add_custom_command(TARGET python POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/PC
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_DIR}/PC/pyconfig.h ${BIN_BUILD_DIR}/${CMAKE_CFG_INTDIR}/PC/pyconfig.h
COMMENT "Copying 'pyconfig.h' to '${BIN_INSTALL_DIR}/${CMAKE_CFG_INTDIR}/PC'"
)
endif()
if(UNIX)
# Setup landmark allowing to run the interpreter from a build tree. See 'getpath.c' for details.
set(_sysconfigdata_py "_sysconfigdata.py")
if("${PY_VERSION}" VERSION_GREATER_EQUAL "3.6.0")
# XXX Add support for _PYTHON_SYSCONFIGDATA_NAME env. variable
set(MULTIARCH "")
set(_sysconfigdata_py "_sysconfigdata_${ABIFLAGS}_${PY_PLATFORM}_${MULTIARCH}.py")
endif()
add_custom_command(
OUTPUT ${BIN_BUILD_DIR}/pybuilddir.txt ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py}
COMMAND ${PYTHON_WRAPPER_COMMAND}
${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:python> -E -S -m sysconfig --generate-posix-vars
COMMAND ${CMAKE_COMMAND}
-DBIN_BUILD_DIR:PATH=${BIN_BUILD_DIR}
-DSYSCONFIGDATA_PY:STRING=${_sysconfigdata_py}
-DPYTHON_BINARY_DIR:PATH=${PROJECT_BINARY_DIR}
-DEXTENSION_INSTALL_DIR:PATH=${EXTENSION_INSTALL_DIR}
-P ${PROJECT_SOURCE_DIR}/cmake/UpdateSysconfig.cmake
COMMENT "Relocate ${_sysconfigdata_py} and update pybuilddir.txt"
WORKING_DIRECTORY ${BIN_BUILD_DIR}
DEPENDS python
)
add_custom_target(update_sysconfig ALL
DEPENDS ${BIN_BUILD_DIR}/pybuilddir.txt ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py}
)
install(FILES ${EXTENSION_BUILD_DIR}/${_sysconfigdata_py}
DESTINATION ${PYTHONHOME}/)
endif()
if(UNIX AND NOT CMAKE_CROSSCOMPILING)
install(CODE
"message(STATUS \"Creating Python executable symlinks...\")
execute_process(
COMMAND \${CMAKE_COMMAND} -E create_symlink python
python${PY_VERSION_MAJOR}
COMMAND \${CMAKE_COMMAND} -E create_symlink python
python${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}
WORKING_DIRECTORY
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${BIN_INSTALL_DIR}
)"
)
endif()
# Copy up the gdb python hooks into a position where they can be automatically
# loaded by gdb during Lib/test/test_gdb.py
#
# Distributors are likely to want to install this somewhere else e.g. relative
# to the stripped DWARF data for the shared library.
set(SRC_GDB_HOOKS ${SRC_DIR}/Tools/gdb/libpython.py)
configure_file(
${SRC_GDB_HOOKS}
${BIN_BUILD_DIR}/python-gdb.py
COPYONLY
)
if(INSTALL_DEVELOPMENT)
install(FILES ${SRC_GDB_HOOKS} DESTINATION ${BIN_INSTALL_DIR} COMPONENT Development)
endif()
+13
View File
@@ -0,0 +1,13 @@
set(files)
if(PY_VERSION VERSION_GREATER_EQUAL "3.6")
list(APPEND files
Tools/scripts/run_tests.py
)
endif()
foreach(file IN LISTS files)
get_filename_component(path ${file} PATH)
file(COPY ${SRC_DIR}/${file} DESTINATION ${PROJECT_BINARY_DIR}/${LIBDIR}/${path})
install(FILES ${SRC_DIR}/${file} DESTINATION ${LIBDIR}/${path})
endforeach()
@@ -0,0 +1,51 @@
From 50a9d90c04eb672d35d516b32c802760a0736a23 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Tue, 13 May 2025 20:36:35 -0400
Subject: [PATCH] _bootstrap_python: Fix execution on windows disabling site
import
This workaround the lack of `sys.winver` attribute addressing the following
error:
```
Generating C:/path/to/Python-3.11.12/Python/deepfreeze/deepfreeze.c
CUSTOMBUILD : Fatal Python error : init_import_site: Failed to import the site module [C:\path\to\pycbs-3.11-build\CMakeBuild\libpython\libpython-shared.vcxproj]
Python runtime state: initialized
Traceback (most recent call last):
File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 626, in <module>
main()
File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 612, in main
known_paths = addusersitepackages(known_paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 350, in addusersitepackages
user_site = getusersitepackages()
^^^^^^^^^^^^^^^^^^^^^
File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 337, in getusersitepackages
USER_SITE = _get_path(userbase)
^^^^^^^^^^^^^^^^^^^
File "C:\path\to\pycbs-3.11-build\Lib\site.py", line 302, in _get_path
ver_nodot = sys.winver.replace('.', '')
^^^^^^^^^^
AttributeError: module 'sys' has no attribute 'winver'
```
---
Programs/_bootstrap_python.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Programs/_bootstrap_python.c b/Programs/_bootstrap_python.c
index 6ecbf0c72b5..136c187758d 100644
--- a/Programs/_bootstrap_python.c
+++ b/Programs/_bootstrap_python.c
@@ -72,6 +72,9 @@ main(int argc, char **argv)
// add current script dir to sys.path
config.isolated = 0;
config.safe_path = 0;
+#ifdef MS_WINDOWS
+ config.site_import = 0;
+#endif
#ifdef MS_WINDOWS
status = PyConfig_SetArgv(&config, argc, argv);
--
2.48.1
@@ -0,0 +1,105 @@
From 646608c7fd9f8ff0c97bb587b6273b1791604e2a Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Fri, 30 May 2025 14:54:08 -0400
Subject: [PATCH] getpath: Update build directory assumptions based on
python-cmake-buildsystem
This ensures the following tests pass:
- `test_sys` (`SysModuleTest.test_stdlib_dir`)
- `test_frozen` (`TestFrozen.test_unfrozen_submodule_in_frozen_package`)
---
Lib/test/test_getpath.py | 12 ++++++------
Modules/getpath.py | 10 +++++++---
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py
index 5208374e200..3a3168a6dbb 100644
--- a/Lib/test/test_getpath.py
+++ b/Lib/test/test_getpath.py
@@ -278,7 +278,7 @@ def test_buildpath_posix(self):
ns.add_known_xfile("/home/cpython/python")
ns.add_known_xfile("/usr/local/bin/python")
ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"])
- ns.add_known_file("/home/cpython/Lib/os.py")
+ ns.add_known_file("/home/cpython/lib/python9.8/os.py")
ns.add_known_dir("/home/cpython/lib-dynload")
expected = dict(
executable="/home/cpython/python",
@@ -290,7 +290,7 @@ def test_buildpath_posix(self):
module_search_paths_set=1,
module_search_paths=[
"/usr/local/lib/python98.zip",
- "/home/cpython/Lib",
+ "/home/cpython/lib/python9.8",
"/home/cpython/build/lib.linux-x86_64-9.8",
],
)
@@ -402,7 +402,7 @@ def test_symlink_buildpath_posix(self):
ns.add_known_link("/linkfrom/python", "/home/cpython/python")
ns.add_known_xfile("/usr/local/bin/python")
ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"])
- ns.add_known_file("/home/cpython/Lib/os.py")
+ ns.add_known_file("/home/cpython/lib/python9.8/os.py")
ns.add_known_dir("/home/cpython/lib-dynload")
expected = dict(
executable="/linkfrom/python",
@@ -414,7 +414,7 @@ def test_symlink_buildpath_posix(self):
module_search_paths_set=1,
module_search_paths=[
"/usr/local/lib/python98.zip",
- "/home/cpython/Lib",
+ "/home/cpython/lib/python9.8",
"/home/cpython/build/lib.linux-x86_64-9.8",
],
)
@@ -709,7 +709,7 @@ def test_symlink_buildpath_macos(self):
ns.add_known_link("/linkfrom/python", "/home/cpython/python")
ns.add_known_xfile("/usr/local/bin/python")
ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.macos-9.8"])
- ns.add_known_file("/home/cpython/Lib/os.py")
+ ns.add_known_file("/home/cpython/lib/python9.8/os.py")
ns.add_known_dir("/home/cpython/lib-dynload")
expected = dict(
executable="/linkfrom/python",
@@ -721,7 +721,7 @@ def test_symlink_buildpath_macos(self):
module_search_paths_set=1,
module_search_paths=[
"/usr/local/lib/python98.zip",
- "/home/cpython/Lib",
+ "/home/cpython/lib/python9.8",
"/home/cpython/build/lib.macos-9.8",
],
)
diff --git a/Modules/getpath.py b/Modules/getpath.py
index dceeed7702c..775614f531d 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -180,7 +180,7 @@
STDLIB_SUBDIR = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}'
STDLIB_LANDMARKS = [f'{STDLIB_SUBDIR}/os.py', f'{STDLIB_SUBDIR}/os.pyc']
PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}/lib-dynload'
- BUILDSTDLIB_LANDMARKS = ['Lib/os.py']
+ BUILDSTDLIB_LANDMARKS = [f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}/os.py']
VENV_LANDMARK = 'pyvenv.cfg'
ZIP_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}{VERSION_MINOR}.zip'
DELIM = ':'
@@ -491,10 +491,14 @@ def search_up(prefix, *landmarks, test=isfile):
else:
build_stdlib_prefix = search_up(build_prefix, *BUILDSTDLIB_LANDMARKS)
# Always use the build prefix for stdlib
+ if os_name == 'nt':
+ lib = 'Lib'
+ else:
+ lib = f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}'
if build_stdlib_prefix:
- stdlib_dir = joinpath(build_stdlib_prefix, 'Lib')
+ stdlib_dir = joinpath(build_stdlib_prefix, lib)
else:
- stdlib_dir = joinpath(build_prefix, 'Lib')
+ stdlib_dir = joinpath(build_prefix, lib)
# Only use the build prefix for prefix if it hasn't already been set
if not prefix:
prefix = build_stdlib_prefix
--
2.48.1
+1
View File
@@ -0,0 +1 @@
* ``0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch``: _bootstrap_python: Fix execution on windows disabling site import.
@@ -0,0 +1,51 @@
From ca2fd1a78562f904f4f5d7046cac9276c2ad2afa Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Tue, 13 May 2025 20:36:35 -0400
Subject: [PATCH] _bootstrap_python: Fix execution on windows disabling site
import
This works around the lack of `sys.winver` attribute addressing the following
error:
```
Generating C:/path/to/Python-3.12.10/Python/deepfreeze/deepfreeze.c
CUSTOMBUILD : Fatal Python error : init_import_site: Failed to import the site module [C:\path o\pycbs-3.12-build\CMakeBuild\libpython\libpython-shared.vcxproj]
Python runtime state: initialized
Traceback (most recent call last):
File "C:\path o\pycbs-3.12-build\Lib\site.py", line 636, in <module>
main()
File "C:\path o\pycbs-3.12-build\Lib\site.py", line 622, in main
known_paths = addusersitepackages(known_paths)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\path o\pycbs-3.12-build\Lib\site.py", line 361, in addusersitepackages
user_site = getusersitepackages()
^^^^^^^^^^^^^^^^^^^^^
File "C:\path o\pycbs-3.12-build\Lib\site.py", line 348, in getusersitepackages
USER_SITE = _get_path(userbase)
^^^^^^^^^^^^^^^^^^^
File "C:\path o\pycbs-3.12-build\Lib\site.py", line 313, in _get_path
ver_nodot = sys.winver.replace('.', '')
^^^^^^^^^^
AttributeError: module 'sys' has no attribute 'winver'
```
---
Programs/_bootstrap_python.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Programs/_bootstrap_python.c b/Programs/_bootstrap_python.c
index 6c388fc7033..edbe2847904 100644
--- a/Programs/_bootstrap_python.c
+++ b/Programs/_bootstrap_python.c
@@ -76,6 +76,9 @@ main(int argc, char **argv)
// add current script dir to sys.path
config.isolated = 0;
config.safe_path = 0;
+#ifdef MS_WINDOWS
+ config.site_import = 0;
+#endif
#ifdef MS_WINDOWS
status = PyConfig_SetArgv(&config, argc, argv);
--
2.48.1
@@ -0,0 +1,105 @@
From b8d5fa3e61e2f1f8d07f8b8291c281cbdd02c4ad Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Fri, 30 May 2025 14:54:08 -0400
Subject: [PATCH] getpath: Update build directory assumptions based on
python-cmake-buildsystem
This ensures the following tests pass:
- `test_sys` (`SysModuleTest.test_stdlib_dir`)
- `test_frozen` (`TestFrozen.test_unfrozen_submodule_in_frozen_package`)
---
Lib/test/test_getpath.py | 12 ++++++------
Modules/getpath.py | 10 +++++++---
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/Lib/test/test_getpath.py b/Lib/test/test_getpath.py
index b9cbe1d92c4..374bfeef5f9 100644
--- a/Lib/test/test_getpath.py
+++ b/Lib/test/test_getpath.py
@@ -304,7 +304,7 @@ def test_buildpath_posix(self):
ns.add_known_xfile("/home/cpython/python")
ns.add_known_xfile("/usr/local/bin/python")
ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"])
- ns.add_known_file("/home/cpython/Lib/os.py")
+ ns.add_known_file("/home/cpython/lib/python9.8/os.py")
ns.add_known_dir("/home/cpython/lib-dynload")
expected = dict(
executable="/home/cpython/python",
@@ -316,7 +316,7 @@ def test_buildpath_posix(self):
module_search_paths_set=1,
module_search_paths=[
"/usr/local/lib/python98.zip",
- "/home/cpython/Lib",
+ "/home/cpython/lib/python9.8",
"/home/cpython/build/lib.linux-x86_64-9.8",
],
)
@@ -492,7 +492,7 @@ def test_symlink_buildpath_posix(self):
ns.add_known_link("/linkfrom/python", "/home/cpython/python")
ns.add_known_xfile("/usr/local/bin/python")
ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.linux-x86_64-9.8"])
- ns.add_known_file("/home/cpython/Lib/os.py")
+ ns.add_known_file("/home/cpython/lib/python9.8/os.py")
ns.add_known_dir("/home/cpython/lib-dynload")
expected = dict(
executable="/linkfrom/python",
@@ -504,7 +504,7 @@ def test_symlink_buildpath_posix(self):
module_search_paths_set=1,
module_search_paths=[
"/usr/local/lib/python98.zip",
- "/home/cpython/Lib",
+ "/home/cpython/lib/python9.8",
"/home/cpython/build/lib.linux-x86_64-9.8",
],
)
@@ -799,7 +799,7 @@ def test_symlink_buildpath_macos(self):
ns.add_known_link("/linkfrom/python", "/home/cpython/python")
ns.add_known_xfile("/usr/local/bin/python")
ns.add_known_file("/home/cpython/pybuilddir.txt", ["build/lib.macos-9.8"])
- ns.add_known_file("/home/cpython/Lib/os.py")
+ ns.add_known_file("/home/cpython/lib/python9.8/os.py")
ns.add_known_dir("/home/cpython/lib-dynload")
expected = dict(
executable="/linkfrom/python",
@@ -811,7 +811,7 @@ def test_symlink_buildpath_macos(self):
module_search_paths_set=1,
module_search_paths=[
"/usr/local/lib/python98.zip",
- "/home/cpython/Lib",
+ "/home/cpython/lib/python9.8",
"/home/cpython/build/lib.macos-9.8",
],
)
diff --git a/Modules/getpath.py b/Modules/getpath.py
index 9913fcba497..abe87164a4d 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -180,7 +180,7 @@
STDLIB_SUBDIR = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}'
STDLIB_LANDMARKS = [f'{STDLIB_SUBDIR}/os.py', f'{STDLIB_SUBDIR}/os.pyc']
PLATSTDLIB_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}.{VERSION_MINOR}/lib-dynload'
- BUILDSTDLIB_LANDMARKS = ['Lib/os.py']
+ BUILDSTDLIB_LANDMARKS = [f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}/os.py']
VENV_LANDMARK = 'pyvenv.cfg'
ZIP_LANDMARK = f'{platlibdir}/python{VERSION_MAJOR}{VERSION_MINOR}.zip'
DELIM = ':'
@@ -510,10 +510,14 @@ def search_up(prefix, *landmarks, test=isfile):
else:
build_stdlib_prefix = search_up(build_prefix, *BUILDSTDLIB_LANDMARKS)
# Always use the build prefix for stdlib
+ if os_name == 'nt':
+ lib = 'Lib'
+ else:
+ lib = f'lib/python{VERSION_MAJOR}.{VERSION_MINOR}'
if build_stdlib_prefix:
- stdlib_dir = joinpath(build_stdlib_prefix, 'Lib')
+ stdlib_dir = joinpath(build_stdlib_prefix, lib)
else:
- stdlib_dir = joinpath(build_prefix, 'Lib')
+ stdlib_dir = joinpath(build_prefix, lib)
# Only use the build prefix for prefix if it hasn't already been set
if not prefix:
prefix = build_stdlib_prefix
--
2.48.1
+4
View File
@@ -0,0 +1,4 @@
* ``0001-_bootstrap_python-Fix-execution-on-windows-disabling.patch``: _bootstrap_python: Fix execution on windows disabling site import.
* ``0002-getpath-Update-build-directory-assumptions-based-on-.patch``: getpath: Update build directory assumptions based on
python-cmake-buildsystem
@@ -0,0 +1,86 @@
From 2d8a07e976859c7e8582ed8f4d7849f7e8b8a68c Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Mon, 6 Nov 2017 09:56:43 -0500
Subject: [PATCH 1/3] Prevent incorrect include of "io.h" and "memory.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/basearith.c | 2 +-
Modules/_decimal/libmpdec/io.c | 4 ++--
Modules/_decimal/libmpdec/memory.c | 2 +-
Modules/_decimal/libmpdec/{io.h => mpd_io.h} | 0
Modules/_decimal/libmpdec/{memory.h => mpd_memory.h} | 0
Modules/_decimal/libmpdec/mpdecimal.c | 2 +-
6 files changed, 5 insertions(+), 5 deletions(-)
rename Modules/_decimal/libmpdec/{io.h => mpd_io.h} (100%)
rename Modules/_decimal/libmpdec/{memory.h => mpd_memory.h} (100%)
diff --git a/Modules/_decimal/libmpdec/basearith.c b/Modules/_decimal/libmpdec/basearith.c
index 35de6b8..c0953a3 100644
--- a/Modules/_decimal/libmpdec/basearith.c
+++ b/Modules/_decimal/libmpdec/basearith.c
@@ -32,7 +32,7 @@
#include <string.h>
#include <assert.h>
#include "constants.h"
-#include "memory.h"
+#include "mpd_memory.h"
#include "typearith.h"
#include "basearith.h"
diff --git a/Modules/_decimal/libmpdec/io.c b/Modules/_decimal/libmpdec/io.c
index a45a429..f517264 100644
--- a/Modules/_decimal/libmpdec/io.c
+++ b/Modules/_decimal/libmpdec/io.c
@@ -37,9 +37,9 @@
#include <locale.h>
#include "bits.h"
#include "constants.h"
-#include "memory.h"
+#include "mpd_memory.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/memory.c b/Modules/_decimal/libmpdec/memory.c
index 0f41fe5..f4140b2 100644
--- a/Modules/_decimal/libmpdec/memory.c
+++ b/Modules/_decimal/libmpdec/memory.c
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "typearith.h"
-#include "memory.h"
+#include "mpd_memory.h"
/* Guaranteed minimum allocation for a coefficient. May be changed once
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
diff --git a/Modules/_decimal/libmpdec/memory.h b/Modules/_decimal/libmpdec/mpd_memory.h
similarity index 100%
rename from Modules/_decimal/libmpdec/memory.h
rename to Modules/_decimal/libmpdec/mpd_memory.h
diff --git a/Modules/_decimal/libmpdec/mpdecimal.c b/Modules/_decimal/libmpdec/mpdecimal.c
index 593f9f5..2fd8b33 100644
--- a/Modules/_decimal/libmpdec/mpdecimal.c
+++ b/Modules/_decimal/libmpdec/mpdecimal.c
@@ -36,7 +36,7 @@
#include "bits.h"
#include "convolute.h"
#include "crt.h"
-#include "memory.h"
+#include "mpd_memory.h"
#include "typearith.h"
#include "umodarith.h"
--
2.5.0
@@ -0,0 +1,65 @@
From 8f6f95702bb5b58021e91385392c5c507cf22d31 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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 edc6cf4..c9b0049 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;
@@ -1517,7 +1517,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);
@@ -1525,7 +1525,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
@@ -0,0 +1,36 @@
From 69f55ccb4b9c5c1c34dc3d3ed8612574e7d65dc5 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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 2fd8b33..a0d707a 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
+10
View File
@@ -0,0 +1,10 @@
* ``0001-Prevent-incorrect-include-of-io.h-and-memory.h-found.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.
@@ -0,0 +1,45 @@
From 8880127d669a170e0dad55631bc2fa03ceed51dd Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@redhat.com>
Date: Mon, 17 Dec 2018 22:06:10 +0100
Subject: [PATCH] bpo-35519: Rename test.bisect to test.bisect_cmd (GH-11200)
Rename test.bisect module to test.bisect_cmd to avoid conflict with
bisect module when running directly a test like
"./python Lib/test/test_xmlrpc.py".
---
Lib/test/{bisect.py => bisect_cmd.py} | 0
Lib/test/support/__init__.py | 2 +-
.../NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst | 3 +++
3 files changed, 4 insertions(+), 1 deletion(-)
rename Lib/test/{bisect.py => bisect_cmd.py} (100%)
create mode 100644 Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst
diff --git a/Lib/test/bisect.py b/Lib/test/bisect_cmd.py
similarity index 100%
rename from Lib/test/bisect.py
rename to Lib/test/bisect_cmd.py
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 66c0fed8411..b40135bc8b9 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1972,7 +1972,7 @@ def set_match_tests(patterns):
patterns = ()
elif all(map(_is_full_match_test, patterns)):
# Simple case: all patterns are full test identifier.
- # The test.bisect utility only uses such full test identifiers.
+ # The test.bisect_cmd utility only uses such full test identifiers.
func = set(patterns).__contains__
else:
regex = '|'.join(map(fnmatch.translate, patterns))
diff --git a/Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst b/Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst
new file mode 100644
index 00000000000..e108dd877e1
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2018-12-17-16-41-45.bpo-35519.RR3L_w.rst
@@ -0,0 +1,3 @@
+Rename :mod:`test.bisect` module to :mod:`test.bisect_cmd` to avoid conflict
+with :mod:`bisect` module when running directly a test like
+``./python Lib/test/test_xmlrpc.py``.
--
2.48.1
+1
View File
@@ -0,0 +1 @@
* ``0001-bpo-35519-Rename-test.bisect-to-test.bisect_cmd-GH-1.patch``: bpo-35519: Rename test.bisect to test.bisect_cmd (GH-11200)
@@ -0,0 +1,35 @@
From 9ec49ea39b57e69722d82b41594479a896c65ae2 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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
@@ -0,0 +1,65 @@
From d96bfdc9f531eaefdab931f6b2830278c2dc0226 Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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
@@ -0,0 +1,36 @@
From 12cd7e4b43f85822d8ab0531cb3097e5f32bd5ff Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
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
@@ -0,0 +1,26 @@
From ca436844d5dddcb0156ada7fadc9fa4c38d8bcbe Mon Sep 17 00:00:00 2001
From: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
Date: Fri, 12 Apr 2019 16:36:42 -0400
Subject: [PATCH 4/4] Fix Windows build of Python for latest WinSDK.
This is a partial backport of https://github.com/python/cpython/commit/df4852cbe4b757e8b79506d73a09ec8a1b595970
---
Modules/_io/_iomodule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index f4d3cbd49f..f7ad176990 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -21,7 +21,7 @@
#endif /* HAVE_SYS_STAT_H */
#ifdef MS_WINDOWS
-#include <consoleapi.h>
+#include <windows.h>
#endif
/* Various interned strings */
--
2.11.0
+12
View File
@@ -0,0 +1,12 @@
* ``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.
* ``0004-Fix-Windows-build-of-Python-for-latest-WinSDK.patch``: Fix build of iomodule using
Visual Studio >= 2017. It is a partial backport of commit [python/cpython@df4852c](https://github.com/python/cpython/commit/df4852cbe4b757e8b79506d73a09ec8a1b595970)
originally associated with [CPython GH-6874](https://github.com/python/cpython/pull/6874).
+50
View File
@@ -0,0 +1,50 @@
CPython Patches
===============
Fixes and improvements to CPython should first be contributed upstream. The
`Python Developer’s Guide <https://docs.python.org/devguide/>`_ is a great
resource to guide you through the process.
That said, there are few scenarios where using `python-cmake-buildsystem` to
patch CPython is relevant. Learn more about these at https://github.com/python-cmake-buildsystem/cpython.
By default, patches are applied at configuration time. Setting the option
``PYTHON_APPLY_PATCHES`` to ``OFF`` allows to change this. Note that the
build system keep track which patches have been applied.
Each patch is documented by adding an entry to the `README.rst` file
found in the same directory (or a parent directory). Whenever possible,
references to `bugs.python.org <http://bugs.python.org>`_(bpo) issues,
corresponding `GitHub PRs <https://github.com/python/cpython/pull/>`_ and
any related discussions on forums or mailing lists are also provided.
Patches are organized per python version. Patches specific to a system,
a system+compiler, or a system+compiler+compiler_version are organized in
corresponding sub-directories::
patches/<PY_VERSION_MAJOR>.<PY_VERSION_MINOR>
patches/<PYTHON_VERSION>
patches/<PYTHON_VERSION>/<CMAKE_SYSTEM_NAME>
patches/<PYTHON_VERSION>/<CMAKE_SYSTEM_NAME>-<CMAKE_C_COMPILER_ID>
patches/<PYTHON_VERSION>/<CMAKE_SYSTEM_NAME>-<CMAKE_C_COMPILER_ID>/<compiler_version>
where
* ``<PYTHON_VERSION>`` is of the form ``X.Y.Z``
* ``<CMAKE_SYSTEM_NAME>`` is a value like ``Darwin``, ``Linux`` or ``Windows``. See
corresponding CMake documentation for more details.
* ``<CMAKE_C_COMPILER_ID>`` is a valid like ``Clang``, ``GNU`` or ``MSVC``. See
corresponding CMake documentation for more details.
* ``<compiler_version>`` is set to the value of ``CMAKE_C_COMPILER_VERSION`` (e.g ``5.2.1``)
except when using Microsoft compiler where it is set to the value of ``MSVC_VERSION`` (e.g ``1900``).
Before being applied, patches are sorted alphabetically. This ensures that
patch starting with `0001-` is applied before the one starting with `0002-`.
Note that for historical reasons, there are still patches found in ``cmake/patches``
and ``cmake/patches-win32`` subdirectories. These will gradually be organized as
described above.