Conversation
|
Wait a second - what's this solving? 🤔 This was only ever broken inside pyblish plug-ins, right? Or did we just get luck and so far never tried/faced it with other AYON plug-ins? Also, where in AYON have we used "Directory discovery"? 🤔 Is that for AYON addons themselvs? |
No, in pyblish, you just can't use dataclasses. In AYON (before this PR) you can't use
Everywhere? We don't return path to each individual plugin file, we do register directories with plugins |
Sure - but at some point we discover the files in those folders, and it's those files that we import that need to be in We load file Also, why need the hashing - doesn't pyblish use abspath and it's absolutely fine. Why do we even need to hash it? 🤔 Shall we call about this? |
c1e564e to
bcf07be
Compare
|
Let me know when you needed that other review pass for this @iLLiCiTiT |
@BigRoy should be ready. Removed the package logic as the relative imports were not stable. |
Changelog Description
Overal improvement of the dynamic import logic. It is possible to use dataclasses in case annotations are imported and it is possible to use relative imports within the plugin directory (if a directory is registered).
Additional info
Both
modules_from_pathandimport_filepathcan expectPath. Themodules_from_pathsupports to pass in path to a python file.I might overdue this changes so maybe I'll make it smaller.
dataclassandfrom __future__ import annotationsdoes not cause crashes. That was fixed by always storing the module into sys modules. Default implementation is using parent directory as hash of parent module.__init__.pyfile in the directory (the file itself is probably imported or used).NOTE: It does not mean we can use dataclasses in publish plugins, there are still places using pyblish default discover logic.
Testing notes:
Dataclasses fix
dataclassesand__future__.annoationsin a plugin file.Directory import
__init__.pyfile to a plugins directory._structures.pyinto the directory and define a class there. NOTE: Files starting with_are not used for plugin discovery.from ._structures import MyClassin other plugin.