Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle plugins that import another module, which is not in sys path #381

Open
hannesdelbeke opened this issue Jan 15, 2022 · 2 comments
Open

Comments

@hannesdelbeke
Copy link
Contributor

hannesdelbeke commented Jan 15, 2022

pyblish stores paths in a registered paths variable. It doesn't add module paths to the sys path.
this results in plugins failing to load sometimes.

example:

We have the following files in a folder

my_plugin_folder:
-- __init__.py
-- pyblish_plugin.py
-- helper_functions.py

pyblish_plugin imports helper_functions
But my_plugin_folder is not in our sys path.
Loading pyblish_plugin will fail with module note found

possible solutions:

  • pyblish adds registered plugin paths to the system path.
    To handle situations where 2 plugins both contain a file named helper_functions.py
    we should always do import my_plugin_folder.helper_functions and not import helper_functions

  • discourage users from using import, and enforce that a plugin should be self contained.
    this however severly limits plugins

  • ask user to handle environment management themselves correctly,
    But this raises the entry bar for people who want to use pyblish.
    Ideally an artist can download pyblish, download some plugins, load them in pyblish, and it all just works.

@hannesdelbeke
Copy link
Contributor Author

Automatically adding paths to the PYTHONPATH could break pipelines.
But it does seems like a good solution for the Pyblish plugin marketplace platform.
ideally the marketplace would download plugins to a single folder, and only that folder needs adding to your env vars.

this issue came to my attention since i currently have several repos, each containing indivual pyblish plugins, but not all repos are added to the PYTHONPATH
this would not be an issue when you develop all plugins inhouse. since then you also handle env management.
it's more for handling third party plugins.

@hannesdelbeke
Copy link
Contributor Author

hannesdelbeke commented Jan 23, 2022

noticed there is a PYBLISHPLUGINPATH variable that does exactly this.
but there isn't much documentation for this

on first sight, it is not clear that a plugin might not work because of import issues. due to not having your env setup properly.
this then results in a silent load, leaving the user confused. (but i registered the path, what is wrong?)
this would show up in the console if the user enabled debug logging.
With the PR merged in addressing silent fail confusing this should show in console as an import exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant