From ab16e42e85ff1bf03aeeee5aef5bc2f75e19875d Mon Sep 17 00:00:00 2001 From: Julien Langlois Date: Wed, 1 Apr 2026 16:02:55 -0700 Subject: [PATCH] SG-42871 Update Qt/PySide license attribution to LGPL with runtime detection Replace hardcoded PySide2/PySide6 version strings in the Licenses dialog with a dynamically generated LGPL attribution block that detects the actually installed PySide version at runtime. Changes: - licenses.py: add get_pyside_license_html() classmethod that imports PySide at runtime and fills the LBP-approved Qt LGPL wording with the real version. Add get_license_html() classmethod that combines the static base HTML with the dynamic attribution. __init__ now calls get_license_html() instead of reading the file directly. Both classmethods are intentionally overridable to allow tk-framework-desktopstartup to inject the correct version on older tk-desktop builds (see SG-42871 compatibility shim in desktopstartup). - licenses.html: remove the three hardcoded PySide2/PySide6 sections (v5.15.0, v6.2.1, v6.5.3). These are now generated dynamically. --- python/tk_desktop/licenses.html | 123 -------------------------------- python/tk_desktop/licenses.py | 80 ++++++++++++++++++++- 2 files changed, 79 insertions(+), 124 deletions(-) diff --git a/python/tk_desktop/licenses.html b/python/tk_desktop/licenses.html index 4456886b..bea281a8 100644 --- a/python/tk_desktop/licenses.html +++ b/python/tk_desktop/licenses.html @@ -980,129 +980,6 @@ - -
-

PySide2 v.5.15.0

-
-Portions related to pySide Copyright (C) 2020The Qt Company.  This Autodesk
-software contains PySide2 v.5.15.0.  pySide is licensed under the GNU Lesser
-General Public License v.3, which can be found at
-https://www.gnu.org/licenses/lgpl-3.0.html. A text copy of this license is
-included with the download of this Autodesk software. You may obtain a copy of
-the source code for PySide2 v. 5.15.0 from www.autodesk.com/lgplsource  or by
-sending a written request to:
-
-    Autodesk, Inc.
-    Attention:  General Counsel
-    Legal Department
-    The Landmark @ One Market
-    Suite 400
-    San Francisco, CA 94105
-
-Your written request must:
-
-1. Contain a self-addressed CD/DVD mailer (or envelope sufficiently large to
-   hold a DVD) with postage sufficient to cover the amount of the current U.S.
-   Post Office First Class postage rate for CD/DVD mailers (or the envelope you
-   have chosen) weighing  5 ounces from San Francisco, California USA to your
-   indicated address; and
-
-2. Identify:
-    a. This Autodesk software name and release number;
-    b. That you are requesting the source code for PySide2 v. 5.15.0 and;
-    c. The above URL (www.autodesk.com/lgplsource )so that Autodesk may
-       properly respond to your request.  The offer to receive this pySide
-       source code via the above URL (www.autodesk.com/lgplsource ) or by
-       written request to Autodesk is valid for a period of three (3) years
-       from the date you purchased your license to this Autodesk software.
-
-You may modify, debug and relink PySide to this Autodesk software as provided
-under the terms of the GNU Lesser General Public License v.3.
-    
-
- - -
-

PySide6 v6.2.1

-
-Portions related to pySide6 v6.2.1 are Copyright (C) 2020The Qt Company.  This
-Autodesk software contains pySide6 v6.2.1.  pySide6 v6.2.1  is licensed under
-the GNU Lesser General Public License v.3, which can be found at
-https://www.gnu.org/licenses/lgpl-3.0.html.   A text copy of this license is
-included with the download of this Autodesk software.  You may obtain a copy of
-the source code for pySide6 v6.2.1 from www.autodesk.com/lgplsource  or by
-sending a written request to:
-
-    Autodesk, Inc.
-    Attention:  General Counsel
-    Legal Department
-    The Landmark @ One Market
-    Suite 400
-    San Francisco, CA 94105
-
-Your written request must:
-
-1. Contain a self-addressed CD/DVD mailer (or envelope sufficiently large to
-   hold a DVD) with postage sufficient to cover the amount of the current U.S.
-   Post Office First Class postage rate for CD/DVD mailers (or the envelope you
-   have chosen) weighing  5 ounces from San Francisco, California USA to your
-   indicated address; and
-
-2. Identify:
-    a. This Autodesk software name and release number;
-    b. That you are requesting the source code for pySide6 v6.2.1 and;
-    c. The above URL (www.autodesk.com/lgplsource )so that Autodesk may
-       properly respond to your request.  The offer to receive this pySide
-       source code via the above URL (www.autodesk.com/lgplsource ) or by
-       written request to Autodesk is valid for a period of three (3) years
-       from the date you purchased your license to this Autodesk software.
-
-You may modify, debug and relink PySide to this Autodesk software as provided
-under the terms of the GNU Lesser General Public License v.3.
-    
-
- - -
-

PySide6 v6.5.3

-
-Portions related to pySide6 v6.5.3 are Copyright (C) 2020The Qt Company.  This
-Autodesk software contains pySide6 v6.5.3.  pySide6 v6.5.3  is licensed under
-the GNU Lesser General Public License v.3, which can be found at
-https://www.gnu.org/licenses/lgpl-3.0.html.   A text copy of this license is
-included with the download of this Autodesk software.  You may obtain a copy of
-the source code for pySide6 v6.5.3 from www.autodesk.com/lgplsource  or by
-sending a written request to:
-
-    Autodesk, Inc.
-    Attention:  General Counsel
-    Legal Department
-    The Landmark @ One Market
-    Suite 400
-    San Francisco, CA 94105
-
-Your written request must:
-
-1. Contain a self-addressed CD/DVD mailer (or envelope sufficiently large to
-   hold a DVD) with postage sufficient to cover the amount of the current U.S.
-   Post Office First Class postage rate for CD/DVD mailers (or the envelope you
-   have chosen) weighing  5 ounces from San Francisco, California USA to your
-   indicated address; and
-
-2. Identify:
-    a. This Autodesk software name and release number;
-    b. That you are requesting the source code for pySide6 v6.5.3 and;
-    c. The above URL (www.autodesk.com/lgplsource )so that Autodesk may
-       properly respond to your request.  The offer to receive this pySide
-       source code via the above URL (www.autodesk.com/lgplsource ) or by
-       written request to Autodesk is valid for a period of three (3) years
-       from the date you purchased your license to this Autodesk software.
-
-You may modify, debug and relink PySide to this Autodesk software as provided
-under the terms of the GNU Lesser General Public License v.3.
-    
-
-

python-api v3.6.2

diff --git a/python/tk_desktop/licenses.py b/python/tk_desktop/licenses.py index a20977e6..9a3c86ea 100644 --- a/python/tk_desktop/licenses.py +++ b/python/tk_desktop/licenses.py @@ -8,6 +8,7 @@ # agreement to the Shotgun Pipeline Toolkit Source Code License. All rights # not expressly granted therein are reserved by Shotgun Software Inc. +import logging import os from sgtk.platform.qt import QtGui @@ -16,6 +17,33 @@ LICENSE_LOCATION = os.path.join(os.path.dirname(__file__), "licenses.html") +_logger = logging.getLogger(__name__) + +# LBP-approved Qt LGPL attribution template. +# Version placeholders are filled at runtime by get_pyside_license_html(). +_PYSIDE_LGPL_TEMPLATE = """\ + +
+

Qt v. {qt_version} / PySide {pyside_version}

+
+The Qt Toolkit is Copyright (C) 2022 The Qt Company Ltd. and other
+contributors. This Autodesk software contains Qt v. {qt_version}, as modified
+by Autodesk. Qt is licensed under the GNU Lesser General Public License v.3,
+which can be found at https://www.gnu.org/licenses/lgpl-3.0.html. You may
+obtain a copy of the license and source code for Qt v. {qt_version}, as
+modified by Autodesk, from
+https://github.com/autodesk-forks/qt5/tree/adsk-v{qt_version} or by sending
+a written request to:
+
+    Autodesk, Inc.
+    Attention: General Counsel
+    Legal Department
+    The Landmark at One Market Street, Suite 400
+    San Francisco, CA 94105
+    
+
+""" + class Licenses(QtGui.QDialog): """Simple about dialog""" @@ -27,5 +55,55 @@ def __init__(self, parent=None): self.ui = licenses.Ui_Licenses() self.ui.setupUi(self) # setSource seems broken on Qt4, so use setHtml instead. + self.ui.licenseText.setHtml(self.get_license_html()) + + @classmethod + def get_pyside_license_html(cls): + """Return the Qt/PySide LGPL attribution HTML with runtime version detection. + + Detects the installed PySide version so the wording is always accurate + regardless of which SGD and tk-desktop versions are running together. + + This method is intentionally designed to be overridable. External code + (e.g. tk-framework-desktopstartup) may replace it on old tk-desktop + builds to inject the correct version when needed. + + :returns: HTML string with the Qt/PySide LGPL attribution. + :rtype: str + """ + try: + import PySide6 + import PySide6.QtCore + + pyside_version = PySide6.__version__ + qt_version = PySide6.QtCore.__version__ + except ImportError: + try: + import PySide2 + import PySide2.QtCore + + pyside_version = PySide2.__version__ + qt_version = PySide2.QtCore.__version__ + except ImportError: + _logger.debug( + "Could not detect PySide version for license attribution." + ) + pyside_version = "unknown" + qt_version = "unknown" + + return _PYSIDE_LGPL_TEMPLATE.format( + pyside_version=pyside_version, + qt_version=qt_version, + ) + + @classmethod + def get_license_html(cls): + """Return the full license HTML, combining the static file with the + dynamic Qt/PySide attribution. + + :returns: Full HTML string for the Licenses dialog. + :rtype: str + """ with open(LICENSE_LOCATION, encoding="utf-8") as f: - self.ui.licenseText.setHtml(f.read()) + base_html = f.read() + return base_html + cls.get_pyside_license_html()