Skip to content

Commit 77273a9

Browse files
author
Alex Wang
committed
merge main
2 parents 59e8eca + a244a18 commit 77273a9

14 files changed

Lines changed: 149 additions & 183 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/scripts/type-checks.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
6+
cd "$REPO_ROOT"
7+
8+
mypy --install-types --non-interactive \
9+
packages/aws-durable-execution-sdk-python/src/aws_durable_execution_sdk_python \
10+
packages/aws-durable-execution-sdk-python/tests
11+
12+
mypy --install-types --non-interactive \
13+
packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel \
14+
packages/aws-durable-execution-sdk-python-otel/tests
15+
16+
# comment out this for now as there are many type check errors in this package
17+
#mypy --install-types --non-interactive \
18+
# packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing \
19+
# packages/aws-durable-execution-sdk-python-testing/tests

.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-otel/src/aws_durable_execution_sdk_python_otel/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from opentelemetry import context, trace
2222
from opentelemetry.context import Context
2323
from opentelemetry.sdk.trace import TracerProvider
24+
from opentelemetry.sdk.trace import TracerProvider as SdkTracerProvider
2425
from opentelemetry.sdk.trace.sampling import TraceIdRatioBased
2526
from opentelemetry.trace import (
2627
Link,
@@ -81,7 +82,7 @@ class DurableExecutionOtelPlugin(DurableInstrumentationPlugin):
8182

8283
def __init__(
8384
self,
84-
trace_provider: TracerProvider,
85+
trace_provider: SdkTracerProvider,
8586
context_extractor: ContextExtractor | None = None,
8687
sampling_rate: float = 1.0,
8788
instrument_name: str = DEFAULT_INSTRUMENT_NAME,

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

0 commit comments

Comments
 (0)