def packager()

in source/python/neuropod/utils/packaging_utils.py [0:0]


def packager(platform):
    # A decorator that wraps a `platform` specific packager with generic packaging and sets docstrings correctly

    def inner(f):
        # The default args for a packager come from combining the default args
        # of _create_neuropod and the packager itself
        @expand_default_kwargs(deps=[_create_neuropod, f])
        def wrapper(**kwargs):
            # Runs create neuropod
            _create_neuropod(packager_fn=f, platform=platform, **kwargs)

        # Expects the functon to have a docstring including
        # {common_doc_pre} and {common_doc_post}
        # We can't easily use `.format` because the docstrings contain {}
        wrapper.__doc__ = f.__doc__.replace("{common_doc_pre}", COMMON_DOC_PRE).replace(
            "{common_doc_post}", COMMON_DOC_POST
        )
        wrapper.__name__ = f.__name__

        return wrapper

    return inner