diff options
author | Dominik Holland <dominik.holland@qt.io> | 2021-10-27 12:42:38 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2021-12-07 06:15:26 +0100 |
commit | c39926232ee04ded0ebbe971aeb047b6d92ee4d8 (patch) | |
tree | 3ef659a62d82ce142962263ea399ab2f835e965a | |
parent | 0ee4da26755fffec0beb157ddf11c8684f2f9b10 (diff) |
The virtualenv created on an newer macoOS systems doesn't work out
of the box when copying the executables because of a broken code signature.
The signature needs to be recreated ad-hoc, but as we need to use pip3
for the package installation this needs to be done right after the
virtualenv is created.
Fixes: AUTOSUITE-1645
Change-Id: Ie79c9fb20af95abf93aed1bc7edbcd6e5f00cee4
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
(cherry picked from commit f19607dc79930b0d5acebc7e894eae18f202ffbc)
-rw-r--r-- | src/tools/ifcodegen/CMakeLists.txt | 11 | ||||
-rwxr-xr-x | src/tools/ifcodegen/fix-macos-virtualenv.sh | 61 |
2 files changed, 72 insertions, 0 deletions
diff --git a/src/tools/ifcodegen/CMakeLists.txt b/src/tools/ifcodegen/CMakeLists.txt index e5b68fef..b9f74e80 100644 --- a/src/tools/ifcodegen/CMakeLists.txt +++ b/src/tools/ifcodegen/CMakeLists.txt @@ -31,6 +31,15 @@ if(QT_FEATURE_python3_virtualenv AND NOT QT_FEATURE_system_qface) set(DEPLOY_VIRTUALENV ${CMAKE_CURRENT_SOURCE_DIR}/deploy-virtualenv.sh) endif() + # The virtualenv created on new macOS versions doesn't work out of the box when copying the executables + # because of a broken code signature + # The signature needs to be recreated ad-hoc, but as we need to use pip3 for the package installation + # this needs to be done right after the virtualenv is created. + set(FIX_VIRTUALENV_COMMAND) + if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Darwin") + set(FIX_VIRTUALENV_COMMAND COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/fix-macos-virtualenv.sh ${VIRTUALENV_PATH}) + endif() + add_custom_command(OUTPUT ${VIRTUALENV_ACTIVATE} COMMAND ${CMAKE_COMMAND} -E make_directory ${VIRTUALENV_PATH} @@ -46,6 +55,8 @@ if(QT_FEATURE_python3_virtualenv AND NOT QT_FEATURE_system_qface) COMMAND ${CMAKE_COMMAND} -E chdir ${VIRTUALENV_PATH} ${Python3_EXECUTABLE} ${RELOCATE_VIRTUALENV} . COMMENT "Setting up virtualenv for qface, name: ${VIRTUALENV_NAME}" + + ${FIX_VIRTUALENV_COMMAND} ) # This is not very nice, but it gives us at least a good way to handle virtualenv rebuilding when diff --git a/src/tools/ifcodegen/fix-macos-virtualenv.sh b/src/tools/ifcodegen/fix-macos-virtualenv.sh new file mode 100755 index 00000000..6c59cc26 --- /dev/null +++ b/src/tools/ifcodegen/fix-macos-virtualenv.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +############################################################################# +## +## Copyright (C) 2021 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the QtInterfaceFramework module of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +SCRIPT=$(dirname $0) +usage() +{ + echo "fix-macos-virtualenv.sh <virtualenv>" + exit 1 +} + +[ "$#" -lt 1 ] && usage +VIRTUALENV="${@: -1}" +[ ! -d "$VIRTUALENV" ] && usage +[ ! -d "$VIRTUALENV/lib" ] && usage +VIRTUALENV_LIB=$VIRTUALENV/lib +for file in "$VIRTUALENV_LIB"/python* ; do + if [[ -d $file ]] ; then + LIB_FOLDER=$file + PYTHON_VERSION=$(basename "$file") + break + fi +done + +if [ "$(uname)" != "Darwin" ]; then + exit 1 +fi + +mkdir bk +cp $VIRTUALENV/bin/python bk +mv -f bk/python $VIRTUALENV/bin/python +rmdir bk +codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f $VIRTUALENV/bin/python +ln -sf python $VIRTUALENV/bin/python3 +ln -sf python $VIRTUALENV/bin/$PYTHON_VERSION |