-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[3fd|python3] switch to vcpkg-msbuild #33026
Changes from 7 commits
3b0c79f
b9c0bdc
0adfc3b
91e4a52
fead72a
e5ba0fb
ba9f83f
f4cd96f
a80933b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/PC/launcher.c b/PC/launcher.c | ||
index 734e75333..7124927cf 100644 | ||
--- a/PC/launcher.c | ||
+++ b/PC/launcher.c | ||
@@ -2015,7 +2015,7 @@ installed, use -0 for available pythons", &p[1]); | ||
return rc; | ||
} | ||
|
||
-#if defined(_WINDOWS) | ||
+#if !defined(_CONSOLE) // _WINDOWS is defined by the vcpkg toolchain | ||
|
||
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | ||
LPWSTR lpstrCmd, int nShow) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
diff --git a/PCbuild/_freeze_module.vcxproj b/PCbuild/_freeze_module.vcxproj | ||
index 7d3423251f..7f607742fe 100644 | ||
--- a/PCbuild/_freeze_module.vcxproj | ||
+++ b/PCbuild/_freeze_module.vcxproj | ||
@@ -366,7 +366,7 @@ | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
<Target Name="_RebuildGetPath" AfterTargets="_RebuildFrozen" Condition="$(Configuration) != 'PGUpdate'"> | ||
- <Exec Command='"$(TargetPath)" "%(GetPath.ModName)" "%(GetPath.FullPath)" "%(GetPath.IntFile)"' /> | ||
+ <Exec Command='"_freeze_module.exe" "%(GetPath.ModName)" "%(GetPath.FullPath)" "%(GetPath.IntFile)"' /> | ||
|
||
<Copy SourceFiles="%(GetPath.IntFile)" | ||
DestinationFiles="%(GetPath.OutFile)" | ||
@@ -378,7 +378,7 @@ | ||
Condition="'@(_UpdatedGetPath)' != ''" Importance="high" /> | ||
</Target> | ||
<Target Name="_RebuildFrozen" AfterTargets="AfterBuild" Condition="$(Configuration) != 'PGUpdate'"> | ||
- <Exec Command='"$(TargetPath)" "%(None.ModName)" "%(None.FullPath)" "%(None.IntFile)"' /> | ||
+ <Exec Command='"_freeze_module.exe" "%(None.ModName)" "%(None.FullPath)" "%(None.IntFile)"' /> | ||
|
||
<Copy SourceFiles="%(None.IntFile)" | ||
DestinationFiles="%(None.OutFile)" | ||
diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj | ||
index c49a8533ad..b1cdf7c8d7 100644 | ||
--- a/PCbuild/pcbuild.proj | ||
+++ b/PCbuild/pcbuild.proj | ||
@@ -14,6 +14,6 @@ | ||
<ItemDefinitionGroup> | ||
<FreezeProjects> | ||
- <Platform>$(PreferredToolArchitecture)</Platform> | ||
+ <Platform>$(Platform)</Platform> | ||
<Configuration>$(Configuration)</Configuration> | ||
<Configuration Condition="$(Configuration) == 'PGInstrument'">Release</Configuration> | ||
<Properties></Properties> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,15 @@ set(PATCHES | |
0010-dont-skip-rpath.patch | ||
0012-force-disable-curses.patch | ||
0014-fix-get-python-inc-output.patch | ||
0015-dont-use-WINDOWS-def.patch | ||
) | ||
|
||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||
list(APPEND PATCHES 0002-static-library.patch) | ||
endif() | ||
|
||
# Fix build failures with GCC for built-in modules (https://github.com/microsoft/vcpkg/issues/26573) | ||
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
if(VCPKG_TARGET_IS_LINUX) | ||
list(APPEND PATCHES 0011-gcc-ldflags-fix.patch) | ||
endif() | ||
|
||
|
@@ -37,13 +38,16 @@ elseif(VCPKG_TARGET_IS_WINDOWS AND CMAKE_SYSTEM_VERSION EQUAL 6.1) | |
message(FATAL_ERROR "python3 requires the feature deprecated-win7-support when building on Windows 7.") | ||
endif() | ||
|
||
if(VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_UWP) | ||
if(VCPKG_TARGET_IS_WINDOWS) | ||
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" PYTHON_ALLOW_EXTENSIONS) | ||
# 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") | ||
list(APPEND PATCHES "0007-workaround-windows-11-sdk-rc-compiler-error.patch") | ||
endif() | ||
if(VCPKG_CROSSCOMPILING) | ||
list(APPEND PATCHES "0016-fix-win-cross.patch") | ||
endif() | ||
endif() | ||
|
||
vcpkg_from_github( | ||
|
@@ -94,20 +98,25 @@ if(VCPKG_TARGET_IS_WINDOWS) | |
find_library(SQLITE_DEBUG NAMES sqlite3 PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH) | ||
find_library(SSL_RELEASE NAMES libssl PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH) | ||
find_library(SSL_DEBUG NAMES libssl PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH) | ||
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}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this benefit from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could rather add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these libs duplicated in props file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ultimate cleanup plan would be to remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Hoikas I assume the why is in response of dropping the |
||
else() | ||
message(STATUS "WARNING: Static builds of Python will not have C extension modules 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) | ||
list(APPEND add_libs_rel "${ZLIB_RELEASE}") | ||
list(APPEND add_libs_dbg "${ZLIB_DEBUG}") | ||
|
||
configure_file("${SOURCE_PATH}/PC/pyconfig.h" "${SOURCE_PATH}/PC/pyconfig.h") | ||
configure_file("${CMAKE_CURRENT_LIST_DIR}/python_vcpkg.props.in" "${SOURCE_PATH}/PCbuild/python_vcpkg.props") | ||
configure_file("${CMAKE_CURRENT_LIST_DIR}/openssl.props.in" "${SOURCE_PATH}/PCbuild/openssl.props") | ||
file(WRITE "${SOURCE_PATH}/PCbuild/libffi.props" | ||
"<?xml version='1.0' encoding='utf-8'?> | ||
<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' />" | ||
"<?xml version='1.0' encoding='utf-8'?>" | ||
"<Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' />" | ||
) | ||
|
||
list(APPEND VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_SET_CHARSET_FLAG=OFF") | ||
if(PYTHON_ALLOW_EXTENSIONS) | ||
set(OPTIONS | ||
"/p:IncludeExtensions=true" | ||
|
@@ -137,27 +146,29 @@ if(VCPKG_TARGET_IS_WINDOWS) | |
list(APPEND OPTIONS "/p:_VcpkgPythonLinkage=StaticLibrary") | ||
endif() | ||
|
||
# _freeze_importlib.exe is run as part of the build process, so make sure the required dynamic libs are available. | ||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release") | ||
vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}/bin") | ||
endif() | ||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug") | ||
vcpkg_add_to_path("${CURRENT_INSTALLED_DIR}/debug/bin") | ||
endif() | ||
vcpkg_find_acquire_program(PYTHON3) | ||
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) | ||
set(ENV{PythonForBuild} "${PYTHON3_DIR}/python.exe") # PythonForBuild is what's used on windows, despite the readme | ||
|
||
vcpkg_find_acquire_program(PYTHON3) | ||
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY) | ||
set(ENV{PythonForBuild} "${PYTHON3_DIR}/python.exe") # PythonForBuild is what's used on windows, despite the readme | ||
if(VCPKG_CROSSCOMPILING) | ||
vcpkg_add_to_path("${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}") | ||
endif() | ||
|
||
vcpkg_install_msbuild( | ||
vcpkg_msbuild_install( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
PROJECT_SUBPATH "PCbuild/pcbuild.proj" | ||
ADD_BIN_TO_PATH | ||
OPTIONS ${OPTIONS} | ||
LICENSE_SUBPATH "LICENSE" | ||
TARGET_PLATFORM_VERSION "${WINSDK_VERSION}" | ||
SKIP_CLEAN | ||
ADDITIONAL_LIBS_RELEASE ${add_libs_rel} | ||
ADDITIONAL_LIBS_DEBUG ${add_libs_dbg} | ||
) | ||
|
||
if(NOT VCPKG_CROSSCOMPILING) | ||
file(GLOB_RECURSE freeze_module "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/PCbuild/**/_freeze_module.exe") | ||
file(COPY "${freeze_module}" DESTINATION "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}") | ||
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}") | ||
endif() | ||
|
||
# The extension modules must be placed in the DLLs directory, so we can't use vcpkg_copy_tools() | ||
if(PYTHON_ALLOW_EXTENSIONS) | ||
file(GLOB_RECURSE PYTHON_EXTENSIONS_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/*.pyd") | ||
|
@@ -203,8 +214,6 @@ if(VCPKG_TARGET_IS_WINDOWS) | |
|
||
vcpkg_fixup_pkgconfig() | ||
|
||
vcpkg_clean_msbuild() | ||
|
||
# Remove static library belonging to executable | ||
if (VCPKG_LIBRARY_LINKAGE STREQUAL "static") | ||
if (EXISTS "${CURRENT_PACKAGES_DIR}/lib/python.lib") | ||
|
@@ -277,8 +286,6 @@ else() | |
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/bin") | ||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug") | ||
|
||
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME "copyright") | ||
|
||
vcpkg_fixup_pkgconfig() | ||
|
||
# Perform some post-build checks on modules | ||
|
@@ -302,6 +309,8 @@ else() | |
endif() | ||
endif() | ||
|
||
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) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to use
vcpkg_msbuild_install
, too?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm would have assumed CI to catch that but I see
3fd:x64-uwp: cascade
. So the port once build for uwp but no longer does.Reason:
poco is only supported on '!uwp', which does not match x64-uwp.