Skip to content

Commit 7948ed3

Browse files
committed
fix: add legal files back to built packages
1 parent dc543c4 commit 7948ed3

10 files changed

Lines changed: 112 additions & 179 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env python3
2+
"""Verify built distributions include LICENSE and NOTICE files."""
3+
4+
from __future__ import annotations
5+
6+
import sys
7+
import tarfile
8+
import zipfile
9+
from pathlib import Path
10+
11+
12+
REQUIRED_BASENAMES = {"LICENSE", "NOTICE"}
13+
14+
15+
def list_archive_names(archive_path: Path) -> list[str]:
16+
if archive_path.suffix == ".whl":
17+
with zipfile.ZipFile(archive_path) as archive:
18+
return archive.namelist()
19+
20+
if archive_path.suffixes[-2:] == [".tar", ".gz"]:
21+
with tarfile.open(archive_path) as archive:
22+
return archive.getnames()
23+
24+
raise ValueError(f"Unsupported distribution type: {archive_path}")
25+
26+
27+
def verify_package(package_dir: Path) -> list[str]:
28+
dist_dir = package_dir / "dist"
29+
errors: list[str] = []
30+
31+
if not dist_dir.is_dir():
32+
return [f"{package_dir}: missing dist directory"]
33+
34+
archives = sorted(
35+
path
36+
for path in dist_dir.iterdir()
37+
if path.is_file()
38+
and (path.suffix == ".whl" or path.suffixes[-2:] == [".tar", ".gz"])
39+
)
40+
if not archives:
41+
return [f"{package_dir}: no built distributions found"]
42+
43+
for archive_path in archives:
44+
names = list_archive_names(archive_path)
45+
basenames = {Path(name).name for name in names}
46+
missing = sorted(REQUIRED_BASENAMES - basenames)
47+
if missing:
48+
errors.append(f"{archive_path}: missing {', '.join(missing)}")
49+
50+
return errors
51+
52+
53+
def main(argv: list[str]) -> int:
54+
if len(argv) < 2:
55+
print(
56+
"usage: check_dist_legal_files.py <package-dir> [<package-dir> ...]",
57+
file=sys.stderr,
58+
)
59+
return 2
60+
61+
errors: list[str] = []
62+
for arg in argv[1:]:
63+
errors.extend(verify_package(Path(arg)))
64+
65+
if errors:
66+
for error in errors:
67+
print(error, file=sys.stderr)
68+
return 1
69+
70+
for arg in argv[1:]:
71+
print(f"{arg}: LICENSE and NOTICE found in all distributions")
72+
return 0
73+
74+
75+
if __name__ == "__main__":
76+
raise SystemExit(main(sys.argv))

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ jobs:
6767
cd "$GITHUB_WORKSPACE"
6868
fi
6969
done
70+
- name: Verify legal files in published distributions
71+
run: |
72+
python .github/scripts/check_dist_legal_files.py \
73+
packages/aws-durable-execution-sdk-python \
74+
packages/aws-durable-execution-sdk-python-otel \
75+
packages/aws-durable-execution-sdk-python-testing

.github/workflows/pypi-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
working-directory: ${{ matrix.package.path }}
4545
run: hatch build
4646

47+
- name: Verify legal files in release distributions
48+
run: python .github/scripts/check_dist_legal_files.py ${{ matrix.package.path }}
49+
4750
- name: Upload distributions
4851
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
4952
with:

packages/aws-durable-execution-sdk-python-otel/pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ Documentation = "https://github.com/aws/aws-durable-execution-sdk-python#readme"
3434
Issues = "https://github.com/aws/aws-durable-execution-sdk-python/issues"
3535
Source = "https://github.com/aws/aws-durable-execution-sdk-python"
3636

37+
[tool.hatch.build.targets.sdist.force-include]
38+
"../../LICENSE" = "LICENSE"
39+
"../../NOTICE" = "NOTICE"
40+
3741
[tool.hatch.build.targets.wheel]
3842
packages = ["src/aws_durable_execution_sdk_python_otel"]
3943

44+
[tool.hatch.build.targets.wheel.force-include]
45+
"../../LICENSE" = "aws_durable_execution_sdk_python_otel/LICENSE"
46+
"../../NOTICE" = "aws_durable_execution_sdk_python_otel/NOTICE"
47+
4048
[tool.hatch.version]
4149
path = "src/aws_durable_execution_sdk_python_otel/__about__.py"
4250

packages/aws-durable-execution-sdk-python-testing/LICENSE

Lines changed: 0 additions & 175 deletions
This file was deleted.

packages/aws-durable-execution-sdk-python-testing/NOTICE

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/aws-durable-execution-sdk-python-testing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ tldr; use `hatch` and it will manage virtual envs and dependencies for you, so y
196196

197197
## License
198198

199-
This project is licensed under the [Apache-2.0 License](LICENSE).
199+
This project is licensed under the [Apache-2.0 License](https://github.com/aws/aws-durable-execution-sdk-python/blob/main/LICENSE).

packages/aws-durable-execution-sdk-python-testing/pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,17 @@ dex-local-runner = "aws_durable_execution_sdk_python_testing.cli:main"
3737
[tool.hatch.build.targets.sdist]
3838
packages = ["src/aws_durable_execution_sdk_python_testing"]
3939

40+
[tool.hatch.build.targets.sdist.force-include]
41+
"../../LICENSE" = "LICENSE"
42+
"../../NOTICE" = "NOTICE"
43+
4044
[tool.hatch.build.targets.wheel]
4145
packages = ["src/aws_durable_execution_sdk_python_testing"]
4246

47+
[tool.hatch.build.targets.wheel.force-include]
48+
"../../LICENSE" = "aws_durable_execution_sdk_python_testing/LICENSE"
49+
"../../NOTICE" = "aws_durable_execution_sdk_python_testing/NOTICE"
50+
4351
[tool.hatch.metadata]
4452
allow-direct-references = true
4553

packages/aws-durable-execution-sdk-python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![PyPI - Version](https://img.shields.io/pypi/v/aws-durable-execution-sdk-python.svg)](https://pypi.org/project/aws-durable-execution-sdk-python)
55
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aws-durable-execution-sdk-python.svg)](https://pypi.org/project/aws-durable-execution-sdk-python)
66
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/aws/aws-durable-execution-sdk-python/badge)](https://scorecard.dev/viewer/?uri=github.com/aws/aws-durable-execution-sdk-python)
7-
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
7+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/aws/aws-durable-execution-sdk-python/blob/main/LICENSE)
88

99
-----
1010

@@ -82,4 +82,4 @@ The complete documentation for the AWS Durable Execution SDK for Python lives on
8282

8383
## 📄 License
8484

85-
See the [LICENSE](LICENSE) file for our project's licensing.
85+
See the [LICENSE](https://github.com/aws/aws-durable-execution-sdk-python/blob/main/LICENSE) file for our project's licensing.

packages/aws-durable-execution-sdk-python/pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,17 @@ Documentation = "https://github.com/aws/aws-durable-execution-sdk-python#readme"
2828
Issues = "https://github.com/aws/aws-durable-execution-sdk-python/issues"
2929
Source = "https://github.com/aws/aws-durable-execution-sdk-python"
3030

31+
[tool.hatch.build.targets.sdist.force-include]
32+
"../../LICENSE" = "LICENSE"
33+
"../../NOTICE" = "NOTICE"
34+
3135
[tool.hatch.build.targets.wheel]
3236
packages = ["src/aws_durable_execution_sdk_python"]
3337

38+
[tool.hatch.build.targets.wheel.force-include]
39+
"../../LICENSE" = "aws_durable_execution_sdk_python/LICENSE"
40+
"../../NOTICE" = "aws_durable_execution_sdk_python/NOTICE"
41+
3442
[tool.hatch.version]
3543
path = "src/aws_durable_execution_sdk_python/__about__.py"
3644

0 commit comments

Comments
 (0)