@@ -3,6 +3,15 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic AND VCPKG_CRT_LINKAGE STREQUAL static
33 set (VCPKG_LIBRARY_LINKAGE static )
44endif ()
55
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+
615if (NOT VCPKG_HOST_IS_WINDOWS)
716 message (WARNING "${PORT} currently requires the following programs from the system package manager:
817 autoconf automake autoconf-archive
@@ -35,6 +44,7 @@ set(PATCHES
3544 0015-dont-use-WINDOWS-def.patch
3645 0016-undup-ffi-symbols.patch # Required for lld-link.
3746 0018-fix-sysconfig-include .patch
47+ 0019-fix-ssl-linkage.patch
3848)
3949
4050if (VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
@@ -57,6 +67,10 @@ endif()
5767
5868if (VCPKG_TARGET_IS_WINDOWS)
5969 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 ()
6074 # The Windows 11 SDK has a problem that causes it to error on the resource files, so we patch that.
6175 vcpkg_get_windows_sdk(WINSDK_VERSION)
6276 if ("${WINSDK_VERSION} " VERSION_GREATER_EQUAL "10.0.22000" )
@@ -102,7 +116,7 @@ endfunction()
102116if (VCPKG_TARGET_IS_WINDOWS)
103117 # Due to the way Python handles C extension modules on Windows, a static python core cannot
104118 # load extension modules.
105- if (PYTHON_ALLOW_EXTENSIONS )
119+ if (PYTHON_HAS_EXTENSIONS )
106120 find_library (BZ2_RELEASE NAMES bz2 PATHS "${CURRENT_INSTALLED_DIR} /lib" NO_DEFAULT_PATH)
107121 find_library (BZ2_DEBUG NAMES bz2d PATHS "${CURRENT_INSTALLED_DIR} /debug/lib" NO_DEFAULT_PATH)
108122 find_library (CRYPTO_RELEASE NAMES libcrypto PATHS "${CURRENT_INSTALLED_DIR} /lib" NO_DEFAULT_PATH)
@@ -120,7 +134,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
120134 list (APPEND add_libs_rel "${BZ2_RELEASE} ;${EXPAT_RELEASE} ;${FFI_RELEASE} ;${LZMA_RELEASE} ;${SQLITE_RELEASE} " )
121135 list (APPEND add_libs_dbg "${BZ2_DEBUG} ;${EXPAT_DEBUG} ;${FFI_DEBUG} ;${LZMA_DEBUG} ;${SQLITE_DEBUG} " )
122136 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." )
124138 endif ()
125139 find_library (ZLIB_RELEASE NAMES zlib PATHS "${CURRENT_INSTALLED_DIR} /lib" NO_DEFAULT_PATH)
126140 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)
136150 )
137151
138152 list (APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_SET_CHARSET_FLAG=OFF" )
139- if (PYTHON_ALLOW_EXTENSIONS )
153+ if (PYTHON_HAS_EXTENSIONS )
140154 set (OPTIONS
141155 "/p:IncludeExtensions=true"
142156 "/p:IncludeExternals=true"
@@ -189,7 +203,7 @@ if(VCPKG_TARGET_IS_WINDOWS)
189203 endif ()
190204
191205 # 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 )
193207 file (GLOB_RECURSE PYTHON_EXTENSIONS_RELEASE "${CURRENT_BUILDTREES_DIR} /${TARGET_TRIPLET} -rel/*.pyd" )
194208 file (COPY ${PYTHON_EXTENSIONS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR} /bin" )
195209 file (COPY ${PYTHON_EXTENSIONS_RELEASE} DESTINATION "${CURRENT_PACKAGES_DIR} /tools/${PORT} /DLLs" )
@@ -257,13 +271,18 @@ else()
257271 "--without-ensurepip"
258272 "--with-suffix="
259273 "--with-system-expat"
260- "--without-readline"
261274 "--disable-test-modules"
262275 )
263276 if (VCPKG_TARGET_IS_OSX)
264277 list (APPEND OPTIONS "LIBS=-liconv -lintl" )
265278 endif ()
266279
280+ if ("readline" IN_LIST FEATURES)
281+ list (APPEND OPTIONS "--with-readline" )
282+ else ()
283+ list (APPEND OPTIONS "--without-readline" )
284+ endif ()
285+
267286 # The version of the build Python must match the version of the cross compiled host Python.
268287 # https://docs.python.org/3/using/configure.html#cross-compiling-options
269288 if (VCPKG_CROSSCOMPILING)
@@ -329,7 +348,7 @@ vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
329348
330349file (READ "${CMAKE_CURRENT_LIST_DIR} /usage" usage)
331350if (VCPKG_TARGET_IS_WINDOWS)
332- if (PYTHON_ALLOW_EXTENSIONS )
351+ if (PYTHON_HAS_EXTENSIONS )
333352 file (READ "${CMAKE_CURRENT_LIST_DIR} /usage.win" usage_extra)
334353 else ()
335354 set (usage_extra "" )
@@ -384,10 +403,12 @@ else()
384403 file (COPY_FILE "${CURRENT_PACKAGES_DIR} /tools/python3/python3.${PYTHON_VERSION_MINOR} " "${CURRENT_PACKAGES_DIR} /tools/python3/python3" )
385404endif ()
386405
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)
388407
389408# For testing
390409block()
410+ include ("${CURRENT_PACKAGES_DIR} /share/${PORT} /vcpkg-port-config.cmake" )
391411 set (CURRENT_HOST_INSTALLED_DIR "${CURRENT_PACKAGES_DIR} " )
412+ set (CURRENT_INSTALLED_DIR "${CURRENT_PACKAGES_DIR} " )
392413 vcpkg_get_vcpkg_installed_python(VCPKG_PYTHON3)
393- endblocK ()
414+ endblock ()
0 commit comments