Skip to content

Description can now be amended per package #11

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

Merged
merged 4 commits into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions scripts/build_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,7 @@
name = "types-{distribution}"
description = "Typing stubs for {distribution}"
long_description = '''
## Typing stubs for {distribution}

This is an auto-generated PEP 561 type stub package for `{distribution}` package.
It can be used by type-checking tools like mypy, PyCharm, pytype etc. to check code
that uses `{distribution}`. The source for this package can be found at
https://github.com/python/typeshed/tree/master/stubs/{distribution}. All fixes for
types and metadata should be contributed there.

See https://github.com/python/typeshed/blob/master/README.md for more details.
This package was generated from typeshed commit `{commit}`.
{long_description}
'''.lstrip()

setup(name=name,
Expand All @@ -75,6 +66,22 @@
""").lstrip()


DESCRIPTION_INTRO_TEMPLATE = """
## Typing stubs for {distribution}

This is an auto-generated PEP 561 type stub package for `{distribution}` package.
It can be used by type-checking tools like mypy, PyCharm, pytype etc. to check code
that uses `{distribution}`. The source for this package can be found at
https://github.com/python/typeshed/tree/master/stubs/{distribution}. All fixes for
types and metadata should be contributed there.
""".strip()

DESCRIPTION_OUTRO_TEMPLATE = """
See https://github.com/python/typeshed/blob/master/README.md for more details.
This package was generated from typeshed commit `{commit}`.
""".strip()


def strip_types_prefix(dependency: str) -> str:
assert dependency.startswith("types-"), "Currently only dependencies on stub packages are supported"
return dependency[len("types-"):]
Expand Down Expand Up @@ -276,14 +283,26 @@ def generate_setup_file(
assert version.count(".") == 1, f"Version must be major.minor, not {version}"
return SETUP_TEMPLATE.format(
distribution=distribution,
long_description=generate_long_description(distribution, commit, metadata),
version=f"{version}.{increment}",
requires=metadata.get("requires", []),
packages=packages,
package_data=package_data,
commit=commit,
)


def generate_long_description(
distribution: str, commit: str, metadata: Dict[str, Any]
) -> str:
extra_description = metadata.get("extra_description", "").strip()
parts = []
parts.append(DESCRIPTION_INTRO_TEMPLATE.format(distribution=distribution))
if extra_description:
parts.append(extra_description)
parts.append(DESCRIPTION_OUTRO_TEMPLATE.format(commit=commit))
return "\n\n".join(parts)


def main(typeshed_dir: str, distribution: str, increment: int) -> str:
"""Generate a wheel for a third-party distribution in typeshed.

Expand Down