Created
February 12, 2021 19:06
-
-
Save asherf/6012037c1afe6940ca3ef2c421e8ee45 to your computer and use it in GitHub Desktop.
pants setup_py plugin that reads long description from a file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ToolchainSetupKwargsRequest(SetupKwargsRequest): | |
@classmethod | |
def is_applicable(cls, _: Target) -> bool: | |
return True | |
@rule | |
async def toolchain_setup_plugin(request: ToolchainSetupKwargsRequest) -> SetupKwargs: | |
explicit_kwargs = request.explicit_kwargs | |
digest_contents = await Get( | |
DigestContents, | |
PathGlobs( | |
[explicit_kwargs.pop("long_desc_file")], | |
description_of_origin="`setup_py()` plugin", | |
glob_match_error_behavior=GlobMatchErrorBehavior.error, | |
), | |
) | |
classifiers = request.explicit_kwargs.pop("additional_classifiers") | |
explicit_kwargs.update( | |
version=VERSION, | |
long_description=digest_contents[0].content.decode(), | |
long_description_content_type="text/markdown", | |
url="https://toolchain.com", | |
license="Proprietary", | |
zip_safe=True, | |
classifiers=classifiers, | |
author="Toolchain Inc", | |
author_email="info@toolchain.com", | |
) | |
return SetupKwargs(explicit_kwargs, address=request.target.address) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment