Skip to content
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

Bump to python 3.11.10 and add features readline and extension #41

Merged
merged 1 commit into from
Oct 8, 2024
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
22 changes: 22 additions & 0 deletions ports/python3/0019-fix-ssl-linkage.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/configure.ac b/configure.ac
index ef899b881d..9ed1836608 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6712,7 +6712,7 @@ done

# check if OpenSSL libraries work as expected
WITH_SAVE_ENV([
- LIBS="$LIBS $OPENSSL_LIBS"
+ LIBS="$OPENSSL_LIBS $LIBS"
CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"

@@ -6737,7 +6737,7 @@ WITH_SAVE_ENV([
])

WITH_SAVE_ENV([
- LIBS="$LIBS $LIBCRYPTO_LIBS"
+ LIBS="$LIBCRYPTO_LIBS $LIBS"
CFLAGS="$CFLAGS $OPENSSL_INCLUDES"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH"

44 changes: 36 additions & 8 deletions ports/python3/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static
set(VCPKG_LIBRARY_LINKAGE static)
endif()

if("extensions" IN_LIST FEATURES)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
endif()
set(PYTHON_HAS_EXTENSIONS ON)
else()
set(PYTHON_HAS_EXTENSIONS OFF)
endif()

if(NOT VCPKG_HOST_IS_WINDOWS)
message(WARNING "${PORT} currently requires the following programs from the system package manager:
autoconf automake autoconf-archive
Expand Down Expand Up @@ -34,6 +43,7 @@ set(PATCHES
0014-fix-get-python-inc-output.patch
0015-dont-use-WINDOWS-def.patch
0018-fix-sysconfig-include.patch
0019-fix-ssl-linkage.patch
add-vcpkg-search-path.patch
)

Expand All @@ -57,6 +67,10 @@ endif()

if(VCPKG_TARGET_IS_WINDOWS)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PYTHON_ALLOW_EXTENSIONS)
if(PYTHON_HAS_EXTENSIONS AND NOT PYTHON_ALLOW_EXTENSIONS)
# This should never be reached due to vcpkg_check_linkage above
message(FATAL_ERROR "Cannot build python extensions! Python extensions on windows can only be built if python is a dynamic library!")
endif()
# The Windows 11 SDK has a problem that causes it to error on the resource files, so we patch that.
vcpkg_get_windows_sdk(WINSDK_VERSION)
if("${WINSDK_VERSION}" VERSION_GREATER_EQUAL "10.0.22000")
Expand All @@ -73,7 +87,7 @@ vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO python/cpython
REF v${PYTHON_VERSION}
SHA512 124bca045e2e456856aae92c4740755cda41706c1b06ebecfcc65db6bdd1a259ecfc8fe54a673592f83163f6dd51606ffebcb7104d3be23f5bfc290eefa07ee2
SHA512 411f43495943b8aeec287d4339bac6beb6a7224b0844cc4d48188b208fbbbc6404ad031b6e7a3bed0900baf972c4536a54f4da1ab39202f4f405a188ca04ae07
HEAD_REF master
PATCHES ${PATCHES}
)
Expand Down Expand Up @@ -102,7 +116,7 @@ endfunction()
if(VCPKG_TARGET_IS_WINDOWS)
# Due to the way Python handles C extension modules on Windows, a static python core cannot
# load extension modules.
if(PYTHON_ALLOW_EXTENSIONS)
if(PYTHON_HAS_EXTENSIONS)
find_library(BZ2_RELEASE NAMES bz2 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(BZ2_DEBUG NAMES bz2d PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
find_library(CRYPTO_RELEASE NAMES libcrypto PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
Expand All @@ -120,7 +134,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND add_libs_rel "${BZ2_RELEASE};${EXPAT_RELEASE};${FFI_RELEASE};${LZMA_RELEASE};${SQLITE_RELEASE}")
list(APPEND add_libs_dbg "${BZ2_DEBUG};${EXPAT_DEBUG};${FFI_DEBUG};${LZMA_DEBUG};${SQLITE_DEBUG}")
else()
message(STATUS "WARNING: Static builds of Python will not have C extension modules available.")
message(STATUS "WARNING: Extensions have been disabled. No C extension modules will be available.")
endif()
find_library(ZLIB_RELEASE NAMES zlib PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(ZLIB_DEBUG NAMES zlib zlibd PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
Expand All @@ -136,7 +150,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
)

list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_SET_CHARSET_FLAG=OFF")
if(PYTHON_ALLOW_EXTENSIONS)
if(PYTHON_HAS_EXTENSIONS)
set(OPTIONS
"/p:IncludeExtensions=true"
"/p:IncludeExternals=true"
Expand Down Expand Up @@ -189,7 +203,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
endif()

# The extension modules must be placed in the DLLs directory, so we can't use vcpkg_copy_tools()
if(PYTHON_ALLOW_EXTENSIONS)
if(PYTHON_HAS_EXTENSIONS)
file(GLOB_RECURSE PYTHON_EXTENSIONS_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.pyd")
file(COPY ${PYTHON_EXTENSIONS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(COPY ${PYTHON_EXTENSIONS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}/DLLs")
Expand Down Expand Up @@ -257,13 +271,18 @@ else()
"--without-ensurepip"
"--with-suffix="
"--with-system-expat"
"--without-readline"
"--disable-test-modules"
)
if(VCPKG_TARGET_IS_OSX)
list(APPEND OPTIONS "LIBS=-liconv -lintl")
endif()

if("readline" IN_LIST FEATURES)
list(APPEND OPTIONS "--with-readline")
else()
list(APPEND OPTIONS "--without-readline")
endif()

# The version of the build Python must match the version of the cross compiled host Python.
# https://docs.python.org/3/using/configure.html#cross-compiling-options
if(VCPKG_CROSSCOMPILING)
Expand Down Expand Up @@ -329,7 +348,7 @@ vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

file(READ "${CMAKE_CURRENT_LIST_DIR}/usage" usage)
if(VCPKG_TARGET_IS_WINDOWS)
if(PYTHON_ALLOW_EXTENSIONS)
if(PYTHON_HAS_EXTENSIONS)
file(READ "${CMAKE_CURRENT_LIST_DIR}/usage.win" usage_extra)
else()
set(usage_extra "")
Expand Down Expand Up @@ -377,4 +396,13 @@ if (NOT VCPKG_TARGET_IS_WINDOWS)
endif()
endif()

configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" "${CURRENT_PACKAGES_DIR}/share/python3/vcpkg-port-config.cmake" @ONLY)
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake" @ONLY)


# For testing
block()
include("${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-port-config.cmake")
set(CURRENT_HOST_INSTALLED_DIR "${CURRENT_PACKAGES_DIR}")
set(CURRENT_INSTALLED_DIR "${CURRENT_PACKAGES_DIR}")
vcpkg_get_vcpkg_installed_python(VCPKG_PYTHON3)
endblock()
27 changes: 15 additions & 12 deletions ports/python3/vcpkg-port-config.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
set(PYTHON3_VERSION "@VERSION@")
set(PYTHON3_VERSION_MAJOR "@PYTHON_VERSION_MAJOR@")
set(PYTHON3_VERSION_MINOR "@PYTHON_VERSION_MINOR@")
set(PYTHON3_INCLUDE "include/python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}")
set(site_base "")
if(VCPKG_TARGET_IS_WINDOWS)
set(site_base "tools/python${PYTHON3_VERSION_MAJOR}/Lib")
else()
set(site_base "lib/python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}")
endif()
set(PYTHON3_SITE "${site_base}/site-packages")

include_guard(GLOBAL)
set(PYTHON3_VERSION "@VERSION@")
set(PYTHON3_VERSION_MAJOR "@PYTHON_VERSION_MAJOR@")
set(PYTHON3_VERSION_MINOR "@PYTHON_VERSION_MINOR@")
set(PYTHON3_INCLUDE "include/python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}")
set(PYTHON3_HAS_EXTENSIONS "@PYTHON_HAS_EXTENSIONS@")
set(site_base "")
if(VCPKG_TARGET_IS_WINDOWS)
set(site_base "tools/python${PYTHON3_VERSION_MAJOR}/Lib")
else()
set(site_base "lib/python${PYTHON3_VERSION_MAJOR}.${PYTHON3_VERSION_MINOR}")
endif()
set(PYTHON3_SITE "${site_base}/site-packages")

include("${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-get-python/vcpkg-port-config.cmake")
70 changes: 50 additions & 20 deletions ports/python3/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,38 @@
{
"name": "python3",
"version": "3.11.9",
"port-version": 2,
"version": "3.11.10",
"description": "The Python programming language",
"homepage": "https://github.com/python/cpython",
"license": "Python-2.0",
"supports": "!uwp & !mingw",
"dependencies": [
{
"name": "bzip2",
"platform": "!(windows & static)"
},
"expat",
{
"name": "gettext",
"platform": "osx"
},
{
"name": "libffi",
"platform": "!(windows & static)"
},
{
"name": "libiconv",
"platform": "osx"
},
{
"name": "liblzma",
"platform": "!(windows & static)"
},
{
"name": "libuuid",
"platform": "!osx & !windows"
},
{
"name": "openssl",
"platform": "!(windows & static)"
"name": "python3",
"host": true,
"default-features": false
},
{
"name": "python3",
"host": true
"features": [
"extensions"
],
"platform": "!windows"
},
{
"name": "sqlite3",
"platform": "!(windows & static)"
"name": "vcpkg-get-python",
"host": true
},
{
"name": "vcpkg-msbuild",
Expand All @@ -51,9 +41,49 @@
},
"zlib"
],
"default-features": [
{
"name": "extensions",
"platform": "!(staticcrt & windows)"
}
],
"features": {
"deprecated-win7-support": {
"description": "Deprecated support for the Windows 7 platform -- may be removed at any time."
},
"extensions": {
"description": "Allow the build and usage of python extensions. On windows this requires python to be a dynamic library!",
"supports": "!(staticcrt & windows)",
"dependencies": [
{
"name": "bzip2",
"default-features": false
},
{
"name": "expat",
"default-features": false
},
{
"name": "libffi",
"default-features": false
},
{
"name": "liblzma",
"default-features": false
},
{
"name": "openssl",
"default-features": false
},
{
"name": "sqlite3",
"default-features": false
}
]
},
"readline": {
"description": "Build with readline. Requires system readline to be installed",
"supports": "!windows"
}
}
}
Loading