Skip to content

Commit

Permalink
Add patches for PySide6
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso committed Jan 11, 2025
1 parent ca8d3b9 commit 7924a55
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/rez_pip/data/patches/pyside6_6_0_0_win_dll_path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- python/PySide6/__init__.py 2025-01-11 15:01:54.266726602 -0500
+++ python/PySide6/__init__.py 2025-01-11 15:06:19.646365323 -0500
@@ -10,14 +10,9 @@


def _additional_dll_directories(package_dir):
- # Find shiboken6 relative to the package directory.
- root = os.path.dirname(package_dir)
- # Check for a flat .zip as deployed by cx_free(PYSIDE-1257)
- if root.endswith('.zip'):
- return []
- shiboken6 = os.path.join(root, 'shiboken6')
- if os.path.isdir(shiboken6): # Standard case, only shiboken6 is needed
- return [shiboken6]
+ # rez-pip patch: Return the path to the shiboken rez package
+ return [os.path.join(os.environ["REZ_SHIBOKEN6_ROOT"], "python", "shiboken6")]
+
# The below code is for the build process when generate_pyi.py
# is executed in the build directory. We need libpyside and Qt in addition.
shiboken6 = os.path.join(os.path.dirname(root), 'shiboken6', 'libshiboken')
20 changes: 20 additions & 0 deletions src/rez_pip/data/patches/pyside6_6_1_0_win_dll_path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- python/PySide6/__init__.py 2025-01-11 14:43:26.190668073 -0500
+++ python/PySide6/__init__.py 2025-01-11 15:09:43.741718533 -0500
@@ -11,14 +11,9 @@


def _additional_dll_directories(package_dir):
- # Find shiboken6 relative to the package directory.
- root = Path(package_dir).parent
- # Check for a flat .zip as deployed by cx_free(PYSIDE-1257)
- if root.suffix == '.zip':
- return []
- shiboken6 = root / 'shiboken6'
- if shiboken6.is_dir(): # Standard case, only shiboken6 is needed
- return [shiboken6]
+ # rez-pip patch: Return the path to the shiboken rez package
+ return [os.path.join(os.environ["REZ_SHIBOKEN6_ROOT"], "python", "shiboken6")]
+
# The below code is for the build process when generate_pyi.py
# is executed in the build directory. We need libpyside and Qt in addition.
shiboken6 = Path(root).parent / 'shiboken6' / 'libshiboken'
20 changes: 20 additions & 0 deletions src/rez_pip/data/patches/pyside6_6_2_4_win_dll_path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- python/PySide6/__init__.py 2025-01-11 14:43:29.390687962 -0500
+++ python/PySide6/__init__.py 2025-01-11 15:11:41.569480197 -0500
@@ -11,14 +11,9 @@


def _additional_dll_directories(package_dir):
- # Find shiboken6 relative to the package directory.
- root = Path(package_dir).parent
- # Check for a flat .zip as deployed by cx_free(PYSIDE-1257)
- if root.suffix == '.zip':
- return []
- shiboken6 = root / 'shiboken6'
- if shiboken6.is_dir(): # Standard case, only shiboken6 is needed
- return [shiboken6]
+ # rez-pip patch: Return the path to the shiboken rez package
+ return [os.path.join(os.environ["REZ_SHIBOKEN6_ROOT"], "python", "shiboken6")]
+
# The below code is for the build process when generate_pyi.py
# is executed in the build directory. We need libpyside and Qt in addition.
shiboken6 = Path(root).parent / 'shiboken6' / 'libshiboken'
20 changes: 20 additions & 0 deletions src/rez_pip/data/patches/pyside6_6_3_0_win_dll_path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- python/PySide6/__init__.py 2025-01-11 14:43:29.554022310 -0500
+++ python/PySide6/__init__.py 2025-01-11 15:13:40.307210955 -0500
@@ -12,14 +12,9 @@


def _additional_dll_directories(package_dir):
- # Find shiboken6 relative to the package directory.
- root = Path(package_dir).parent
- # Check for a flat .zip as deployed by cx_free(PYSIDE-1257)
- if root.suffix == '.zip':
- return []
- shiboken6 = root / 'shiboken6'
- if shiboken6.is_dir(): # Standard case, only shiboken6 is needed
- return [shiboken6]
+ # rez-pip patch: Return the path to the shiboken rez package
+ return [os.path.join(os.environ["REZ_SHIBOKEN6_ROOT"], "python", "shiboken6")]
+
# The below code is for the build process when generate_pyi.py
# is executed in the build directory. We need libpyside and Qt in addition.
shiboken6 = Path(root).parent / 'shiboken6' / 'libshiboken'
52 changes: 52 additions & 0 deletions src/rez_pip/plugins/PySide6.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
import shutil
import typing
import logging
import platform

import packaging.utils
import packaging.version
import packaging.specifiers
import packaging.requirements

import rez_pip.pip
import rez_pip.patch
import rez_pip.plugins
import rez_pip.exceptions

Expand Down Expand Up @@ -99,6 +101,56 @@ def groupPackages(
return [rez_pip.pip.PackageGroup[rez_pip.pip.PackageInfo](tuple(data))]


@rez_pip.plugins.hookimpl
def patches(dist: "importlib_metadata.Distribution", path: str) -> typing.List[str]:
if dist.name != "PySide6" or platform.system() != "Windows":
return []

patches: typing.List[str] = []

# To generate the patches:
# 1. run srcipts/get_pyside6_files.py
# 2. Look at the output and get the different diffs.
# 3. Generate a patch for each version range where there is a diff:
# 3.1 cp patches/data/6.3.0/__init__.py patches/data/6.3.0/__init__.py.new
# 3.2 vim patches/data/6.3.0/__init__.py.new
# 3.3 diff --unified patches/data/6.3.0/__init__.py patches/data/6.3.0/__init__.py.new > src/rez_pip/data/patches/pyside6_6_3_0_win_dll_path.patch
# 3.4 Edit src/rez_pip/data/patches/pyside6_6_3_0_win_dll_path.patch to make sure the paths
# are good in the patch header. Also make sure CRLF (line ending) is kept as-is.
#
# I think that it's important that the paths in the look like "python/PySide6/..."
# so that it matches the file layout...
version = packaging.version.Version(dist.version)
if version in packaging.specifiers.SpecifierSet(">=6.0.0,<6.1.0"):
patches.append(
os.path.join(
rez_pip.patch.getBuiltinPatchesDir(), "pyside6_6_0_0_win_dll_path.patch"
)
)

elif version in packaging.specifiers.SpecifierSet(">=6.1.0,<6.2.4"):
patches.append(
os.path.join(
rez_pip.patch.getBuiltinPatchesDir(), "pyside6_6_1_0_win_dll_path.patch"
)
)

elif version in packaging.specifiers.SpecifierSet(">=6.2.4,<6.3.0"):
patches.append(
os.path.join(
rez_pip.patch.getBuiltinPatchesDir(), "pyside6_6_2_4_win_dll_path.patch"
)
)

elif version in packaging.specifiers.SpecifierSet(">=6.3.0"):
patches.append(
os.path.join(
rez_pip.patch.getBuiltinPatchesDir(), "pyside6_6_3_0_win_dll_path.patch"
)
)
return patches


@rez_pip.plugins.hookimpl
def cleanup(dist: "importlib_metadata.Distribution", path: str) -> None:
if packaging.utils.canonicalize_name(dist.name) not in [
Expand Down

0 comments on commit 7924a55

Please sign in to comment.