-
Notifications
You must be signed in to change notification settings - Fork 337
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
Subclassing default rezplugins instead of replacing #720
Labels
Comments
Is your custom plugin also in a `local.py`? Off the top of my head, I'd say
that this is the culprit:
https://github.com/nerdvegas/rez/blob/master/src/rez/plugin_managers.py#L21.
This code finds plugins on REZ_PLUGINS_PATH and pulls them into the local
`rezplugins` module hierarchy. So, if you have a custom plugin in a
"./build_process/local.py" path relative to a plugin path, this is probably
getting loaded instead of the builtin equivalent module. Could you confirm
this by renaming your custom module to something other than "local"? I know
that won't give you the plugin you need, but it would show that this is the
problem.
A way we may be able to solve this - currently, the plugin manager uses the
module name as the plugin name. However, there's also a "name" classmethod
on all plugins, which to my knowledge (and it looks to be true in the
builtins), always matches the module name. So what we could do is update
https://github.com/nerdvegas/rez/blob/master/src/rez/plugin_managers.py#L93
to register using name() instead of the module name. We would also have to
update the same register_plugin() function to not override a plugin of the
same name if it's already there (that doesn't have to be done currently,
because python itself will only see the first module with that name).
With this small change, you should be able to rename your own module (to
"custom_local.py" or whatever), but keep the name() classmethod returning
"local". If I'm right then this should mean you can still override the
builtins, but you can also import those builtin plugin classes and subclass
them.
Let me know how you go,
A
…On Thu, Sep 5, 2019 at 7:13 PM Jordi Bastide ***@***.***> wrote:
Hi all,
We sometimes need to override official rezplugins for some reasons and
keep the default name (local build_process, ...) to avoid specifying a
different plugins in each command call.
Since 2.40.3 with #677 <#677>
feature, we are able to replace completely a default plugin by our custom
one and this is really great.
But a complete replace could be hard to maintain with the HEAD of official
rezplugins and a subclassing should be better. It's also useful to give
info only about what have been modified from the default plugin.
So a custom build_process/local.py should only contain:
from rezplugins.build_process.local import LocalBuildProcess
class MyCustomLocalBuildProcess(LocalBuildProcess):
def release(self, release_message=None, variants=None):
"""MyCustom LocalBuildProcess release override."""
self._print_header("Custom releasing %s..." % self.package.qualified_name)
def register_plugin():
return MyCustomLocalBuildProcess
instead of a full copy (~300 lines) with a similar modification than above.
Currently this is not possible to import the official local module when
we are using the custom local plugin, the plugin_manager skips import of
similar plugins (to avoid reload ?).
What do you think about this possible way to do ?
Jordi
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#720>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMOUST6ISZCXS3CY7L4U73QIDEULANCNFSM4IT3MSYA>
.
|
Yes, renaming my custom module allow me to import official LocalBuildProcess from local.py module and subclass it. Your approach sounds interesting (I still need to do some tests) and I could make you a PR if you agree to have the behavior described above in rez (it should be transparent). |
Sounds good Jordi, let's give it a go.
Thx
A
…On Mon, Sep 9, 2019 at 6:50 PM Jordi Bastide ***@***.***> wrote:
Could you confirm this by renaming your custom module to something other
than "local" ?
Yes, renaming my custom module allow me to import official
LocalBuildProcess from local.py module and subclass it.
Your approach sounds interesting (I still need to do some tests) but I
could make you a PR if you agree to have the behavior described above in
rez (it should be transparent).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#720>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMOUSVXIS7XAOX72DEG34TQIYE4ZANCNFSM4IT3MSYA>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi all,
We sometimes need to override official rezplugins for some reasons and keep the default name (local build_process, ...) to avoid specifying a different plugins in each command call.
Since 2.40.3 with #677 feature, we are able to replace completely a default plugin by our custom one and this is really great.
But a complete replace could be hard to maintain with the HEAD of official rezplugins and a subclassing should be better. It's also useful to give info only about what have been modified from the default plugin.
So a custom build_process/local.py should only contain:
instead of a full copy (~300 lines) with a similar modification than above.
Currently this is not possible to import the official
local
module when we are using the customlocal
plugin, the plugin_manager skips import of similar plugins (to avoid reload ?).What do you think about this possible way to do ?
Jordi
The text was updated successfully, but these errors were encountered: