Skip to content

Commit

Permalink
add port vcpkg-tool-python2 (#23431)
Browse files Browse the repository at this point in the history
* add vcpkg-tool-lessmsi

* add vcpkg-tool-python2

* adjust vcpkg_find_acquire_program

* use python2 dependency in qt5-base

* remove python2 from qt5-base

* add python2 to qt5-webengine

* use python3 instead of python2

* add some deps on the new vcpkg-tool-python2

* Apply suggestions from code review

Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>

* add license field

* fix test detection

* error on failure to find python2

* move logs to correct position.

* add dep to qtwebengine

* adjust pybind cmake config.

* fix shiva

* move python2 to manual-tools
adjust search path
generate a details.cmake for vcpkg_find_acquire_program

* format manifest

* use version-date

* version stuff

* replace version-string

* more version stuff

* fix search path and add supports expression

* version stuff

* shiva version

* remove arm windows from support

* reuse output_path
use lessmsi is a host dep so use the correct path

* version stuff

* Fix x86 regression

* version stuff

* try fixing qtinterfaceframework

* version stuff

Co-authored-by: Alexander Neumann <you@example.com>
Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com>
Co-authored-by: Victor Romero <viromer@microsoft.com>
Co-authored-by: Victor Romero <romerosanchezv@gmail.com>
  • Loading branch information
5 people authored Mar 14, 2022
1 parent 9659615 commit fad0644
Show file tree
Hide file tree
Showing 29 changed files with 272 additions and 44 deletions.
8 changes: 6 additions & 2 deletions ports/blitz/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "blitz",
"version-string": "2020-03-25",
"port-version": 4,
"version-date": "2020-03-25",
"port-version": 5,
"description": "Blitz++ is a C++ template class library that provides high-performance multidimensional array containers for scientific computing.",
"homepage": "https://github.com/blitzpp/blitz",
"supports": "!(arm | arm64 | uwp)",
Expand All @@ -13,6 +13,10 @@
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "vcpkg-tool-python2",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions ports/pybind11/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ vcpkg_cmake_config_fixup(CONFIG_PATH "share/cmake/pybind11")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/")

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/pybind11/pybind11Tools.cmake"
[=[find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})]=]
[=[find_package(PythonLibs ${PYBIND11_PYTHON_VERSION} MODULE REQUIRED ${_pybind11_quiet})]=]) # CMake's PythonLibs works better with vcpkg

# copy license
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
3 changes: 2 additions & 1 deletion ports/pybind11/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "pybind11",
"version-semver": "2.9.1",
"version": "2.9.1",
"port-version": 1,
"description": "pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code",
"homepage": "https://github.com/pybind/pybind11",
"license": "BSD-3-Clause",
Expand Down
8 changes: 5 additions & 3 deletions ports/qt5-base/cmake/qt_build_submodule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ function(qt_build_submodule SOURCE_PATH)
# This fixes issues on machines with default codepages that are not ASCII compatible, such as some CJK encodings
set(ENV{_CL_} "/utf-8")

vcpkg_find_acquire_program(PYTHON2)
get_filename_component(PYTHON2_EXE_PATH ${PYTHON2} DIRECTORY)
vcpkg_add_to_path("${PYTHON2_EXE_PATH}")
if(NOT PORT STREQUAL "qt5-webengine")
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_EXE_PATH ${PYTHON3} DIRECTORY)
vcpkg_add_to_path("${PYTHON3_EXE_PATH}")
endif()

vcpkg_configure_qmake(SOURCE_PATH ${SOURCE_PATH} ${ARGV})

Expand Down
1 change: 1 addition & 0 deletions ports/qt5-base/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "qt5-base",
"version": "5.15.3",
"port-version": 1,
"description": "Qt5 Application Framework Base Module. Includes Core, GUI, Widgets, Networking, SQL, Concurrent and other essential qt components.",
"homepage": "https://www.qt.io/",
"license": null,
Expand Down
5 changes: 4 additions & 1 deletion ports/qtinterfaceframework/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ vcpkg_add_to_path(PREPEND "${PYTHON3_DIR}")
vcpkg_add_to_path(PREPEND "${PYTHON3_DIR}/Scripts")
vcpkg_get_python_package(PYTHON_EXECUTABLE "${PYTHON3}" PACKAGES virtualenv qface)

if(VCPKG_CROSSCOMPILING)
list(APPEND FEATURE_OPTIONS "-DVCPKG_HOST_TRIPLET=${_HOST_TRIPLET}")
endif()

