ferogram 0.5.4__tar.gz → 0.5.5b3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ferogram-0.5.5b3/.github/scripts/check_release.py +163 -0
- ferogram-0.5.5b3/.github/scripts/verify_provenance.py +115 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/.github/workflows/compile-check.yml +19 -13
- ferogram-0.5.5b3/.github/workflows/publish.yml +484 -0
- ferogram-0.5.5b3/.github/workflows/tests.yml +50 -0
- ferogram-0.5.5b3/.gitignore +21 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/CHANGELOG.md +52 -0
- ferogram-0.5.5b3/CONTRIBUTING.md +51 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/Cargo.lock +19 -20
- {ferogram-0.5.4 → ferogram-0.5.5b3}/Cargo.toml +7 -7
- {ferogram-0.5.4 → ferogram-0.5.5b3}/FEATURES.md +5 -4
- {ferogram-0.5.4 → ferogram-0.5.5b3}/Makefile +12 -5
- {ferogram-0.5.4 → ferogram-0.5.5b3}/PKG-INFO +4 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3}/build.rs +6 -6
- ferogram-0.5.5b3/examples/README.md +38 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/group_management.py +0 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3}/pyproject.toml +22 -2
- ferogram-0.5.5b3/python/ferogram/_internal.py +404 -0
- ferogram-0.5.5b3/python/ferogram/client.py +1215 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/filters.py +4 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/keyboards.py +35 -32
- ferogram-0.5.5b3/python/ferogram/methods/__init__.py +38 -0
- ferogram-0.5.5b3/python/ferogram/methods/auth.py +240 -0
- ferogram-0.5.5b3/python/ferogram/methods/bots.py +195 -0
- ferogram-0.5.5b3/python/ferogram/methods/chats.py +339 -0
- ferogram-0.5.5b3/python/ferogram/methods/dialogs.py +110 -0
- ferogram-0.5.5b3/python/ferogram/methods/invites.py +116 -0
- ferogram-0.5.5b3/python/ferogram/methods/media.py +853 -0
- ferogram-0.5.5b3/python/ferogram/methods/messages.py +541 -0
- ferogram-0.5.5b3/python/ferogram/methods/participants.py +206 -0
- ferogram-0.5.5b3/python/ferogram/methods/users.py +209 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/_tl_schema.py +344 -91
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/__init__.py +4 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/account.py +16 -16
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/aicompose.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/auth.py +144 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/bots.py +86 -11
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/channels.py +17 -12
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/communities.py +6 -6
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/contacts.py +79 -9
- ferogram-0.5.5b3/python/ferogram/raw/generated/functions/ephemeral.py +455 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/messages.py +465 -64
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/payments.py +523 -25
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/phone.py +14 -14
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/photos.py +3 -3
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/premium.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/smsjobs.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/stats.py +5 -5
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/stickers.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/stories.py +7 -7
- ferogram-0.5.5b3/python/ferogram/raw/generated/functions/toncenter.py +95 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/updates.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/upload.py +1 -1
- ferogram-0.5.5b3/python/ferogram/raw/generated/functions/wallet.py +957 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/__init__.py +6 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/_base.py +4805 -1524
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/account.py +3 -3
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/auth.py +36 -3
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/bots.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/chatlists.py +1 -1
- ferogram-0.5.5b3/python/ferogram/raw/generated/types/ephemeral.py +78 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/help.py +6 -6
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/messages.py +116 -13
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/payments.py +73 -6
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/premium.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/smsjobs.py +1 -1
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/stories.py +1 -1
- ferogram-0.5.5b3/python/ferogram/raw/generated/types/toncenter.py +84 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/updates.py +3 -3
- ferogram-0.5.5b3/python/ferogram/raw/generated/types/wallet.py +645 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/tl.py +66 -1
- ferogram-0.5.5b3/python/ferogram/transfer.py +306 -0
- {ferogram-0.5.4/ferogram → ferogram-0.5.5b3/schema}/api.tl +263 -51
- ferogram-0.5.5b3/tests/conftest.py +3 -0
- ferogram-0.5.5b3/tests/support.py +54 -0
- ferogram-0.5.5b3/tests/unit/test_codegen_up_to_date.py +37 -0
- ferogram-0.5.5b3/tests/unit/test_filters.py +181 -0
- ferogram-0.5.5b3/tests/unit/test_keyboards.py +179 -0
- ferogram-0.5.5b3/tests/unit/test_method_requests.py +328 -0
- ferogram-0.5.5b3/tests/unit/test_public_api.py +126 -0
- {ferogram-0.5.4/tests → ferogram-0.5.5b3/tests/unit}/test_rich.py +12 -19
- ferogram-0.5.5b3/tests/unit/test_schema_usage.py +78 -0
- ferogram-0.5.5b3/tests/unit/test_tl_primitives.py +190 -0
- {ferogram-0.5.4/tests → ferogram-0.5.5b3/tests/unit}/test_tl_roundtrip.py +17 -17
- ferogram-0.5.5b3/tests/unit/test_types.py +124 -0
- ferogram-0.5.5b3/tests/unit/test_updates.py +38 -0
- {ferogram-0.5.4/ferogram/raw → ferogram-0.5.5b3/tools}/codegen.py +8 -2
- ferogram-0.5.4/.github/workflows/publish.yml +0 -299
- ferogram-0.5.4/.gitignore +0 -9
- ferogram-0.5.4/ferogram/client.py +0 -4218
- ferogram-0.5.4/ferogram/raw/generated/functions/ephemeral.py +0 -241
- {ferogram-0.5.4 → ferogram-0.5.5b3}/.readthedocs.yaml +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/LICENSE-APACHE +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/LICENSE-MIT +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/README.md +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/assets/architecture.svg +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/admin_tools.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/command_bot.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/echo_bot.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/media_bot.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/raw_invoke.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/rich_message.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/search_bot.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/send_hi.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/send_media.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/send_message.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/update_handlers.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/user_management.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/examples/userbot.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/__init__.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/logging.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/py.typed +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/__init__.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/api/__init__.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/api/functions.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/api/types.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/__init__.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/chatlists.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/folders.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/fragment.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/help.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/langpack.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/functions/users.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/aicompose.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/channels.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/communities.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/contacts.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/fragment.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/phone.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/photos.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/stats.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/stickers.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/storage.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/upload.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/generated/types/users.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/raw/proxy.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/rich.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/types.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3/python}/ferogram/updates.py +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/connection.rs +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/lib.rs +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/message_box.rs +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/pipelined.rs +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/raw.rs +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/session.rs +0 -0
- {ferogram-0.5.4 → ferogram-0.5.5b3}/src/srp.rs +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Release checks used by .github/workflows/publish.yml.
|
|
3
|
+
|
|
4
|
+
check_release.py version [--check-pypi]
|
|
5
|
+
pyproject.toml version must match the pushed tag (v<version>). With
|
|
6
|
+
--check-pypi the version must also not exist on PyPI yet.
|
|
7
|
+
|
|
8
|
+
check_release.py dists DIR VERSION
|
|
9
|
+
DIR must hold exactly the distributions a full release consists of.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
import fnmatch
|
|
14
|
+
import os
|
|
15
|
+
import re
|
|
16
|
+
import sys
|
|
17
|
+
import tomllib
|
|
18
|
+
import urllib.error
|
|
19
|
+
import urllib.request
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
PROJECT = "ferogram"
|
|
23
|
+
|
|
24
|
+
# One pattern per distribution in a release. Each pattern must match exactly
|
|
25
|
+
# one file and every file must match exactly one pattern.
|
|
26
|
+
EXPECTED_DISTS = [
|
|
27
|
+
"{p}-{v}.tar.gz",
|
|
28
|
+
"{p}-{v}-cp39-abi3-manylinux*x86_64*.whl",
|
|
29
|
+
"{p}-{v}-cp39-abi3-manylinux*aarch64*.whl",
|
|
30
|
+
"{p}-{v}-cp39-abi3-macosx_*_x86_64.whl",
|
|
31
|
+
"{p}-{v}-cp39-abi3-macosx_*_arm64.whl",
|
|
32
|
+
"{p}-{v}-cp39-abi3-win_amd64.whl",
|
|
33
|
+
"{p}-{v}-cp39-abi3-android_*_arm64_v8a.whl",
|
|
34
|
+
"{p}-{v}-cp39-abi3-android_*_armeabi_v7a.whl",
|
|
35
|
+
"{p}-{v}-cp39-abi3-android_*_x86_64.whl",
|
|
36
|
+
"{p}-{v}-cp39-abi3-android_*_x86.whl",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def error(msg: str) -> None:
|
|
41
|
+
print(f"::error::{msg}")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def warning(msg: str) -> None:
|
|
45
|
+
print(f"::warning::{msg}")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def read_versions(root: Path) -> tuple[str, str]:
|
|
49
|
+
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
|
|
50
|
+
cargo = tomllib.loads((root / "Cargo.toml").read_text(encoding="utf-8"))
|
|
51
|
+
return pyproject["project"]["version"], cargo["package"]["version"]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def pep440_to_semver(version: str) -> str:
|
|
55
|
+
"""Spell a PEP 440 version the way Cargo.toml has to write it."""
|
|
56
|
+
m = re.fullmatch(r"(\d+\.\d+\.\d+)(?:(a|b|rc)(\d+))?(?:\.post(\d+))?(?:\.dev(\d+))?", version)
|
|
57
|
+
if not m:
|
|
58
|
+
return version
|
|
59
|
+
base, kind, num, post, dev = m.groups()
|
|
60
|
+
parts = []
|
|
61
|
+
if kind:
|
|
62
|
+
parts.append(f"{ {'a': 'alpha', 'b': 'beta', 'rc': 'rc'}[kind] }.{num}")
|
|
63
|
+
if post:
|
|
64
|
+
parts.append(f"post.{post}")
|
|
65
|
+
if dev:
|
|
66
|
+
parts.append(f"dev.{dev}")
|
|
67
|
+
return base + ("-" + ".".join(parts) if parts else "")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def on_pypi(project: str, version: str) -> bool:
|
|
71
|
+
url = f"https://pypi.org/pypi/{project}/{version}/json"
|
|
72
|
+
try:
|
|
73
|
+
with urllib.request.urlopen(url, timeout=30):
|
|
74
|
+
return True
|
|
75
|
+
except urllib.error.HTTPError as exc:
|
|
76
|
+
if exc.code == 404:
|
|
77
|
+
return False
|
|
78
|
+
raise
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def cmd_version(args: argparse.Namespace) -> int:
|
|
82
|
+
version, cargo_version = read_versions(Path(args.root))
|
|
83
|
+
problems = []
|
|
84
|
+
|
|
85
|
+
if os.environ.get("GITHUB_REF_TYPE") == "tag":
|
|
86
|
+
tag = os.environ["GITHUB_REF_NAME"]
|
|
87
|
+
if tag != f"v{version}":
|
|
88
|
+
problems.append(
|
|
89
|
+
f"tag {tag} does not match the pyproject.toml version {version} "
|
|
90
|
+
f"(expected tag v{version})"
|
|
91
|
+
)
|
|
92
|
+
else:
|
|
93
|
+
print("Not a tag run, skipping the tag comparison.")
|
|
94
|
+
|
|
95
|
+
if cargo_version != pep440_to_semver(version):
|
|
96
|
+
warning(
|
|
97
|
+
f"Cargo.toml version {cargo_version} differs from pyproject.toml "
|
|
98
|
+
f"version {version} (expected {pep440_to_semver(version)}). "
|
|
99
|
+
"The wheels use the pyproject.toml version."
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
if args.check_pypi and on_pypi(PROJECT, version):
|
|
103
|
+
problems.append(f"{PROJECT} {version} already exists on PyPI")
|
|
104
|
+
|
|
105
|
+
for problem in problems:
|
|
106
|
+
error(problem)
|
|
107
|
+
if problems:
|
|
108
|
+
return 1
|
|
109
|
+
|
|
110
|
+
print(f"{PROJECT} {version}")
|
|
111
|
+
output = os.environ.get("GITHUB_OUTPUT")
|
|
112
|
+
if output:
|
|
113
|
+
with open(output, "a", encoding="utf-8") as fh:
|
|
114
|
+
fh.write(f"version={version}\n")
|
|
115
|
+
return 0
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def cmd_dists(args: argparse.Namespace) -> int:
|
|
119
|
+
files = sorted(p.name for p in Path(args.dir).iterdir() if p.is_file())
|
|
120
|
+
patterns = [p.format(p=PROJECT, v=args.version) for p in EXPECTED_DISTS]
|
|
121
|
+
problems = []
|
|
122
|
+
|
|
123
|
+
for pattern in patterns:
|
|
124
|
+
matches = [f for f in files if fnmatch.fnmatch(f, pattern)]
|
|
125
|
+
if len(matches) != 1:
|
|
126
|
+
problems.append(f"{len(matches)} files match {pattern}, expected 1")
|
|
127
|
+
|
|
128
|
+
for name in files:
|
|
129
|
+
hits = [p for p in patterns if fnmatch.fnmatch(name, p)]
|
|
130
|
+
if len(hits) != 1:
|
|
131
|
+
problems.append(f"unexpected file in {args.dir}: {name}")
|
|
132
|
+
|
|
133
|
+
for name in files:
|
|
134
|
+
print(name)
|
|
135
|
+
for problem in problems:
|
|
136
|
+
error(problem)
|
|
137
|
+
if problems:
|
|
138
|
+
return 1
|
|
139
|
+
|
|
140
|
+
print(f"{len(files)} distributions, all expected platforms present")
|
|
141
|
+
return 0
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def main() -> int:
|
|
145
|
+
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
146
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
147
|
+
|
|
148
|
+
p_version = sub.add_parser("version")
|
|
149
|
+
p_version.add_argument("--root", default=".")
|
|
150
|
+
p_version.add_argument("--check-pypi", action="store_true")
|
|
151
|
+
p_version.set_defaults(func=cmd_version)
|
|
152
|
+
|
|
153
|
+
p_dists = sub.add_parser("dists")
|
|
154
|
+
p_dists.add_argument("dir")
|
|
155
|
+
p_dists.add_argument("version")
|
|
156
|
+
p_dists.set_defaults(func=cmd_dists)
|
|
157
|
+
|
|
158
|
+
args = parser.parse_args()
|
|
159
|
+
return args.func(args)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if __name__ == "__main__":
|
|
163
|
+
sys.exit(main())
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Check a published PyPI release against the distributions that were uploaded.
|
|
3
|
+
|
|
4
|
+
Polls the PyPI simple API (PEP 691) until every file of the release is listed
|
|
5
|
+
and has a provenance URL. Then it checks, for every file:
|
|
6
|
+
|
|
7
|
+
- the sha256 on PyPI equals the sha256 of the local file
|
|
8
|
+
- the provenance object (PEP 740) names the expected GitHub publisher
|
|
9
|
+
|
|
10
|
+
The signatures themselves are verified separately with pypi-attestations.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import hashlib
|
|
15
|
+
import json
|
|
16
|
+
import sys
|
|
17
|
+
import time
|
|
18
|
+
import urllib.request
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
SIMPLE_ACCEPT = "application/vnd.pypi.simple.v1+json"
|
|
22
|
+
INTEGRITY_ACCEPT = "application/vnd.pypi.integrity.v1+json"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_json(url: str, accept: str) -> dict:
|
|
26
|
+
request = urllib.request.Request(url, headers={"Accept": accept})
|
|
27
|
+
with urllib.request.urlopen(request, timeout=30) as response:
|
|
28
|
+
return json.load(response)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def sha256(path: Path) -> str:
|
|
32
|
+
digest = hashlib.sha256()
|
|
33
|
+
with path.open("rb") as fh:
|
|
34
|
+
for chunk in iter(lambda: fh.read(1 << 20), b""):
|
|
35
|
+
digest.update(chunk)
|
|
36
|
+
return digest.hexdigest()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main() -> int:
|
|
40
|
+
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
|
41
|
+
parser.add_argument("project")
|
|
42
|
+
parser.add_argument("version")
|
|
43
|
+
parser.add_argument("--dist-dir", required=True)
|
|
44
|
+
parser.add_argument("--repository", required=True, help="owner/repo")
|
|
45
|
+
parser.add_argument("--workflow", required=True, help="e.g. publish.yml")
|
|
46
|
+
parser.add_argument("--environment", default="")
|
|
47
|
+
parser.add_argument("--timeout", type=int, default=1200)
|
|
48
|
+
parser.add_argument("--interval", type=int, default=30)
|
|
49
|
+
parser.add_argument("--files-out", help="write the checked file names here")
|
|
50
|
+
args = parser.parse_args()
|
|
51
|
+
|
|
52
|
+
local = {p.name: sha256(p) for p in Path(args.dist_dir).iterdir() if p.is_file()}
|
|
53
|
+
if not local:
|
|
54
|
+
print(f"::error::no files in {args.dist_dir}")
|
|
55
|
+
return 1
|
|
56
|
+
|
|
57
|
+
url = f"https://pypi.org/simple/{args.project}/"
|
|
58
|
+
deadline = time.monotonic() + args.timeout
|
|
59
|
+
while True:
|
|
60
|
+
listing = get_json(url, SIMPLE_ACCEPT)
|
|
61
|
+
remote = {f["filename"]: f for f in listing["files"] if f["filename"] in local}
|
|
62
|
+
waiting = sorted(
|
|
63
|
+
(set(local) - set(remote))
|
|
64
|
+
| {n for n, f in remote.items() if not f.get("provenance")}
|
|
65
|
+
)
|
|
66
|
+
if not waiting:
|
|
67
|
+
break
|
|
68
|
+
if time.monotonic() > deadline:
|
|
69
|
+
print("::error::timed out waiting for PyPI. Not listed or without provenance:")
|
|
70
|
+
for name in waiting:
|
|
71
|
+
print(f" {name}")
|
|
72
|
+
return 1
|
|
73
|
+
print(f"{len(waiting)} of {len(local)} files not ready yet, retrying in {args.interval}s")
|
|
74
|
+
time.sleep(args.interval)
|
|
75
|
+
|
|
76
|
+
problems = []
|
|
77
|
+
for name in sorted(local):
|
|
78
|
+
entry = remote[name]
|
|
79
|
+
found = []
|
|
80
|
+
if entry["hashes"].get("sha256") != local[name]:
|
|
81
|
+
found.append(f"{name}: sha256 on PyPI differs from the uploaded file")
|
|
82
|
+
|
|
83
|
+
provenance = get_json(entry["provenance"], INTEGRITY_ACCEPT)
|
|
84
|
+
publishers = [
|
|
85
|
+
bundle.get("publisher") or {}
|
|
86
|
+
for bundle in provenance.get("attestation_bundles", [])
|
|
87
|
+
if bundle.get("attestations")
|
|
88
|
+
]
|
|
89
|
+
matched = any(
|
|
90
|
+
pub.get("kind") == "GitHub"
|
|
91
|
+
and pub.get("repository") == args.repository
|
|
92
|
+
and pub.get("workflow") == args.workflow
|
|
93
|
+
and (not args.environment or pub.get("environment") == args.environment)
|
|
94
|
+
for pub in publishers
|
|
95
|
+
)
|
|
96
|
+
if not matched:
|
|
97
|
+
found.append(f"{name}: unexpected publisher {publishers}")
|
|
98
|
+
|
|
99
|
+
if not found:
|
|
100
|
+
print(f"ok {name}")
|
|
101
|
+
problems.extend(found)
|
|
102
|
+
|
|
103
|
+
for problem in problems:
|
|
104
|
+
print(f"::error::{problem}")
|
|
105
|
+
if problems:
|
|
106
|
+
return 1
|
|
107
|
+
|
|
108
|
+
if args.files_out:
|
|
109
|
+
Path(args.files_out).write_text("\n".join(sorted(local)) + "\n", encoding="utf-8")
|
|
110
|
+
print(f"{len(local)} files on PyPI with provenance from {args.repository} ({args.workflow})")
|
|
111
|
+
return 0
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
sys.exit(main())
|
|
@@ -18,21 +18,25 @@ on:
|
|
|
18
18
|
- android-aarch64
|
|
19
19
|
- all
|
|
20
20
|
|
|
21
|
+
permissions:
|
|
22
|
+
contents: read
|
|
23
|
+
|
|
21
24
|
jobs:
|
|
22
25
|
|
|
23
26
|
linux-x86_64:
|
|
24
27
|
if: inputs.target == 'linux-x86_64' || inputs.target == 'all'
|
|
25
|
-
runs-on: ubuntu-
|
|
28
|
+
runs-on: ubuntu-24.04
|
|
26
29
|
steps:
|
|
27
|
-
- uses: actions/checkout@
|
|
30
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
28
31
|
with:
|
|
29
32
|
ref: ${{ inputs.ref }}
|
|
33
|
+
persist-credentials: false
|
|
30
34
|
|
|
31
|
-
- uses: actions/setup-python@
|
|
35
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
32
36
|
with:
|
|
33
37
|
python-version: "3.13"
|
|
34
38
|
|
|
35
|
-
- uses: Swatinem/rust-cache@v2
|
|
39
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
36
40
|
with:
|
|
37
41
|
key: compile-check-x86_64
|
|
38
42
|
|
|
@@ -60,17 +64,18 @@ jobs:
|
|
|
60
64
|
|
|
61
65
|
linux-aarch64:
|
|
62
66
|
if: inputs.target == 'linux-aarch64' || inputs.target == 'all'
|
|
63
|
-
runs-on: ubuntu-
|
|
67
|
+
runs-on: ubuntu-24.04
|
|
64
68
|
steps:
|
|
65
|
-
- uses: actions/checkout@
|
|
69
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
66
70
|
with:
|
|
67
71
|
ref: ${{ inputs.ref }}
|
|
72
|
+
persist-credentials: false
|
|
68
73
|
|
|
69
|
-
- uses: actions/setup-python@
|
|
74
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
70
75
|
with:
|
|
71
76
|
python-version: "3.13"
|
|
72
77
|
|
|
73
|
-
- uses: Swatinem/rust-cache@v2
|
|
78
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
74
79
|
with:
|
|
75
80
|
key: compile-check-aarch64
|
|
76
81
|
|
|
@@ -84,24 +89,25 @@ jobs:
|
|
|
84
89
|
|
|
85
90
|
android-aarch64:
|
|
86
91
|
if: inputs.target == 'android-aarch64' || inputs.target == 'all'
|
|
87
|
-
runs-on: ubuntu-
|
|
92
|
+
runs-on: ubuntu-24.04
|
|
88
93
|
steps:
|
|
89
|
-
- uses: actions/checkout@
|
|
94
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
90
95
|
with:
|
|
91
96
|
ref: ${{ inputs.ref }}
|
|
97
|
+
persist-credentials: false
|
|
92
98
|
|
|
93
|
-
- uses: actions/setup-python@
|
|
99
|
+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
94
100
|
with:
|
|
95
101
|
python-version: "3.13"
|
|
96
102
|
|
|
97
103
|
- name: Setup Android NDK r26d
|
|
98
|
-
uses: nttld/setup-ndk@v1
|
|
104
|
+
uses: nttld/setup-ndk@ed92fe6cadad69be94a966a7ee3271275e62f779 # v1.6.0
|
|
99
105
|
id: ndk
|
|
100
106
|
with:
|
|
101
107
|
ndk-version: r26d
|
|
102
108
|
link-to-sdk: true
|
|
103
109
|
|
|
104
|
-
- uses: Swatinem/rust-cache@v2
|
|
110
|
+
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
|
|
105
111
|
with:
|
|
106
112
|
key: compile-check-android-aarch64
|
|
107
113
|
|