@@ -3,6 +3,15 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static
3
3
set (VCPKG_LIBRARY_LINKAGE static )
4
4
endif ()
5
5
6
+ if ("extensions" IN_LIST FEATURES)
7
+ if (VCPKG_TARGET_IS_WINDOWS)
8
+ vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
9
+ endif ()
10
+ set (PYTHON_HAS_EXTENSIONS ON )
11
+ else ()
12
+ set (PYTHON_HAS_EXTENSIONS OFF )
13
+ endif ()
14
+
6
15
if (NOT VCPKG_HOST_IS_WINDOWS)
7
16
message (WARNING "${PORT} currently requires the following programs from the system package manager:
8
17
autoconf automake autoconf-archive
@@ -35,6 +44,7 @@ set(PATCHES
35
44
0015-dont-use-WINDOWS-def.patch
36
45
0016-undup-ffi-symbols.patch # Required for lld-link.
37
46
0018-fix-sysconfig-include .patch
47
+ 0019-fix-ssl-linkage.patch
38
48
)
39
49
40
50
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
@@ -57,6 +67,10 @@ endif()
57
67
58
68
if (VCPKG_TARGET_IS_WINDOWS)
59
69
string (COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE} " "dynamic" PYTHON_ALLOW_EXTENSIONS)
70
+ if (PYTHON_HAS_EXTENSIONS AND NOT PYTHON_ALLOW_EXTENSIONS)
71
+ # This should never be reached due to vcpkg_check_linkage above
72
+ message (FATAL_ERROR "Cannot build python extensions! Python extensions on windows can only be built if python is a dynamic library!" )
73
+ endif ()
60
74
# The Windows 11 SDK has a problem that causes it to error on the resource files, so we patch that.
61
75
vcpkg_get_windows_sdk(WINSDK_VERSION)
62
76
if ("${WINSDK_VERSION} " VERSION_GREATER_EQUAL "10.0.22000" )
@@ -102,7 +116,7 @@ endfunction()
102
116
if (VCPKG_TARGET_IS_WINDOWS)
103
117
# Due to the way Python handles C extension modules on Windows, a static python core cannot
104
118
# load extension modules.
105
- if (PYTHON_ALLOW_EXTENSIONS )
119
+ if (PYTHON_HAS_EXTENSIONS )
106
120
find_library (BZ2_RELEASE NAMES bz2 PATHS "${CURRENT_INSTALLED_DIR} /lib" NO_DEFAULT_PATH)
107
121
find_library (BZ2_DEBUG NAMES bz2d PATHS "${CURRENT_INSTALLED_DIR} /debug/lib" NO_DEFAULT_PATH)
108
122
find_library (CRYPTO_RELEASE NAMES libcrypto PATHS "${CURRENT_INSTALLED_DIR} /lib" NO_DEFAULT_PATH)
@@ -120,7 +134,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
120
134
list (APPEND add_libs_rel "${BZ2_RELEASE} ;${EXPAT_RELEASE} ;${FFI_RELEASE} ;${LZMA_RELEASE} ;${SQLITE_RELEASE} " )
121
135
list (APPEND add_libs_dbg "${BZ2_DEBUG} ;${EXPAT_DEBUG} ;${FFI_DEBUG} ;${LZMA_DEBUG} ;${SQLITE_DEBUG} " )
122
136
else ()
123
- message (STATUS "WARNING: Static builds of Python will not have C extension modules available." )
137
+ message (STATUS "WARNING: Extensions have been disabled. No C extension modules will be available." )
124
138
endif ()
125
139
find_library (ZLIB_RELEASE NAMES zlib PATHS "${CURRENT_INSTALLED_DIR} /lib" NO_DEFAULT_PATH)
126
140
find_library (ZLIB_DEBUG NAMES zlib zlibd PATHS "${CURRENT_INSTALLED_DIR} /debug/lib" NO_DEFAULT_PATH)
@@ -136,7 +150,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
136
150
)
137
151
138
152
list (APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_SET_CHARSET_FLAG=OFF" )
139
- if (PYTHON_ALLOW_EXTENSIONS )
153
+ if (PYTHON_HAS_EXTENSIONS )
140
154
set (OPTIONS
141
155
"/p:IncludeExtensions=true"
142
156
"/p:IncludeExternals=true"
@@ -189,7 +203,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
189
203
endif ()
190
204
191
205
# The extension modules must be placed in the DLLs directory, so we can't use vcpkg_copy_tools()
192
- if (PYTHON_ALLOW_EXTENSIONS )
206
+ if (PYTHON_HAS_EXTENSIONS )
193
207
file (GLOB_RECURSE PYTHON_EXTENSIONS_RELEASE "${CURRENT_BUILDTREES_DIR} /${TARGET_TRIPLET} -rel/*.pyd" )
194
208
file (COPY ${PYTHON_EXTENSIONS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR} /bin" )
195
209
file (COPY ${PYTHON_EXTENSIONS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR} /tools/${PORT} /DLLs" )
@@ -257,13 +271,18 @@ else()
257
271
"--without-ensurepip"
258
272
"--with-suffix="
259
273
"--with-system-expat"
260
- "--without-readline"
261
274
"--disable-test-modules"
262
275
)
263
276
if (VCPKG_TARGET_IS_OSX)
264
277
list (APPEND OPTIONS "LIBS=-liconv -lintl" )
265
278
endif ()
266
279
280
+ if ("readline" IN_LIST FEATURES)
281
+ list (APPEND OPTIONS "--with-readline" )
282
+ else ()
283
+ list (APPEND OPTIONS "--without-readline" )
284
+ endif ()
285
+
267
286
# The version of the build Python must match the version of the cross compiled host Python.
268
287
# https://docs.python.org/3/using/configure.html#cross-compiling-options
269
288
if (VCPKG_CROSSCOMPILING)
@@ -329,7 +348,7 @@ vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
329
348
330
349
file (READ "${CMAKE_CURRENT_LIST_DIR} /usage" usage)
331
350
if (VCPKG_TARGET_IS_WINDOWS)
332
- if (PYTHON_ALLOW_EXTENSIONS )
351
+ if (PYTHON_HAS_EXTENSIONS )
333
352
file (READ "${CMAKE_CURRENT_LIST_DIR} /usage.win" usage_extra)
334
353
else ()
335
354
set (usage_extra "" )
@@ -384,10 +403,12 @@ else()
384
403
file (COPY_FILE "${CURRENT_PACKAGES_DIR} /tools/python3/python3.${PYTHON_VERSION_MINOR} " "${CURRENT_PACKAGES_DIR} /tools/python3/python3" )
385
404
endif ()
386
405
387
- configure_file ("${CMAKE_CURRENT_LIST_DIR} /vcpkg-port-config.cmake" "${CURRENT_PACKAGES_DIR} /share/python3 /vcpkg-port-config.cmake" @ONLY)
406
+ configure_file ("${CMAKE_CURRENT_LIST_DIR} /vcpkg-port-config.cmake" "${CURRENT_PACKAGES_DIR} /share/${PORT} /vcpkg-port-config.cmake" @ONLY)
388
407
389
408
# For testing
390
409
block()
410
+ include ("${CURRENT_PACKAGES_DIR} /share/${PORT} /vcpkg-port-config.cmake" )
391
411
set (CURRENT_HOST_INSTALLED_DIR "${CURRENT_PACKAGES_DIR} " )
412
+ set (CURRENT_INSTALLED_DIR "${CURRENT_PACKAGES_DIR} " )
392
413
vcpkg_get_vcpkg_installed_python(VCPKG_PYTHON3)
393
- endblocK ()
414
+ endblock ()
0 commit comments