Skip to content

Commit

Permalink
Add pyqt5
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 2, 2024
1 parent 93d564a commit 41f6126
Show file tree
Hide file tree
Showing 11 changed files with 478 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ports/py-pyqt5-sip/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)

vcpkg_from_pythonhosted(
OUT_SOURCE_PATH SOURCE_PATH
PACKAGE_NAME PyQt5_sip
VERSION ${VERSION}
SHA512 ef363b21899f6d089fbc6d5adf700dc6c8838501343070ed1cf0826e05dd860343eba608d5aee5d8bece39b8ddca1f37866bb56aa07db18384ac0a372ca3532f
)

vcpkg_python_build_and_install_wheel(SOURCE_PATH "${SOURCE_PATH}")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

vcpkg_python_test_import(MODULE "PyQt5.sip")

set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
18 changes: 18 additions & 0 deletions ports/py-pyqt5-sip/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "py-pyqt5-sip",
"version": "12.13.0",
"description": "Python bindings for the Qt cross platform application toolkit",
"homepage": "https://www.riverbankcomputing.com/software/pyqt/",
"dependencies": [
"python3",
"py-sip",
{
"name": "py-setuptools",
"host": true
},
{
"name": "vcpkg-python-scripts",
"host": true
}
]
}
49 changes: 49 additions & 0 deletions ports/py-pyqt5/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
set(VCPKG_BUILD_TYPE release)

vcpkg_from_pythonhosted(
OUT_SOURCE_PATH SOURCE_PATH
PACKAGE_NAME PyQt5
VERSION ${VERSION}
SHA512 e62debe112210b68993377264448199b66a43fc5db13c583a25e210759f5cd945bd1056c1c19fb86bcf005c6904358dfb89e005d27167a349f1d55987a63013e
)

# https://www.riverbankcomputing.com/static/Docs/PyQt5/installation.html
# sipbuild repo: /project.py
set(SIPBUILD_ARGS
"--confirm-license"
"--qmake" "${CURRENT_INSTALLED_DIR}/tools/qt5/bin/qmake${VCPKG_HOST_EXECUTABLE_SUFFIX}"
"--api-dir" "${CURRENT_PACKAGES_DIR}/share/qt5/qsci/api/python"
"--verbose"
"--qt-shared"
"--no-make"
"--disable" "QtDesigner"
"--pep484-pyi"
"--build-dir" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel"
"--target-dir" "${PYTHON3_SITEPACKAGES}"
)

vcpkg_backup_env_variables(VARS PATH)

vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/python3/Scripts/" "${CURRENT_HOST_INSTALLED_DIR}/tools/qt5/bin/" "${CURRENT_HOST_INSTALLED_DIR}/bin")

message(STATUS "Running sipbuild...")
#vcpkg_execute_required_process(
# COMMAND "${PYTHON3}" "-m" "sipbuild.tools.build" ${SIPBUILD_ARGS}
# WORKING_DIRECTORY "${SOURCE_PATH}"
# LOGNAME "sipbuild-${TARGET_TRIPLET}"
#)
message(STATUS "Running sipbuild...finished.")

# inventory.txt is consumed by the distinfo tool which is run during make and should be run against the package directory
file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)
vcpkg_replace_string("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/inventory.txt"
"${CURRENT_INSTALLED_DIR}"
"${CURRENT_PACKAGES_DIR}")
vcpkg_replace_string("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/inventory.txt"
"${NATIVE_INSTALLED_DIR}"
"${CURRENT_PACKAGES_DIR}")

vcpkg_qmake_build(BUILD_LOGNAME "install" TARGETS "install")

vcpkg_python_test_import(MODULE "PyQt5.QtCore")
32 changes: 32 additions & 0 deletions ports/py-pyqt5/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "py-pyqt5",
"version": "5.15.10",
"description": "Python bindings for the Qt cross platform application toolkit",
"homepage": "https://www.riverbankcomputing.com/software/pyqt/",
"dependencies": [
"python3",
"py-sip",
"py-pyqt5-sip",
"py-pyqt-builder",
"py-ply",
"py-packaging",
{
"name": "qt5-activeqt",
"platform": "windows"
},
"qt5-base",
"qt5-multimedia",
"qt5-sensors",
"qt5-svg",
"qt5-webchannel",
"qt5-websockets",
{
"name": "vcpkg-python-scripts",
"host": true
},
{
"name": "vcpkg-qmake-qt5",
"host": true
}
]
}
10 changes: 10 additions & 0 deletions ports/vcpkg-qmake-qt5/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
file(INSTALL
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_configure.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_build.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_install.cmake"
"${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_qmake_fix_makefiles.cmake"
"${CMAKE_CURRENT_LIST_DIR}/vcpkg-port-config.cmake"
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

file(INSTALL "${VCPKG_ROOT_DIR}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
set(VCPKG_POLICY_CMAKE_HELPER_PORT enabled)
7 changes: 7 additions & 0 deletions ports/vcpkg-qmake-qt5/vcpkg-port-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include_guard(GLOBAL)
include("${CMAKE_CURRENT_LIST_DIR}/../vcpkg-cmake-get-vars/vcpkg-port-config.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/z_vcpkg_qmake_fix_makefiles.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_configure.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_build.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/vcpkg_qmake_install.cmake")

18 changes: 18 additions & 0 deletions ports/vcpkg-qmake-qt5/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vcpkg-qmake-qt5",
"version-date": "2024-02-29",
"documentation": "https://vcpkg.io/en/docs/README.html",
"license": "MIT",
"supports": "native",
"dependencies": [
"pkgconf",
{
"name": "qt5-base",
"default-features": false
},
{
"name": "vcpkg-cmake-get-vars",
"host": true
}
]
}
72 changes: 72 additions & 0 deletions ports/vcpkg-qmake-qt5/vcpkg_qmake_build.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
include_guard(GLOBAL)

function(z_run_jom_build invoke_command targets log_prefix log_suffix)
message(STATUS "Package ${log_prefix}-${TARGET_TRIPLET}-${log_suffix}")
vcpkg_execute_build_process(
COMMAND "${invoke_command}" -j ${VCPKG_CONCURRENCY} ${targets}
NO_PARALLEL_COMMAND "${invoke_command}" -j 1 ${targets}
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${log_suffix}"
LOGNAME "package-${log_prefix}-${TARGET_TRIPLET}-${log_suffix}"
)
endfunction()

function(vcpkg_qmake_build)
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
cmake_parse_arguments(PARSE_ARGV 0 arg
"SKIP_MAKEFILES"
"BUILD_LOGNAME"
"TARGETS;RELEASE_TARGETS;DEBUG_TARGETS"
)

# Make sure that the linker finds the libraries used
vcpkg_backup_env_variables(VARS PATH LD_LIBRARY_PATH)

if(CMAKE_HOST_WIN32)
if (VCPKG_QMAKE_USE_NMAKE)
find_program(NMAKE nmake)
set(invoke_command "${NMAKE}")
get_filename_component(nmake_exe_path "${NMAKE}" DIRECTORY)
vcpkg_host_path_list(APPEND ENV{PATH} "${nmake_exe_path}")
else()
vcpkg_find_acquire_program(JOM)
set(invoke_command "${JOM}")
endif()
else()
find_program(MAKE make)
set(invoke_command "${MAKE}")
endif()

file(TO_NATIVE_PATH "${CURRENT_INSTALLED_DIR}" NATIVE_INSTALLED_DIR)

if(NOT DEFINED arg_BUILD_LOGNAME)
set(arg_BUILD_LOGNAME build)
endif()

set(short_name_debug "dbg")
set(path_suffix_debug "/debug")
set(targets_debug "${arg_DEBUG_TARGETS}")

set(short_name_release "rel")
set(path_suffix_release "")
set(targets_release "${arg_RELEASE_TARGETS}")

if(NOT DEFINED VCPKG_BUILD_TYPE)
set(items debug release)
else()
set(items release)
endif()
foreach(build_type IN ITEMS ${items})
set(current_installed_prefix "${CURRENT_INSTALLED_DIR}${path_suffix_${build_type}}")

vcpkg_add_to_path(PREPEND "${current_installed_prefix}/lib" "${current_installed_prefix}/bin")

vcpkg_list(SET targets ${targets_${build_type}} ${arg_TARGETS})
if(NOT arg_SKIP_MAKEFILES)
z_run_jom_build("${invoke_command}" qmake_all makefiles "${short_name_${build_type}}")
z_vcpkg_qmake_fix_makefiles("${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_name_${build_type}}")
endif()
z_run_jom_build("${invoke_command}" "${targets}" "${arg_BUILD_LOGNAME}" "${short_name_${build_type}}")

vcpkg_restore_env_variables(VARS PATH LD_LIBRARY_PATH)
endforeach()
endfunction()
Loading

0 comments on commit 41f6126

Please sign in to comment.