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

Subclassing default rezplugins instead of replacing #720

Open
Jordibastide opened this issue Sep 5, 2019 · 3 comments
Open

Subclassing default rezplugins instead of replacing #720

Jordibastide opened this issue Sep 5, 2019 · 3 comments

Comments

@Jordibastide
Copy link

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:

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

@nerdvegas
Copy link
Contributor

nerdvegas commented Sep 6, 2019 via email

@Jordibastide
Copy link
Author

Jordibastide commented Sep 9, 2019

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) and I could make you a PR if you agree to have the behavior described above in rez (it should be transparent).

@nerdvegas
Copy link
Contributor

nerdvegas commented Sep 9, 2019 via email

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

No branches or pull requests

3 participants