From a41cd79282a486ac67d4d58a4f6235908b68ecca Mon Sep 17 00:00:00 2001 From: Stephane Deverly Date: Thu, 25 Apr 2024 14:32:02 +0200 Subject: [PATCH 1/2] For #13673, PySide6 and Python 3.11 --- azure-pipelines.yml | 25 +++++++++++-------------- framework.py | 15 ++++++++------- resources/build_packages.sh | 17 ++++++++++++----- resources/requirements.txt | 2 +- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 705f58a..e9e510d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,18 +24,18 @@ jobs: strategy: matrix: # Define all the platform/python version we need - MacPython37: + MacPython311: platform: 'osx' # Short name for us - imageName: 'macOS-10.15' - python.version: '3.7' - WinPython37: + imageName: 'macOS-latest' + python.version: '3.11' + WinPython311: platform: 'win' # Short name for us - imageName: 'windows-2019' - python.version: '3.7' - LinuxPython37: + imageName: 'windows-latest' + python.version: '3.11' + LinuxPython311: platform: 'linux' # Short name for us imageName: 'ubuntu-latest' - python.version: '3.7' + python.version: '3.11' maxParallel: 1 pool: @@ -84,12 +84,9 @@ jobs: inputs: Contents: | .git - resources/packagevenv_osx_2 - resources/packagevenv_osx_3 - resources/packagevenv_windows_2 - resources/packagevenv_windows_3 - resources/packagevenv_linux_2 - resources/packagevenv_linux_3 + resources/packagevenv_osx_3.11 + resources/packagevenv_windows_3.11 + resources/packagevenv_linux_3.11 # Archive files # Compress files into .7z, .tar.gz, or .zip diff --git a/framework.py b/framework.py index 2bb37cd..2cfe375 100644 --- a/framework.py +++ b/framework.py @@ -3,9 +3,9 @@ # file included in this repository. """ -Framework containing PySide2 distributions for the Unreal engine +Framework containing PySide distributions for the Unreal engine -Because Unreal does not include PySide2/Qt distributions but does use its own +Because Unreal does not include PySide/Qt distributions but does use its own version of Python, we have to distribute full versions for the engine to function. """ @@ -31,15 +31,15 @@ def init_framework(self): Something similar to what `virtualenv` does is done when this framework is loaded by SG TK. """ - self.log_debug("%s: Initializing UnrealQtFramework..." % self) + self.logger.debug("%s: Initializing UnrealQtFramework..." % self) # Check if PySide is already available, do nothing if it is the case try: from sgtk.platform.qt import QtCore # noqa - self.log_debug("Qt is already available, not activating any custom package.") + self.logger.debug("Qt is already available, not activating any custom package.") return except ImportError as e: - self.log_debug("Qt is not available: %s, activating custom package." % e) + self.logger.debug("Qt is not available: %s, activating custom package." % e) pass # Remap the platform name to our names pname = self.platform_name() @@ -53,13 +53,14 @@ def init_framework(self): # Copied over from activate_this.py script which does not exist anymore # from Python 3. python_major = sys.version_info[0] # 2 or 3 + python_minor = sys.version_info[1] # 6, 7, 8, etc base_path = os.path.realpath( os.path.join( os.path.dirname(__file__), "python", "vendors", - "py%d" % python_major, + "py%d.%d" % (python_major, python_minor), pname, ) ) @@ -108,7 +109,7 @@ def init_framework(self): sys.prefix = base_path def destroy_framework(self): - self.log_debug("%s: Destroying UnrealQtFramework..." % self) + self.logger.debug("%s: Destroying UnrealQtFramework..." % self) @classmethod def platform_name(cls): diff --git a/resources/build_packages.sh b/resources/build_packages.sh index ae375b5..b8401ee 100755 --- a/resources/build_packages.sh +++ b/resources/build_packages.sh @@ -133,15 +133,22 @@ echo "Detecting Python version..." python_version=$($python_cmd --version 2>&1) # 2 or 3 python_major_version=${python_version:7:1} -if [ -z $python_major_version ]; +# 2 or 3 +python_major_version=${python_version:7:1} +# Remove patch number from Python 3.9.17 +no_patch=${python_version%\.*} +# 3.9 +python_major_minor=${no_patch:7} + +if [ -z $python_major_version ] || [ -z $python_major_minor ]; then echo "Unable to detect python version, aborting" exit 1 fi -echo "Detected python version ${python_major_version} from ${python_version}" +echo "Detected python version ${python_major_version} from ${python_version} (${python_major_minor})" -packagevenv="packagevenv_${platform_name}_${python_major_version}" +packagevenv="packagevenv_${platform_name}_${python_major_minor}" if [ ! -d $packagevenv ]; then if [ ${python_major_version} == 2 ]; then @@ -200,8 +207,8 @@ if [ $do_build == 1 ]; then fi # Copy packages to their shipping destination if [ -d ./${packagevenv} ]; then - mkdir -p ../python/vendors/py${python_major_version} - target="../python/vendors/py${python_major_version}/${platform_name}" + mkdir -p ../python/vendors/py${python_major_minor} + target="../python/vendors/py${python_major_minor}/${platform_name}" if [ -d $target ]; then echo "Deleting previous build in $target" # Clean up git but don't fail if there is nothing matching diff --git a/resources/requirements.txt b/resources/requirements.txt index 1d47abb..9151b9e 100644 --- a/resources/requirements.txt +++ b/resources/requirements.txt @@ -1,3 +1,3 @@ ## The following requirements were added by pip --freeze: -PySide2==5.15.2 +PySide6==6.7.0 From bcc916bd192165834eb6ee3ee11beec74b6c5fe1 Mon Sep 17 00:00:00 2001 From: Stephane Deverly Date: Thu, 25 Apr 2024 16:44:58 +0200 Subject: [PATCH 2/2] For #13673, fix for Python 3.11 --- framework.py | 2 +- hooks/core/bootstrap.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework.py b/framework.py index 2cfe375..fbdf42d 100644 --- a/framework.py +++ b/framework.py @@ -75,7 +75,7 @@ def init_framework(self): "lib" ) ) - python_pattern = r"^python%d\.\d$" % python_major + python_pattern = r"^python%d\.\d+$" % python_major for folder in lib_folders: if re.match(python_pattern, folder): break diff --git a/hooks/core/bootstrap.py b/hooks/core/bootstrap.py index 98640e6..e3d8ea4 100644 --- a/hooks/core/bootstrap.py +++ b/hooks/core/bootstrap.py @@ -138,7 +138,7 @@ def populate_bundle_cache_entry(self, destination, descriptor, **kwargs): for asset in response_d["assets"]: name = asset["name"] m = re.match( - r"%s-py\d.\d-%s.zip" % (version, pname), + r"%s-py\d.\d+-%s.zip" % (version, pname), name ) if m: