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

Fusion: automatic installation of PySide2 #6111

Merged
merged 21 commits into from
Jan 10, 2024

Conversation

kalisp
Copy link
Member

@kalisp kalisp commented Jan 8, 2024

Changelog Description

This PR adds hook which tries to check if PySide2 is installed in Python used by Fusion and if not, it tries to install it automatically.

Additional info

This is customer requirement. Even that there is explicit (which stays there) menu option inside of Fusion, it is happening that artists will not press it.
Hook is based on Blender approach, but checking for PySide2 is simplified as there is some issue about missing dataclass for click in Python3.6

Testing notes:

  1. uninstall PySide2 from Python 3.6 used by Fusion (you could learn where that Python is located directly in Fusion console:
    image
  2. launch Fusion - it should install PySide2
  3. launch Fusion again - it shouldn't do anything

Currently not working yet as subprocess is invoking wrong `pip` which causes issue about missing `dataclasses`.
Cannot use pip list as wrong pip from .venv is used and it was causing issue about missing dataclass (not in Python3.6).
This implementation is simpler and just tries to import PySide2.
@ynbot
Copy link
Contributor

ynbot commented Jan 8, 2024

Task linked: OP-7450 Fusion: setup PySide2

@ynbot ynbot added type: enhancement Enhancements to existing functionality size/S Denotes a PR changes 100-499 lines, ignoring general files host: Fusion labels Jan 8, 2024
@BigRoy
Copy link
Collaborator

BigRoy commented Jan 8, 2024

I assume this will make the fusion launch as slow as blender launch - can we make this optional somehow. We have no need for this feature and definitely want to avoid those speed issues.

Also, is there a reason we're not defaulting to PySide6?

kalisp and others added 4 commits January 8, 2024 15:12
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
@kalisp
Copy link
Member Author

kalisp commented Jan 8, 2024

I assume this will make the fusion launch as slow as blender launch - can we make this optional somehow. We have no need for this feature and definitely want to avoid those speed issues.

Also, is there a reason we're not defaulting to PySide6?

Would there be really difference in running and handling python-c import PySide2?

But I was thinking about making this optional, I don't think we have optionality in hooks. Created an issue for that #6112.

@BigRoy
Copy link
Collaborator

BigRoy commented Jan 8, 2024

But I was thinking about making this optional, I don't think we have optionality in hooks. Created an issue for that #6112.

You could always just check a project (or system) setting inside its execute method so it ends up doing nothing if force_install_pyside2 is e.g. disabled.

Would there be really difference in running and handling python-c import PySide2?

Difference from what?

@kalisp
Copy link
Member Author

kalisp commented Jan 8, 2024

Time wise difference. I am assuming that Blender might be a bit slower as it loops through all packages, but this one should be pretty fast, imho.

@antirotor
Copy link
Member

I know it can run in totally different python environment than AYON is, but should we at least try to install pyside version defined by the AYON launcher/addon itself in pyproject.toml? I mean this can in theory pull in latest version of pyside for given python that might not be exactly compatible with other tools. Or am I to paranoid?

This approach should be more generic, not tied to specific version of PySide2
@kalisp
Copy link
Member Author

kalisp commented Jan 9, 2024

Added optionality:
chrome_7vwqsCwZMR

Made query for existence of PySide more generic, it should handle different versions of PySide in the future.

@kalisp
Copy link
Member Author

kalisp commented Jan 9, 2024

I know it can run in totally different python environment than AYON is, but should we at least try to install pyside version defined by the AYON launcher/addon itself in pyproject.toml? I mean this can in theory pull in latest version of pyside for given python that might not be exactly compatible with other tools. Or am I to paranoid?

I don't think we can install same version of PySide in Python 3.6 as is for more up-to-date versions of Python.

@BigRoy
Copy link
Collaborator

BigRoy commented Jan 9, 2024

I know it can run in totally different python environment than AYON is, but should we at least try to install pyside version defined by the AYON launcher/addon itself in pyproject.toml? I mean this can in theory pull in latest version of pyside for given python that might not be exactly compatible with other tools. Or am I to paranoid?

I don't think we can install same version of PySide in Python 3.6 as is for more up-to-date versions of Python.

Note that we're not using Python 3.6 with Fusion but Python 3.9 (matching version with OP). Py3.6 is one of the supported versions - not necessarily the best version to use. ;)

Copy link
Member

@jakubjezek001 jakubjezek001 left a comment

Choose a reason for hiding this comment

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

LGTM! tested on Ayon and works perfect

kalisp and others added 3 commits January 9, 2024 17:17
Because it is not "expected" python in blender but installed python, I would expect the executable is python3 on linux/macos rather than python.

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
It checks first that it would need admin privileges for installation, if not it installs headlessly. If yes, it will create separate dialog that will ask for admin privileges.
@kalisp
Copy link
Member Author

kalisp commented Jan 10, 2024

Added headless possibility of PySide2 installation in Windows if no admin privileges required.

@jakubjezek001
Copy link
Member

I wonder if this menu item makes any sense at all now.
image

@jakubjezek001
Copy link
Member

Also the installation is happening silently which is ok, but since it is taking some time it made me wonder what is going on, since no UX feedback was given. Shouldn't some informative message popup and say, Ayon is preparing Fusion to first run, please be patient, it will take a minute. Or, you know, something like this.

Copy link
Member

@jakubjezek001 jakubjezek001 left a comment

Choose a reason for hiding this comment

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

works as advertized

@BigRoy
Copy link
Collaborator

BigRoy commented Jan 10, 2024

I wonder if this menu item makes any sense at all now. image

I'd personally prefer that menu entry to exist on our end - and disable the auto-install feature due to the influence it has on the startup speed for Fusion from the launcher (all the time). I'd rather have it fail to launch once inside Fusion - then make the user aware of the 'install it' instead of it continuously influencing the performance of the launch times.

But maybe I just have had to deal with too many people that want applications to launch in less than a few seconds. :)

Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
@kalisp
Copy link
Member Author

kalisp commented Jan 10, 2024

Yeah, the option must stay there as this hook is optional.

I don't believe that this hook takes too long after pyside is installed.

I couldn't find any dialog that could be thrown in Launcher during pre-launch hook, I am logging that PySide2 is being installed, but that will show up only in ayon_console.

@kalisp kalisp merged commit 399bb40 into develop Jan 10, 2024
1 check passed
@kalisp kalisp deleted the enhancement/OP-7450_Fusion-setup-PySide2 branch January 10, 2024 16:10
@ynbot ynbot added this to the next-patch milestone Jan 10, 2024
@BigRoy
Copy link
Collaborator

BigRoy commented Jan 11, 2024

Isn't this functionality technically wrong if the application environment settings is providing a PYTHONPATH that has PySide2 available? Somehow this PR requires PySide2 to be directly installed INTO the interpreters location, no?

It should actually be doing the check from within the environment of the application to run, e.g. Fusion's Python environment as defined by application settings?

@iLLiCiTiT
Copy link
Member

If you provide PYTHONPATH with PySide, you'll probably disable the prelaunch hook.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
host: Fusion size/S Denotes a PR changes 100-499 lines, ignoring general files sponsored Client endorsed or requested target: AYON target: OpenPype type: enhancement Enhancements to existing functionality
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants