Jelajahi Sumber

3P Package source for Pyside / Linux (#67)

Steve Pham 3 tahun lalu
induk
melakukan
2ee9b0011d

+ 0 - 9
package-system/Qt/build.sh

@@ -84,12 +84,3 @@ for qtlib in "${qtarray[@]}"; do
     echo $qtlib installed.
 done
 echo Qt installed successfully!
-
-if [[ "$OSTYPE" != "darwin"* ]]; then
-    VERSION=$($TARGET_INSTALL_ROOT/bin/qmake -query QT_VERSION)
-    # Strip libQt5Core for WSL compatibility
-    strip --remove-section=.note.ABI-tag $TARGET_INSTALL_ROOT/lib/libQt5Core.so.$VERSION
-    # Remove symlinks from the build dir, we regenerate them
-    find $TARGET_INSTALL_ROOT/lib -type l | xargs rm
-    echo Qt install post-processing complete!
-fi

+ 28 - 0
package-system/pyside2-qt/Findpyside2.cmake.Linux

@@ -0,0 +1,28 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+     
+# this file actually ingests the library and defines targets.
+     
+set(MY_NAME "pyside2")
+set(TARGET_WITH_NAMESPACE "3rdParty::${MY_NAME}")
+if (TARGET ${TARGET_WITH_NAMESPACE})
+    return()
+endif()
+     
+add_library(${TARGET_WITH_NAMESPACE} INTERFACE IMPORTED GLOBAL)
+     
+ly_pip_install_local_package_editable(${CMAKE_CURRENT_LIST_DIR}/pyside2 pyside2)
+
+set(pyside2_RUNTIME_DEPENDENCIES
+    ${PYSIDE_BASE_PATH}/PySide2/libpyside2.abi3.so.5.14
+    ${PYSIDE_BASE_PATH}/PySide2/libpyside2.abi3.so.5.14.2.3
+    ${PYSIDE_BASE_PATH}/shiboken2/shiboken2.abi3.so
+    ${PYSIDE_BASE_PATH}/shiboken2/libshiboken2.abi3.so.5.14
+    ${PYSIDE_BASE_PATH}/shiboken2/libshiboken2.abi3.so.5.14.2.3
+)
+     
+set(${MY_NAME}_FOUND True)

+ 0 - 0
package-system/pyside2-qt/__init__.py


+ 28 - 0
package-system/pyside2-qt/build_config.json

@@ -0,0 +1,28 @@
+{
+    "git_url": "https://code.qt.io/cgit/pyside/pyside-setup.git",
+    "git_tag": "v5.14.2.3",
+    "package_name": "pyside2",
+    "package_version": "5.15.2-rev1",
+    "package_url": "https://code.qt.io/cgit/pyside/pyside-setup.git",
+    "package_license": "custom",
+    "package_license_file": "pyside2/LICENSE.LGPLv3",
+    "patch_file": "pyside_o3de-v5.14.2.3.patch",
+    "cmake_find_target": "Findpyside2.cmake",
+    "Platforms": {
+        "Linux": {
+            "Linux": {
+                "depends_on_packages" :[ 
+                    ["python-3.7.10-rev2-linux", "6b9cf455e6190ec38836194f4454bb9db6bfc6890b4baff185cc5520aa822f05", ""],
+                    ["qt-5.15.2-rev6-linux", "a37bd9989f1e8fe57d94b98cbf9bd5c3caaea740e2f314e5162fa77300551531", ""]
+                ],
+                "cmake_find_source": "Findpyside2.cmake.Linux",
+                "custom_build_cmd": [
+                    "./build_linux.sh"
+                ],
+                "custom_install_cmd": [
+                    "./package_linux.sh"
+                ]
+            }
+        }
+    }
+}

+ 53 - 0
package-system/pyside2-qt/build_linux.sh

@@ -0,0 +1,53 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+
+# Get the python executable from the package dependency
+LOCAL_PYTHON37_BIN=$TEMP_FOLDER/python-3.7.10-rev2-linux/python/bin/python3
+
+SCRIPT_PATH=`dirname $0`
+
+
+if [ ! -f "$LOCAL_PYTHON37_BIN" ]
+then
+    echo "Missing 3P dependency of python3.7 $LOCAL_PYTHON37_BIN"
+    echo "You will need to build the 3P version of python under the '`readlink -f ../python`'' folder"
+    echo "with the following command:"
+    echo
+    echo "python3 build_package_image.py"
+    echo
+    exit 1
+fi
+
+# Get the qt package's qmake location
+LOCAL_3P_QTBUILD_PATH=$TEMP_FOLDER/qt-5.15.2-rev6-linux/qt
+LOCAL_3P_QTBUILD_QMAKE_PATH=`readlink -f $LOCAL_3P_QTBUILD_PATH/bin/qmake`
+LOCAL_3P_QTBUILD_LIB_PATH=`readlink -f $LOCAL_3P_QTBUILD_PATH/lib`
+if [ ! -f "$LOCAL_3P_QTBUILD_QMAKE_PATH" ]
+then
+    echo "Missing 3P dependency of Qt $LOCAL_3P_QTBUILD_PATH"
+    echo
+    exit 1
+fi
+
+
+# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script
+echo Building source
+pushd $TEMP_FOLDER/src
+
+LD_LIBRARY_PATH=$LOCAL_3P_QTBUILD_LIB_PATH/
+export LD_LIBRARY_PATH
+
+echo "$LOCAL_PYTHON37_BIN setup.py install --qmake=$LOCAL_3P_QTBUILD_QMAKE_PATH --build-type=all --limited-api=yes --skip-modules=Qml,Quick,Positioning,Location,RemoteObjects,Scxml,TextToSpeech,3DCore,3DRender,3DInput,3DLogic,3DAnimation,3DExtras,Multimedia,MultimediaWidgets,AxContainer"
+$LOCAL_PYTHON37_BIN setup.py install --qmake=$LOCAL_3P_QTBUILD_QMAKE_PATH --build-type=all --limited-api=yes --skip-modules=Qml,Quick,QuickWidgets,Positioning,Location,RemoteObjects,Scxml,TextToSpeech,3DCore,3DRender,3DInput,3DLogic,3DAnimation,3DExtras,Multimedia,MultimediaWidgets,AxContainer
+
+popd
+
+exit 0

+ 42 - 0
package-system/pyside2-qt/package_linux.sh

@@ -0,0 +1,42 @@
+#!/bin/bash
+
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script
+
+PACKAGE_BASE=$TARGET_INSTALL_ROOT
+
+INSTALL_SOURCE=$TEMP_FOLDER/src/pyside3a_install/`ls $TEMP_FOLDER/src/pyside3a_install`
+echo INSTALL_SOURCE=$INSTALL_SOURCE
+
+# Copy the LICENSE and README files
+cp $TEMP_FOLDER/src/LICENSE.* $PACKAGE_BASE/
+cp $TEMP_FOLDER/src/README.* $PACKAGE_BASE/
+
+# Copy the Pyside2 package, and create major version sylmink
+cp -r $INSTALL_SOURCE/lib/python3.7/site-packages/PySide2 $PACKAGE_BASE
+cp $INSTALL_SOURCE/lib/libpyside2.abi3.so.5.14.2.3 $PACKAGE_BASE/PySide2/
+ln -s libpyside2.abi3.so.5.14.2.3 $PACKAGE_BASE/PySide2/libpyside2.abi3.so.5.14
+
+# Copy the shiboken2 package, and create major version sylmink
+cp -r $INSTALL_SOURCE/lib/python3.7/site-packages/shiboken2 $PACKAGE_BASE
+cp $INSTALL_SOURCE/lib/libshiboken2.abi3.so.5.14.2.3 $PACKAGE_BASE/shiboken2/
+ln -s libshiboken2.abi3.so.5.14.2.3 $PACKAGE_BASE/shiboken2/libshiboken2.abi3.so.5.14
+
+# Patch the Pyside2 shared library to resolve shiboken2
+$TEMP_FOLDER/src/patchelf --set-rpath ../shiboken2:\$ORIGIN $PACKAGE_BASE/PySide2/libpyside2.abi3.so.5.14.2.3
+
+# Patch the shiboken2.abi.so module to resolve the libshiboken at ORIGIN
+$TEMP_FOLDER/src/patchelf --set-rpath \$ORIGIN $PACKAGE_BASE/shiboken2/shiboken2.abi3.so
+
+# Add additional files needed for pip install
+cp $TEMP_FOLDER/../__init__.py $PACKAGE_BASE/
+cp $TEMP_FOLDER/../setup.py $PACKAGE_BASE/
+
+exit 0

+ 224 - 0
package-system/pyside2-qt/pyside_o3de-v5.14.2.3.patch

@@ -0,0 +1,224 @@
+diff --git a/build_scripts/main.py b/build_scripts/main.py
+index cf56850df..0e1a0fa4b 100644
+--- a/build_scripts/main.py
++++ b/build_scripts/main.py
+@@ -544,6 +544,9 @@ class PysideBuild(_build):
+                 py_include_dir = os.path.join(py_prefix, "include")
+             else:
+                 py_include_dir = os.path.join(py_prefix, "include/python{}".format(py_version))
++                if not os.path.isdir(py_include_dir):
++                    py_include_dir = os.path.join(py_prefix, "include/python{}m".format(py_version))
++
+         dbg_postfix = ""
+         if build_type == "Debug":
+             dbg_postfix = "_d"
+diff --git a/sources/pyside2/libpyside/CMakeLists.txt b/sources/pyside2/libpyside/CMakeLists.txt
+index 7493a453a..f67196815 100644
+--- a/sources/pyside2/libpyside/CMakeLists.txt
++++ b/sources/pyside2/libpyside/CMakeLists.txt
+@@ -1,13 +1,5 @@
+ project(libpyside)
+ 
+-if(${Qt5Qml_FOUND})
+-    if(NOT "${Qt5Qml_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQml/")
+-        string(REPLACE "/QtCore" "/QtQml" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
+-        list(APPEND Qt5Qml_PRIVATE_INCLUDE_DIRS ${replaceme})
+-        list(REMOVE_DUPLICATES Qt5Qml_PRIVATE_INCLUDE_DIRS)
+-    endif()
+-endif()
+-
+ if(${Qt5Quick_FOUND})
+     if(NOT "${Qt5Quick_PRIVATE_INCLUDE_DIRS}" MATCHES "/QtQuick/")
+         string(REPLACE "/QtCore" "/QtQuick" replaceme "${Qt5Core_PRIVATE_INCLUDE_DIRS}")
+@@ -17,26 +9,11 @@ if(${Qt5Quick_FOUND})
+     endif()
+ endif()
+ 
++# Disable QML support
++set(QML_SUPPORT 0)
+ set(QML_PRIVATE_API_SUPPORT 0)
+-if(Qt5Qml_FOUND)
+-    # Used for registering custom QQuickItem classes defined in Python code.
+-    set(QML_SUPPORT 1)
+-    set(QML_INCLUDES ${Qt5Qml_INCLUDE_DIRS})
+-    set(QML_LIBRARIES ${Qt5Qml_LIBRARIES})
+-
+-    if(Qt5Qml_PRIVATE_INCLUDE_DIRS)
+-        # Used for transforming QML exceptions into Python exceptions.
+-        set(QML_PRIVATE_API_SUPPORT 1)
+-        set(QML_INCLUDES ${QML_INCLUDES} ${Qt5Qml_PRIVATE_INCLUDE_DIRS})
+-    else()
+-        message(WARNING "QML private API include files could not be found, support for catching QML exceptions inside Python code will not work.")
+-    endif()
+-else()
+-    set(QML_SUPPORT 0)
+-    set(QML_PRIVATE_API_SUPPORT 0)
+-    set(QML_INCLUDES "")
+-    set(QML_LIBRARIES "")
+-endif()
++set(QML_INCLUDES "")
++set(QML_LIBRARIES "")
+ 
+ qt5_wrap_cpp(DESTROYLISTENER_MOC "destroylistener.h")
+ 
+diff --git a/sources/pyside2/libpyside/pyside.cpp b/sources/pyside2/libpyside/pyside.cpp
+index e2b8708ce..0541c7d91 100644
+--- a/sources/pyside2/libpyside/pyside.cpp
++++ b/sources/pyside2/libpyside/pyside.cpp
+@@ -423,7 +423,7 @@ static const char invalidatePropertyName[] = "_PySideInvalidatePtr";
+ // class by walking up the meta objects.
+ static const char *typeName(QObject *cppSelf)
+ {
+-    const char *typeName = typeid(*cppSelf).name();
++    const char *typeName = getTypeId(*cppSelf).name();
+     if (!Shiboken::Conversions::getConverter(typeName)) {
+         for (auto metaObject = cppSelf->metaObject(); metaObject; metaObject = metaObject->superClass()) {
+             const char *name = metaObject->className();
+@@ -459,7 +459,6 @@ PyObject *getWrapperForQObject(QObject *cppSelf, SbkObjectType *sbk_type)
+     }
+ 
+     pyOut = Shiboken::Object::newObject(sbk_type, cppSelf, false, false, typeName(cppSelf));
+-
+     return pyOut;
+ }
+ 
+diff --git a/sources/pyside2/libpyside/pyside.h b/sources/pyside2/libpyside/pyside.h
+index ae400e1fe..b7412594b 100644
+--- a/sources/pyside2/libpyside/pyside.h
++++ b/sources/pyside2/libpyside/pyside.h
+@@ -50,12 +50,57 @@
+ 
+ #include <QtCore/QMetaType>
+ #include <QtCore/QHash>
++#include <QtCore/QMetaObject>
++#include <QtCore/QObject>
++
++#include <type_traits>
++#include <typeinfo>
+ 
+ struct SbkObjectType;
+ 
+ namespace PySide
+ {
+ 
++// Analog for std::type_info with the name field, to allow getTypeId to be used in lieu of typeid
++class TypeInfo
++{
++private:
++    const char* m_name = nullptr;
++
++public:
++    explicit TypeInfo(const char* name) : m_name(name) {}
++    const char* name() const { return m_name; }
++};
++
++// getTypeId returns an interface similar to the std::type_info returned by typeid, but will attempt to use
++// Qt's meta-object system for QObject subclasses instead - this allows Shiboken to interop with libraries that
++// are built without RTTI
++template <class T>
++const TypeInfo getTypeId(typename std::enable_if<std::is_base_of<QObject, T>::value>::type* = 0)
++{
++    const char* typeName = T::staticMetaObject.className();
++    return TypeInfo(typeName);
++}
++
++template <class T>
++const TypeInfo getTypeId(typename std::enable_if<!std::is_base_of<QObject, T>::value>::type* = 0)
++{
++    return TypeInfo(typeid(T).name());
++}
++
++template <class T>
++const TypeInfo getTypeId(const T& t, typename std::enable_if<std::is_base_of<QObject, T>::value>::type* = 0)
++{
++    const char* typeName = t.metaObject() ? t.metaObject()->className() : T::staticMetaObject.className();
++    return TypeInfo(typeName);
++}
++
++template <class T>
++const TypeInfo getTypeId(const T& t, typename std::enable_if<!std::is_base_of<QObject, T>::value>::type* = 0)
++{
++    return TypeInfo(typeid(t).name());
++}
++
+ PYSIDE_API void init(PyObject *module);
+ 
+ /**
+diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt
+index c1349cae6..5e6071bb7 100644
+--- a/sources/shiboken2/CMakeLists.txt
++++ b/sources/shiboken2/CMakeLists.txt
+@@ -76,7 +76,7 @@ if (NOT PYTHON_EXTENSION_SUFFIX)
+   get_python_extension_suffix()
+ endif()
+ 
+-option(FORCE_LIMITED_API "Enable the limited API." "yes")
++option(FORCE_LIMITED_API "Enable the limited API." ON)
+ set(PYTHON_LIMITED_API 0)
+ 
+ shiboken_check_if_limited_api()
+diff --git a/sources/shiboken2/data/shiboken_helpers.cmake b/sources/shiboken2/data/shiboken_helpers.cmake
+index 6bd75d0ea..316b52f05 100644
+--- a/sources/shiboken2/data/shiboken_helpers.cmake
++++ b/sources/shiboken2/data/shiboken_helpers.cmake
+@@ -298,7 +298,7 @@ macro(shiboken_check_if_limited_api)
+         OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
+         OUTPUT_STRIP_TRAILING_WHITESPACE)
+ 
+-    if(FORCE_LIMITED_API STREQUAL "yes")
++    if(FORCE_LIMITED_API)
+         if (${PYTHON_VERSION_MAJOR} EQUAL 3 AND ${PYTHON_VERSION_MINOR} GREATER 4)
+             # GREATER_EQUAL is available only from cmake 3.7 on. We mean python 3.5 .
+             set(PYTHON_LIMITED_API 1)
+diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+index 64467e3d1..e729c49ea 100644
+--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
++++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+@@ -58,7 +58,11 @@ static const char typeNameFunc[] = R"CPP(
+ template <class T>
+ static const char *typeNameOf(const T &t)
+ {
++#ifdef PYSIDE_H
++    const char *typeName =  PySide::getTypeId<T>(t).name();
++#else
+     const char *typeName =  typeid(t).name();
++#endif //PYSIDE_H
+     auto size = std::strlen(typeName);
+ #if defined(Q_CC_MSVC) // MSVC: "class QPaintDevice * __ptr64"
+     if (auto lastStar = strchr(typeName, '*')) {
+@@ -1522,18 +1526,31 @@ void CppGenerator::writeConverterRegister(QTextStream &s, const AbstractMetaClas
+         cppSignature.removeFirst();
+     }
+ 
+-    s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::";
++    if (usePySideExtensions() && metaClass->isQObject()) {
++        s << INDENT << "Shiboken::Conversions::registerConverterName(converter, PySide::getTypeId<::";
++    } else {
++        s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::";
++    }
+     QString qualifiedCppNameInvocation;
+     if (!classContext.forSmartPointer())
+         qualifiedCppNameInvocation = metaClass->qualifiedCppName();
+     else
+         qualifiedCppNameInvocation = classContext.preciseType()->cppSignature();
+ 
+-    s << qualifiedCppNameInvocation << ").name());\n";
++    if (usePySideExtensions() && metaClass->isQObject()) {
++        s << qualifiedCppNameInvocation << ">().name());\n";
++    } else {
++        s << qualifiedCppNameInvocation << ").name());\n";
++    }
+ 
+     if (shouldGenerateCppWrapper(metaClass)) {
+-        s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::";
+-        s << wrapperName(metaClass) << ").name());\n";
++        if (usePySideExtensions() && metaClass->isQObject()) {
++            s << INDENT << "Shiboken::Conversions::registerConverterName(converter, PySide::getTypeId<::";
++            s << wrapperName(metaClass) << ">().name());\n";
++        } else {
++            s << INDENT << "Shiboken::Conversions::registerConverterName(converter, typeid(::";
++            s << wrapperName(metaClass) << ").name());\n";
++        }
+     }
+ 
+     s << endl;

+ 41 - 0
package-system/pyside2-qt/setup.py

@@ -0,0 +1,41 @@
+#
+# Copyright (c) Contributors to the Open 3D Engine Project.
+# For complete copyright and license terms please see the LICENSE at the root of this distribution.
+# 
+# SPDX-License-Identifier: Apache-2.0 OR MIT
+#
+#
+
+import os
+import platform
+
+from setuptools import setup, find_packages
+from setuptools.command.develop import develop
+from setuptools.command.build_py import build_py
+
+PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
+
+PYTHON_64 = platform.architecture()[0] == '64bit'
+
+
+if __name__ == '__main__':
+    if not PYTHON_64:
+        raise RuntimeError("32-bit Python is not a supported platform.")
+
+    with open(os.path.join(PROJECT_ROOT, 'README.md')) as f:
+        long_description = f.read()
+
+    setup(
+        name="pyside2",
+        version="5.12.4.2.3",
+        description='Pyside2',
+        long_description=long_description,
+        packages=['PySide2', 'shiboken2'],
+        install_requires=[
+        ],
+        tests_require=[
+        ],
+        entry_points={
+        },
+    )
+

+ 2 - 0
package_build_list_host_linux.json

@@ -16,6 +16,7 @@
         "mcpp-2.7.2_az.1-rev1-linux": "package-system/mcpp/get_and_build_mcpp.py mcpp-2.7.2_az.1-rev1",
         "OpenMesh-8.1-rev3-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenMesh --platform-name Linux --package-root ../../package-system --clean",
         "OpenSSL-1.1.1b-rev2-linux": "package-system/OpenSSL/build_package_image.py",
+        "pyside2-5.15.2-rev1-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/pyside2-qt --platform-name Linux --package-root ../../package-system --clean",
         "ilmbase-2.3.0-rev4-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/OpenEXR --platform-name Linux --package-root ../../package-system --clean",
         "PhysX-4.1.2.29882248-rev4-linux": "package-system/PhysX/build_package_image.py --platform-name linux",
         "NvCloth-v1.1.6-4-gd243404-pr58-rev1-linux": "package-system/NvCloth/build_package_image.py --platform-name linux",
@@ -47,6 +48,7 @@
         "mcpp-2.7.2_az.1-rev1-linux": "package-system/mcpp-linux",
         "OpenMesh-8.1-rev3-linux": "package-system/OpenMesh-linux",
         "OpenSSL-1.1.1b-rev2-linux": "package-system/OpenSSL-linux",
+        "pyside2-5.15.2-rev1-linux": "package-system/pyside2-linux",
         "ilmbase-2.3.0-rev4-linux": "package-system/ilmbase-linux",
         "SPIRVCross-2021.04.29-rev1-linux": "package-system/SPIRVCross-linux",
         "squish-ccr-deb557d-rev1-linux": "package-system/squish-ccr-linux",