Skip to content

"run_after" and "when" decorator are incompatible with each other #12736

@alalazo

Description

@alalazo

Using both the @when and @run_after decorator on the same method results in weird errors, depending on the order in which they're used.

Steps to reproduce the issue

Use both decorators on the same method, like:

@run_after('configure')
@when('platform=darwin')
def filter_rt(self):
    # Don't link with -lrt; the system has no (and needs no) librt                                                                        
    filter_file(r' -lrt$', '', 'Makefile')

Error Message

Reporting the error description from a conversation with "Sly" on Slack:

I've tried it with the Git package by putting the two decorators on different lines. Having the @run_after('install') first results in the function trying to run even when the variant is not included and erroring out with Error: NoSuchMethodError: Package Git does not support install_subtree called with [email protected]%[email protected]~subtree~tcltk. Having the @when('+variantX') is first, it always runs the function and installs the functionality, regardless of whether the variant is included or not. The only way I've gotten to work in an expected manner is just having @run_after('install') and having an if '+variantX' in self.spec: conditional inside the function.

Information on your system

Should not be relevant

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions