Skip to content

Simplify build-system removing support for building CPython 2.7 #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,6 @@ workflows:
python_version: 3.6.15
python_arch: x86

# 2.7.18
- build-test-python:
name: python-2.7.18-x64
python_version: 2.7.18
python_arch: x64

- build-test-python:
name: python-2.7.18-x86
python_version: 2.7.18
python_arch: x86


build-and-test-win:
jobs:
Expand Down
40 changes: 2 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,6 @@ string(REGEX REPLACE "[a-z]+[1-9]$" "" _py_version_patch_no_rc ${PY_VERSION_PATC
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.
# 2.7.x
set(_download_2.7.3_md5 "2cf641732ac23b18d139be077bd906cd")
set(_download_2.7.4_md5 "592603cfaf4490a980e93ecb92bde44a")
set(_download_2.7.5_md5 "b4f01a1d0ba0b46b05c73b2ac909b1df")
set(_download_2.7.6_md5 "1d8728eb0dfcac72a0fd99c17ec7f386")
set(_download_2.7.7_md5 "cf842800b67841d64e7fb3cd8acb5663")
set(_download_2.7.8_md5 "d4bca0159acb0b44a781292b5231936f")
set(_download_2.7.9_md5 "5eebcaa0030dc4061156d3429657fb83")
set(_download_2.7.10_md5 "d7547558fd673bd9d38e2108c6b42521")
set(_download_2.7.11_md5 "6b6076ec9e93f05dd63e47eb9c15728b")
set(_download_2.7.12_md5 "88d61f82e3616a4be952828b3694109d")
set(_download_2.7.13_md5 "17add4bf0ad0ec2f08e0cae6d205c700")
set(_download_2.7.14_md5 "cee2e4b33ad3750da77b2e85f2f8b724")
set(_download_2.7.15_md5 "045fb3440219a1f6923fefdabde63342")
set(_download_2.7.16_md5 "f1a2ace631068444831d01485466ece0")
set(_download_2.7.17_md5 "27a7919fa8d1364bae766949aaa91a5b")
set(_download_2.7.18_md5 "38c84292658ed4456157195f1c9bcbe1")
# 3.5.x
set(_download_3.5.1_md5 "be78e48cdfc1a7ad90efff146dce6cfe")
set(_download_3.5.2_md5 "3fe8434643a78630c61c6464fe2e7e72")
Expand Down Expand Up @@ -337,7 +320,7 @@ message(STATUS "PY_VERSION_LONG: ${PY_VERSION_LONG}")

# Check version
if(NOT DEFINED _download_${PY_VERSION_LONG}_md5)
message(WARNING "warning: selected python version '${PY_VERSION_LONG}' is not tested. Tested versions match '2.7.[3-14]' or '3.5.[1-5]' or `3.6.[0-4]`")
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}")
Expand All @@ -351,34 +334,21 @@ if(PYTHON_APPLY_PATCHES)
endif()

# Convenience boolean variables to easily test python version
set(IS_PY3 0)
set(IS_PY2 1)
if(PY_VERSION_MAJOR VERSION_GREATER 2)
set(IS_PY3 1)
set(IS_PY2 0)
endif()
set(IS_PY3 1)

# Enable CXX language to support building of _distutils_findvs extension
if(WIN32 AND IS_PY3)
enable_language(CXX)
endif()

# Options depending of the python version
if(IS_PY2)
cmake_dependent_option(USE_SYSTEM_DB "Use system DB" ON "USE_SYSTEM_LIBRARIES" OFF)
else()
if(DEFINED USE_SYSTEM_DB)
message(AUTHOR_WARNING "USE_SYSTEM_DB option is *NOT* supported with Python 3. Current version is ${PY_VERSION}")
endif()
endif()

if(IS_PY2)
option(Py_USING_UNICODE "Enable unicode support" ON)
else()
if(DEFINED Py_USING_UNICODE)
message(AUTHOR_WARNING "Py_USING_UNICODE option is *NOT* supported with Python 3. Current version is ${PY_VERSION}")
endif()
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)
Expand All @@ -388,11 +358,9 @@ else()
endif()
endif()

if(PY_VERSION_MAJOR VERSION_GREATER 2.7.10)
# 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})
endif()

if(IS_PY3)
set(WITH_HASH_ALGORITHM "default" CACHE STRING "Define hash algorithm for str, bytes and memoryview.")
Expand Down Expand Up @@ -776,11 +744,7 @@ if(BUILD_TESTING)
set(TESTOPTS -l)
set(TESTPROG ${PROJECT_BINARY_DIR}/${PYTHONHOME}/test/regrtest.py)
set(TESTPYTHONOPTS )
if(IS_PY2)
set(TESTPYTHON $<TARGET_FILE:python> -Wd -3 -E -tt ${TESTPYTHONOPTS})
else()
set(TESTPYTHON $<TARGET_FILE:python> ${TESTPYTHONOPTS})
endif()
set(TESTPYTHON ${CMAKE_CROSSCOMPILING_EMULATOR} ${TESTPYTHON})
include(cmake/UnitTests.cmake)
foreach(unittest ${unittests})
Expand Down
21 changes: 7 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,23 @@ options on the commandline with `-DOPTION=VALUE`, or use the "ccmake" gui.
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 (_). Known extensions for 2.7.12 include:

ARRAY AUDIOOP BINASCII BISECT BSDDB BZ2 CMATH CODECS_CN CODECS_HK
CODECS_ISO2022 CODECS_JP CODECS_KR CODECS_TW COLLECTIONS CPICKLE CRYPT
CSTRINGIO CSV CTYPES CTYPES_TEST CURSES CURSES_PANEL DATETIME DBM
ELEMENTTREE FCNTL FUNCTOOLS FUTURE_BUILTINS GDBM GRP HASHLIB HEAPQ
HOTSHOT IO ITERTOOLS JSON LINUXAUDIODEV LOCALE LSPROF LZMA MATH MMAP
MULTIBYTECODEC MULTIPROCESSING NIS NT OPERATOR OSSAUDIODEV PARSER POSIX
PWD PYEXPAT RANDOM READLINE RESOURCE SELECT SOCKET SPWD SQLITE3 SSL
STROP STRUCT SYSLOG TERMIOS TESTCAPI TIME TKINTER UNICODEDATA ZLIB
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/python2.7/lib-dynload. If you set
.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/python2.7/lib-dynload instead of
lib/python2.7/lib-dynload.
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
Expand Down Expand Up @@ -280,8 +271,10 @@ the PSF will require you to license code under "Academic Free License" or
Which python versions are supported?
....................................

This project supports building multiple versions of CPython 2.7 and CPython 3.
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.
57 changes: 0 additions & 57 deletions appveyor.yml

This file was deleted.

74 changes: 0 additions & 74 deletions cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@ check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
check_include_files(termios.h HAVE_TERMIOS_H)
check_include_files(term.h HAVE_TERM_H)
if(IS_PY2)
check_include_files(thread.h HAVE_THREAD_H)
endif()
check_include_files(unistd.h HAVE_UNISTD_H) # libffi and cpython
check_include_files(util.h HAVE_UTIL_H)
check_include_files(utime.h HAVE_UTIME_H)
Expand Down Expand Up @@ -654,13 +651,8 @@ endif()
if(define_xopen_source)
message(STATUS "Checking for XOPEN_SOURCE - yes")
set_required_def(_XOPEN_SOURCE_EXTENDED 1) # Define to activate Unix95-and-earlier features
if(IS_PY2)
set_required_def(_XOPEN_SOURCE 600) # Define to the level of X/Open that your system supports
set_required_def(_POSIX_C_SOURCE 200112L) # Define to activate features from IEEE Stds 1003.1-2001
else()
set_required_def(_XOPEN_SOURCE 700) # Define to the level of X/Open that your system supports
set_required_def(_POSIX_C_SOURCE 200809L) # Define to activate features from IEEE Stds 1003.1-2008
endif()
else()
message(STATUS "Checking for XOPEN_SOURCE - no")
endif()
Expand Down Expand Up @@ -840,9 +832,6 @@ check_symbol_exists(ftell64 "${CFG_HEADERS}" HAVE_FTELL64)
check_symbol_exists(ftello "${CFG_HEADERS}" HAVE_FTELLO)
check_symbol_exists(ftime "${CFG_HEADERS}" HAVE_FTIME)
check_symbol_exists(ftruncate "${CFG_HEADERS}" HAVE_FTRUNCATE)
if(IS_PY2)
check_symbol_exists(getcwd "${CFG_HEADERS}" HAVE_GETCWD)
endif()
check_symbol_exists(getc_unlocked "${CFG_HEADERS}" HAVE_GETC_UNLOCKED)
check_symbol_exists(getgroups "${CFG_HEADERS}" HAVE_GETGROUPS)
check_symbol_exists(getitimer "${CFG_HEADERS}" HAVE_GETITIMER)
Expand Down Expand Up @@ -1680,53 +1669,6 @@ python_platform_test(
#ucs2
set(HAVE_USABLE_WCHAR_T 0)

if(IS_PY2)

if(Py_USING_UNICODE AND NOT DEFINED Py_UNICODE_SIZE)
if(HAVE_UCS4_TCL)
message(STATUS "Defaulting Py_UNICODE_SIZE to 4 because HAVE_UCS4_TCL is set")
set(Py_UNICODE_SIZE 4)
else()
# Py_UNICODE defaults to two-byte mode
set(Py_UNICODE_SIZE 2)
endif()
endif()

if("${Py_UNICODE_SIZE}" STREQUAL "${SIZEOF_WCHAR_T}")
set(PY_UNICODE_TYPE wchar_t)
set(HAVE_USABLE_WCHAR_T 1)
message(STATUS "Using wchar_t for unicode [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]")
else()

if("${Py_UNICODE_SIZE}" STREQUAL "${SIZEOF_SHORT}")
set(PY_UNICODE_TYPE "unsigned short")
set(HAVE_USABLE_WCHAR_T 0)
message(STATUS "Using unsigned short for unicode [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]")
else()

if("${Py_UNICODE_SIZE}" STREQUAL "${SIZEOF_LONG}")
set(PY_UNICODE_TYPE "unsigned long")
set(HAVE_USABLE_WCHAR_T 0)
message(STATUS "Using unsigned long for unicode [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]")
else()

if(Py_USING_UNICODE)
message(SEND_ERROR "No usable unicode type found for [Py_UNICODE_SIZE: ${Py_UNICODE_SIZE}]
Two paths forward:
(1) set Py_UNICODE_SIZE to either ${SIZEOF_WCHAR_T}, ${SIZEOF_SHORT} or ${SIZEOF_LONG}
(2) disable Py_USING_UNICODE option")
else()
message(STATUS "No usable unicode type found [Py_USING_UNICODE: ${Py_USING_UNICODE}]")
endif()

endif()

endif()

endif()

endif()

if(PY_VERSION VERSION_GREATER_EQUAL "3.7")
set(PY_COERCE_C_LOCALE ${WITH_C_LOCALE_COERCION})
endif()
Expand Down Expand Up @@ -1897,15 +1839,6 @@ cmake_pop_check_state()
cmake_push_check_state()
set(CFG_HEADERS_SAVE ${CFG_HEADERS})

if(IS_PY2)
set(ATHEOS_THREADS 0)
set(BEOS_THREADS 0)
set(C_THREADS 0)
set(HURD_C_THREADS 0)
set(MACH_C_THREADS 0)
set(HAVE_PTH 0) # GNU PTH threads
endif()

set(HAVE_PTHREAD_DESTRUCTOR 0) # for Solaris 2.6
add_cond(CFG_HEADERS HAVE_PTHREAD_H pthread.h)
add_cond(CMAKE_REQUIRED_LIBRARIES CMAKE_USE_PTHREADS_INIT "${CMAKE_THREAD_LIBS_INIT}")
Expand Down Expand Up @@ -2317,13 +2250,6 @@ endif()
#
#######################################################################

if(IS_PY2)
check_c_source_compiles("
void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2))) {};
int main() {f(NULL);} "
HAVE_ATTRIBUTE_FORMAT_PARSETUPLE)
endif()

check_c_source_compiles("#include <unistd.h>\n int main() {getpgrp(0);}" GETPGRP_HAVE_ARG)

check_c_source_compiles("#include <unistd.h>\n int main() {setpgrp(0, 0);}" SETPGRP_HAVE_ARG)
Expand Down
16 changes: 0 additions & 16 deletions cmake/PythonApplyPatches.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,6 @@ function(_apply_patches _subdir)
endfunction()

set(_py_version ${PY_VERSION})
if("${PY_VERSION}" VERSION_LESS "3.0")
if("${PY_VERSION}" MATCHES "^2\\.7\\.(3|4)$")
set(_py_version "2.7.3")
endif()
if("${PY_VERSION}" MATCHES "^2\\.7\\.(5|6)$")
set(_py_version "2.7.5")
endif()
if("${PY_VERSION}" MATCHES "^2\\.7\\.(11|12|13|14)$")
set(_py_version "2.7.13")
message(STATUS "Using ${_py_version} patches for 2.7.11, 2.7.12, 2.7.13 and 2.7.14")
endif()
if("${PY_VERSION}" VERSION_GREATER_EQUAL "2.7.15")
set(_py_version "2.7.15")
message(STATUS "Using ${_py_version} patches for 2.7.15 <= PY_VERSION < 3.0.0")
endif()
endif()

# Apply patches
_apply_patches("${PY_VERSION_MAJOR}.${PY_VERSION_MINOR}")
Expand Down
Loading