set(qt_plugindir ${QT6_DIRECTORY_PREFIX}plugins)
set(qt_qmldir ${QT6_DIRECTORY_PREFIX}qml)
qt_cmake_configure(${_opt}
OPTIONS ${FEATURE_OPTIONS}
"-DCMAKE_PROGRAM_PATH=${CURRENT_HOST_INSTALLED_DIR}/tools/pkgconf" # need to overwrite vcpkg.cmake
"-DPython3_EXECUTABLE=${PYTHON3}" # Otherwise a VS installation might be found.
OPTIONS_DEBUG ${_qis_CONFIGURE_OPTIONS_DEBUG}
OPTIONS_RELEASE ${_qis_CONFIGURE_OPTIONS_RELEASE})
Expand Down
2 changes: 1 addition & 1 deletion ports/qtinterfaceframework/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "qtinterfaceframework",
"version": "6.2.3",
"port-version": 1,
"port-version": 2,
"description": "Qt Interface Framework",
"homepage": "https://www.qt.io/",
"license": null,
Expand Down
5 changes: 5 additions & 0 deletions ports/qtwebengine/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$comment": "x86-windows is not within the upstream support matrix of Qt6",
"name": "qtwebengine",
"version": "6.2.3",
"port-version": 1,
"description": "Qt WebEngine",
"homepage": "https://www.qt.io/",
"license": null,
Expand Down Expand Up @@ -107,6 +108,10 @@
"name": "vcpkg-tool-nodejs",
"host": true
},
{
"name": "vcpkg-tool-python2",
"host": true
},
{
"name": "zlib",
"platform": "!windows"
Expand Down
13 changes: 13 additions & 0 deletions ports/shiva/no_copy_dll.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt
index eef14ee87..d52a147d8 100644
--- a/modules/python/CMakeLists.txt
+++ b/modules/python/CMakeLists.txt
@@ -4,7 +4,7 @@ set(MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(pybind11 CONFIG REQUIRED)


-if (WIN32)
+if (WIN32 AND FALSE)
## We need pyton dll
file(GLOB PYTHON_DLL ${PYTHON_LIBRARIES}/../*.dll)

30 changes: 18 additions & 12 deletions ports/shiva/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
vcpkg_find_acquire_program(PYTHON2)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Milerius/shiva
REF 1.0
SHA512 d1ce33e89b17fa8f82e21b51dfa1308e38c617fea52c34a20b7b6c8643318280df24c043238ddd73ba2dbc139c5b5de1c2cb3add1f5629a54694c78b415d73d1
HEAD_REF master
PATCHES no_copy_dll.patch
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
find_library(PYTHON_RELEASE NAMES python310 PATHS "${CURRENT_INSTALLED_DIR}/lib" NO_DEFAULT_PATH)
find_library(PYTHON_DEBUG NAMES python310_d python310 PATHS "${CURRENT_INSTALLED_DIR}/debug/lib" NO_DEFAULT_PATH)
include(SelectLibraryConfigurations)
select_library_configurations(PYTHON)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DSHIVA_BUILD_TESTS=OFF
-DPYTHON_EXECUTABLE=${PYTHON2}
-DSHIVA_BUILD_TESTS=OFF
"-DPYTHON_LIBRARY=${PYTHON_LIBRARIES}"
"-DPYTHON_LIBRARIES=${PYTHON_LIBRARIES}"
"-DPYTHON_EXECUTABLE=${CURRENT_INSTALLED_DIR}/tools/python3/python${VCPKG_EXECUTABLE_SUFFIX}"
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/shiva)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/shiva")

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug ${CURRENT_PACKAGES_DIR}/lib)
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/shiva)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/shiva/LICENSE ${CURRENT_PACKAGES_DIR}/share/shiva/copyright)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug" "${CURRENT_PACKAGES_DIR}/lib")
file(COPY "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/shiva")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/shiva/LICENSE" "${CURRENT_PACKAGES_DIR}/share/shiva/copyright")
14 changes: 11 additions & 3 deletions ports/shiva/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "shiva",
"version-string": "1.0",
"port-version": 4,
"version": "1.0",
"port-version": 5,
"description": "Modern C++ Game Engine",
"homepage": "https://github.com/Milerius/shiva",
"dependencies": [
Expand All @@ -17,6 +17,14 @@
"nlohmann-json",
"pybind11",
"sol2",
"spdlog"
"spdlog",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
6 changes: 5 additions & 1 deletion ports/v8/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "v8",
"version": "9.1.269.39",
"port-version": 2,
"port-version": 3,
"description": "Google Chrome's JavaScript engine",
"homepage": "https://v8.dev",
"supports": "!(arm | arm64 | uwp | osx)",
Expand All @@ -15,6 +15,10 @@
"name": "pthread",
"platform": "linux"
},
{
"name": "vcpkg-tool-python2",
"host": true
},
"zlib"
]
}
9 changes: 8 additions & 1 deletion ports/vcpkg-gn/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"name": "vcpkg-gn",
"version-date": "2021-11-16",
"port-version": 1,
"description": "https://gn.googlesource.com/gn/+/4aa9bdfa05b688c58d3d7d3e496f3f18cbb3d89e",
"supports": "native & !x86"
"supports": "native & !x86",
"dependencies": [
{
"name": "vcpkg-tool-python2",
"host": true
}
]
}
17 changes: 17 additions & 0 deletions ports/vcpkg-tool-lessmsi/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

set(version v1.10.0)

vcpkg_download_distfile(archive_path
URLS "https://github.com/activescott/lessmsi/releases/download/${version}/lessmsi-${version}.zip"
FILENAME "lessmsi-${version}.zip"
SHA512 91be9363d75e8ca0129304008ddc26fe575cc4fd76d7f43ef0a6ff414855dc1c6e412f4e694b2950026e02cc3d31b18bd8c2e4c03e1ddce01477f3f2d2197479
)

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}")

file(ARCHIVE_EXTRACT
INPUT "${archive_path}"
DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}"
)

8 changes: 8 additions & 0 deletions ports/vcpkg-tool-lessmsi/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "vcpkg-tool-lessmsi",
"version": "1.10.0",
"description": "This is a utility with a graphical user interface and a command line interface that can be used to view and extract the contents of an MSI file.",
"homepage": "https://github.com/activescott/lessmsi",
"license": "MIT",
"supports": "native & windows"
}
60 changes: 60 additions & 0 deletions ports/vcpkg-tool-python2/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

if(VCPKG_TARGET_IS_WINDOWS)
set(arch_suffix "")
set(program_name python)
set(program_version 2.7.18)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
set(tool_subdirectory "python-${program_version}-x86")
set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}.msi")
set(download_filename "python-${program_version}.msi")
set(download_sha512 2c112733c777ddbf189b0a54047a9d5851ebce0564cc38b9687d79ce6c7a09006109dbad8627fb1a60c3ad55e261db850d9dfa454af0533b460b2afc316fe115)
else()
set(tool_subdirectory "python-${program_version}-x64")
set(arch_suffix ".amd64")
set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}.amd64.msi")
set(download_filename "python-${program_version}.amd64.msi")
set(download_sha512 6a81a413b80fd39893e7444fd47efa455d240cbb77a456c9d12f7cf64962b38c08cfa244cd9c50a65947c40f936c6c8c5782f7236d7b92445ab3dd01e82af23e)
endif()
set(paths_to_search "${CURRENT_PACKAGES_DIR}/manual-tools/${PORT}")

vcpkg_download_distfile(archive_path
URLS ${download_urls}
SHA512 "${download_sha512}"
FILENAME "${download_filename}"
)
set(output_path "${CURRENT_PACKAGES_DIR}/manual-tools") # vcpkg.cmake adds everything in /tools to CMAKE_PROGRAM_PATH. That is not desired for Python2
file(MAKE_DIRECTORY "${output_path}")
cmake_path(NATIVE_PATH archive_path archive_path_native) # lessmsi is a bit picky about path formats.
message(STATUS "Extracting Python2 ...")
vcpkg_execute_in_download_mode(
COMMAND "${CURRENT_HOST_INSTALLED_DIR}/tools/vcpkg-tool-lessmsi/lessmsi.exe" x "${archive_path_native}" # Using output_path here does not work in bash
WORKING_DIRECTORY "${output_path}"
OUTPUT_FILE "${CURRENT_BUILDTREES_DIR}/lessmsi-${TARGET_TRIPLET}-out.log"
ERROR_FILE "${CURRENT_BUILDTREES_DIR}/lessmsi-${TARGET_TRIPLET}-err.log"
RESULT_VARIABLE error_code
)
if(error_code)
message(FATAL_ERROR "Couldn't extract Python2 with lessmsi!")
endif()
message(STATUS "Extracting Python2 ... finished!")
file(RENAME "${output_path}/python-2.7.18${arch_suffix}/SourceDir/" "${output_path}/${PORT}/")
file(REMOVE_RECURSE "${output_path}/python-2.7.18.amd64"
# Files below are not part of a msiexec installation/extraction.
"${output_path}/${PORT}/Windows"
"${output_path}/${PORT}/Microsoft.VC90.CRT.manifest"
"${output_path}/${PORT}/msvcr90.dll")
z_vcpkg_find_acquire_program_find_internal("PYTHON2"
INTERPRETER "${interpreter}"
PATHS ${paths_to_search}
NAMES ${program_name}
)
if(NOT PYTHON2)
message(FATAL_ERROR "Unable to find python2: ${PYTHON2}")
endif()
message(STATUS "Using python2: ${PYTHON2}")
set(details "set(program_version \"${program_version}\")\n")
string(APPEND details "set(paths_to_search \"\${CURRENT_HOST_INSTALLED_DIR}/manual-tools/${PORT}\")\n")
file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/details.cmake" "${details}")
endif()

15 changes: 15 additions & 0 deletions ports/vcpkg-tool-python2/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "vcpkg-tool-python2",
"version": "2.7.18",
"description": "Python 2",
"homepage": "https://www.python.org/download/releases/2.0/",
"license": "PSF-2.0",
"supports": "!uwp & !(arm & windows)",
"dependencies": [
{
"name": "vcpkg-tool-lessmsi",
"host": true,
"platform": "windows"
}
]
}
26 changes: 15 additions & 11 deletions scripts/cmake/vcpkg_find_acquire_program.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -270,18 +270,22 @@ function(vcpkg_find_acquire_program program)
if(CMAKE_HOST_WIN32)
set(program_name python)
set(program_version 2.7.18)
if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
set(tool_subdirectory "python-${program_version}-x86")
set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}.msi")
set(download_filename "python-${program_version}.msi")
set(download_sha512 2c112733c777ddbf189b0a54047a9d5851ebce0564cc38b9687d79ce6c7a09006109dbad8627fb1a60c3ad55e261db850d9dfa454af0533b460b2afc316fe115)
else()
set(tool_subdirectory "python-${program_version}-x64")
set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}.amd64.msi")
set(download_filename "python-${program_version}.amd64.msi")
set(download_sha512 6a81a413b80fd39893e7444fd47efa455d240cbb77a456c9d12f7cf64962b38c08cfa244cd9c50a65947c40f936c6c8c5782f7236d7b92445ab3dd01e82af23e)
if(EXISTS "${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-tool-python2/details.cmake")
include("${CURRENT_HOST_INSTALLED_DIR}/share/vcpkg-tool-python2/details.cmake")
else() # Old behavior
if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
set(tool_subdirectory "python-${program_version}-x86")
set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}.msi")
set(download_filename "python-${program_version}.msi")
set(download_sha512 2c112733c777ddbf189b0a54047a9d5851ebce0564cc38b9687d79ce6c7a09006109dbad8627fb1a60c3ad55e261db850d9dfa454af0533b460b2afc316fe115)
else()
set(tool_subdirectory "python-${program_version}-x64")
set(download_urls "https://www.python.org/ftp/python/${program_version}/python-${program_version}.amd64.msi")
set(download_filename "python-${program_version}.amd64.msi")
set(download_sha512 6a81a413b80fd39893e7444fd47efa455d240cbb77a456c9d12f7cf64962b38c08cfa244cd9c50a65947c40f936c6c8c5782f7236d7b92445ab3dd01e82af23e)
endif()
set(paths_to_search "${DOWNLOADS}/tools/python/${tool_subdirectory}")
endif()
set(paths_to_search "${DOWNLOADS}/tools/python/${tool_subdirectory}")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
# macOS includes Python 2.7 built-in as `python`
set(program_name python)
Expand Down
5 changes: 5 additions & 0 deletions versions/b-/blitz.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "58bca2588e7ff4935893cfebdf1d9665f95f846e",
"version-date": "2020-03-25",
"port-version": 5
},
{
"git-tree": "694507bc15d282e3de5160a0a221abfa381e6327",
"version-string": "2020-03-25",
Expand Down
Loading

0 comments on commit fad0644

Please sign in to comment.