Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

switch PyQt5 for PySide2 #1744

Merged
merged 56 commits into from
Oct 18, 2021
Merged

switch PyQt5 for PySide2 #1744

merged 56 commits into from
Oct 18, 2021

Conversation

antirotor
Copy link
Member

@antirotor antirotor commented Jun 22, 2021

This PR is switching PyQt5 for PySide2. It is removing it from pyproject.toml so it is no longer managed by poetry (poetry doesn't support installing to custom locations yet (python-poetry/poetry#1937)). PySide2 and its dependencies (shiboken2) are installed to /vendor/python by ./tools/fetch_thirdparty_libs.ps1|sh. You can add this directory to sys.path using following piece of code before importing Qt.py:

import os
import site
from pathlib import Path
site.addsitedir(Path(os.getenv("OPENPYPE_ROOT")) / "vendor/python")

Steps to make the switch:

  1. delete .venv
  2. run ./tools/create_env.ps1|sh
  3. run ./tools/fetch_thirdparty_libs.ps1|sh

Instead of 1) and 2) you can manually delete PyQt5 stuff from .venv

Close #1676

Tested in hosts:

  • Nuke
    • Windows
    • Linux
    • MacOs
  • Hiero
    • Windows
    • Linux
    • MacOs
  • Photoshop/Aftereffects
    • Windows
    • MacOs
  • Tvpaint
    • Windows
  • Harmony
    • Windows
    • MacOs
  • Blender
    • Windows
    • Linux
    • MacOs
  • Maya
    • Windows
    • Linux
    • MacOs

[cuID:yjx9ec]

@iLLiCiTiT
Copy link
Member

Modifications made:

  • modules are not installed to subfolder PySide2 but are install directly to /vendor/python
  • this directory is prepended to sys.path in start.py so it is added all the time when openpype is launched
  • removed get_pyside2_location
    • there is no usage of it after openpype lib import as it already must be in sys.path at the time
  • fixed few smaller issues with PyQt5 and PySide2 compatibilities
    • in PySide2 value of popupMenu property is not integer but enum object which breaks stylesheet properties
    • signal/slot receivers work in different way

Global note

  • this change requires new installation of OpenPype on client side to take effect but should not affect already existing builds

@antirotor
Copy link
Member Author

PySide2 version is now specified in pyproject.toml in openpype section. For version resolution, it uses pip version resolution format (not Poetry) as it is installed via pip.

https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers

@antirotor antirotor marked this pull request as ready for review June 23, 2021 13:02
@antirotor antirotor requested a review from a team June 23, 2021 13:03
@64qam
Copy link
Member

64qam commented Jun 29, 2021

When building on linux:

image

@antirotor
Copy link
Member Author

When building on linux:

this seems to be bug in patchelf tool: NixOS/patchelf#230

Solved, but not released (and I doubt it will ever be on centos 7). Another tool we need to build from sources.

@iLLiCiTiT
Copy link
Member

Another tool we need to build from sources.

Is it bug related to PySide2? Or we just find that out with this PR?

@iLLiCiTiT
Copy link
Member

TODO Note: Check centos yum install requirements... (I've added more than needed)

@antirotor antirotor marked this pull request as ready for review October 7, 2021 21:07
@antirotor
Copy link
Member Author

This now correctly builds and run with docker. Unfortunately multiple hacks were used to fight wrong GLIBC versions on linux:

That problem is caused by new setuptools - this package is dependency of poetry itself and is automatically pulled to created environment. When Cx_Freeze is installed with that new version of setuptools, it will compile its stub executables and link them with wrong version of GLIBC (not available on Centos 7). So when finally OpenPype is build, those stubs are used for openpype_console and openpype_gui. So.... We hack it - after venv installation, setuptools is downgraded via pip, then cx_freeze is reinstalled and problem is solved.

To achieve this, it was necessary to get to values specified in pyproject.toml from shell scripts. For that I've created helper script parse_pyproject.py - you can call it with argumetns specifying path. For example, to get license from pyproject, just call python parse_pyproject.py tool.poetry.licese and it will return its value. If value is not found, None is returned. You can put multiple arguments there for multiple return values. To access list values, just specify index - for example: python parse_pyproject.py tool.poetry.source.0.url will return url from first item in tool.poetry,source list.

vendor is now handled by build_dependecies.py script and not by cx_freeze as it wasn't handling non-default paths in python parts well and there is no processing, just copying it to build folder.

@mkolar
Copy link
Member

mkolar commented Oct 8, 2021

I've tested as much as I could on windows in multiple hosts. all looking good.

@64qam
Copy link
Member

64qam commented Oct 8, 2021

On Centos: Nuke and Blender are ok. Maya and Nuke Studio/Hiero work also well, but when publishing, OP fails to collect Default Deadline Webservice. The same publishing works well on the older build.
maya
ng

@iLLiCiTiT
Copy link
Member

The same publishing works well on the older build.

Not related to this changes. Seems like is missing last develop merge...

if not app:
app = QtWidgets.QApplication([])

starter = PypeTrayStarter(app)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'starter' is assigned to but never used

@64qam
Copy link
Member

64qam commented Oct 13, 2021

Photoshop/AE on Mac OS: when launching on task, another OpenPype icon appears in task bar, Photoshop/AE won't start and console displays:

File "/Applications/OpenPype.app/Contents/MacOS/openpype/tools/tray_app/app.py", line 188, in on_timer
host_connected = self.is_host_connected()
File "/Applications/OpenPype.app/Contents/MacOS/repos/avalon-core/avalon/photoshop/lib.py", line 167, in is_host_connected
if ConsoleTrayApp.process.poll() is not None:
Attribute ERROR : 'NoneType' object has no attribute 'poll'``` 

@mkolar mkolar merged commit 7c2da65 into develop Oct 18, 2021
@mkolar mkolar deleted the feature/move-to-pyside2 branch October 18, 2021 13:26
@mkolar mkolar added the type: feature Larger, user affecting changes and completely new things label Oct 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature Larger, user affecting changes and completely new things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace PyQt5 with pyside2
5 participants