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

Copy typeshed's LICENSE file to stubs packages #158

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
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
17 changes: 10 additions & 7 deletions stub_uploader/build_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,16 @@ def create_py_typed(metadata: Metadata, pkg_data: PackageData, dst: Path) -> Non
py_typed_path.write_text("partial\n" if metadata.partial else "")


def copy_changelog(distribution: str, dst: str) -> None:
def copy_license(ts_data: TypeshedData, dst: Path) -> None:
"""Copy the license file from the typeshed repository to the build directory."""
shutil.copy(ts_data.typeshed_path / "LICENSE", dst / "LICENSE")


def copy_changelog(distribution: str, dst: Path) -> None:
"""Copy changelog to the build directory."""
try:
shutil.copy(
os.path.join(CHANGELOG_PATH, f"{distribution}.md"),
os.path.join(dst, CHANGELOG),
)
with open(os.path.join(dst, "MANIFEST.in"), "a") as f:
shutil.copy(CHANGELOG_PATH / f"{distribution}.md", dst / CHANGELOG)
with open(dst / "MANIFEST.in", "a") as f:
f.write(f"include {CHANGELOG}\n")
except FileNotFoundError:
pass # Ignore missing changelogs
Expand Down Expand Up @@ -447,7 +449,8 @@ def main(
(tmpdir / "README.md").write_text(
generate_long_description(distribution, ts_data, metadata)
)
copy_changelog(distribution, str(tmpdir))
copy_license(ts_data, tmpdir)
copy_changelog(distribution, tmpdir)

print(f"\033[0;33mRunning '{sys.executable} -m build --no-isolation' in {tmpdir}")
print()
Expand Down
2 changes: 1 addition & 1 deletion stub_uploader/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
TYPES_PREFIX = "types-"

_ROOT = pathlib.Path(__file__).parent.parent
CHANGELOG_PATH = str((_ROOT / "data" / "changelogs").resolve())
CHANGELOG_PATH = (_ROOT / "data" / "changelogs").resolve()
UPLOADED_PATH = str((_ROOT / "data" / "uploaded_packages.txt").resolve())