lean-pkg 0.25.0__py3-none-any.whl
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.
- lean_pkg/__init__.py +3 -0
- lean_pkg/adapters/__init__.py +148 -0
- lean_pkg/adapters/github.py +65 -0
- lean_pkg/adapters/leansearch.py +68 -0
- lean_pkg/adapters/loogle.py +45 -0
- lean_pkg/adapters/palomar.py +170 -0
- lean_pkg/adapters/reservoir.py +127 -0
- lean_pkg/anchor.py +678 -0
- lean_pkg/audit.py +716 -0
- lean_pkg/binding_file.py +446 -0
- lean_pkg/blueprint.py +213 -0
- lean_pkg/build_scope.py +282 -0
- lean_pkg/ci_github.py +917 -0
- lean_pkg/claim_axioms.py +421 -0
- lean_pkg/claims.py +1155 -0
- lean_pkg/claims_mark.py +197 -0
- lean_pkg/cli.py +5208 -0
- lean_pkg/cli_parser.py +768 -0
- lean_pkg/command_tree.py +615 -0
- lean_pkg/comparator_config.py +990 -0
- lean_pkg/comparator_contracts.py +382 -0
- lean_pkg/comparator_receipt.py +2854 -0
- lean_pkg/comparator_stage.py +623 -0
- lean_pkg/comparator_types.py +830 -0
- lean_pkg/container.py +172 -0
- lean_pkg/core.py +1570 -0
- lean_pkg/coverage.py +1278 -0
- lean_pkg/data/stacks/lts-2026.10.yaml +73 -0
- lean_pkg/data/toolchain-advisories.yaml +77 -0
- lean_pkg/data/upgrade-breaking.yaml +20 -0
- lean_pkg/data/verify-workflow-pins.yaml +14 -0
- lean_pkg/deps_closure.py +512 -0
- lean_pkg/deps_fill.py +445 -0
- lean_pkg/dup_constants.py +448 -0
- lean_pkg/exercise.py +828 -0
- lean_pkg/exercise_forbid.py +288 -0
- lean_pkg/export_paths.py +77 -0
- lean_pkg/extract.py +1172 -0
- lean_pkg/extract_decls.py +501 -0
- lean_pkg/extract_ledger.py +1408 -0
- lean_pkg/extract_summary.py +132 -0
- lean_pkg/extract_types.py +502 -0
- lean_pkg/extract_write.py +138 -0
- lean_pkg/formalization.py +1078 -0
- lean_pkg/formalization_kept.py +182 -0
- lean_pkg/fresh_repo.py +709 -0
- lean_pkg/gate.py +2141 -0
- lean_pkg/headline.py +211 -0
- lean_pkg/help_topics.py +442 -0
- lean_pkg/holes.py +289 -0
- lean_pkg/host_routes.py +376 -0
- lean_pkg/hypotheses.py +788 -0
- lean_pkg/index.py +1749 -0
- lean_pkg/json_stdout.py +48 -0
- lean_pkg/lake_hygiene.py +289 -0
- lean_pkg/lean_diag.py +280 -0
- lean_pkg/lean_scan.py +1300 -0
- lean_pkg/ledger.py +582 -0
- lean_pkg/next_step.py +510 -0
- lean_pkg/page.py +1831 -0
- lean_pkg/page_html.py +153 -0
- lean_pkg/palomar.py +316 -0
- lean_pkg/palomar_check.py +1027 -0
- lean_pkg/port_modules.py +677 -0
- lean_pkg/prior_art.py +286 -0
- lean_pkg/producer.py +212 -0
- lean_pkg/producer_skew.py +208 -0
- lean_pkg/public_safety.py +1487 -0
- lean_pkg/publish.py +402 -0
- lean_pkg/rebase.py +984 -0
- lean_pkg/receipt.py +2385 -0
- lean_pkg/receipt_check.py +1064 -0
- lean_pkg/receipt_ci.py +660 -0
- lean_pkg/receipt_systemd.py +890 -0
- lean_pkg/recommended.py +232 -0
- lean_pkg/report.py +727 -0
- lean_pkg/reservoir.py +203 -0
- lean_pkg/scaffold.py +588 -0
- lean_pkg/schemas/formalization-0.4.schema.json +344 -0
- lean_pkg/schemas/formalization-0.4.schema.source.txt +15 -0
- lean_pkg/scripts/ClaimAxioms.lean +47 -0
- lean_pkg/scripts/ContractsOnly.lean +300 -0
- lean_pkg/scripts/DupConstants.lean +149 -0
- lean_pkg/scripts/HypProbe.lean +257 -0
- lean_pkg/scripts/comparator-check.sh +396 -0
- lean_pkg/scripts/verify-comparator.sh +135 -0
- lean_pkg/seal_bundle.py +647 -0
- lean_pkg/search.py +865 -0
- lean_pkg/site_profiles/easley.yaml +10 -0
- lean_pkg/site_profiles/github-actions.yaml +12 -0
- lean_pkg/sites.py +225 -0
- lean_pkg/stacks.py +373 -0
- lean_pkg/statements_module.py +217 -0
- lean_pkg/templates/Apache-2.0.txt +202 -0
- lean_pkg/toolchain_advisories.py +225 -0
- lean_pkg/upgrade.py +706 -0
- lean_pkg/verify.py +495 -0
- lean_pkg-0.25.0.dist-info/METADATA +93 -0
- lean_pkg-0.25.0.dist-info/RECORD +103 -0
- lean_pkg-0.25.0.dist-info/WHEEL +5 -0
- lean_pkg-0.25.0.dist-info/entry_points.txt +5 -0
- lean_pkg-0.25.0.dist-info/licenses/LICENSE +202 -0
- lean_pkg-0.25.0.dist-info/top_level.txt +1 -0
lean_pkg/reservoir.py
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# lean-pkg reservoir -- would Reservoir list this package?
|
|
2
|
+
"""`lean-pkg reservoir check NAME [--offline]` (#22.2): read-only static checks of the
|
|
3
|
+
documented Reservoir listing criteria (docs/faq.md#reservoir): public on GitHub, not a
|
|
4
|
+
fork, at least 2 stars, `lake-manifest.json` at the root, an OSI license GitHub can
|
|
5
|
+
detect, a Lake package that has not opted out (`reservoir := false`), and the lakefile
|
|
6
|
+
metadata Reservoir displays (`description`, `keywords`, `versionTags`). Then, unless
|
|
7
|
+
--offline, whether Reservoir's package API already lists it, with the `record` command
|
|
8
|
+
to run when it does. Nothing is written; lean-pkg never records the listing by itself.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import re
|
|
15
|
+
|
|
16
|
+
from . import cli
|
|
17
|
+
from . import core
|
|
18
|
+
from . import publish as publish_mod
|
|
19
|
+
|
|
20
|
+
MIN_STARS = 2
|
|
21
|
+
DISPLAY_KEYS = ("description", "keywords", "versionTags")
|
|
22
|
+
OPT_OUT_RE = re.compile(r"^\s*reservoir\s*(?::=|=)\s*false\b", re.MULTILINE)
|
|
23
|
+
PENDING = "pending promote: " # #23.3: a GitHub-dependent item that `promote --yes` will satisfy
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def lakefile_text(repo) -> tuple[str | None, str]:
|
|
27
|
+
for name in ("lakefile.lean", "lakefile.toml"):
|
|
28
|
+
try:
|
|
29
|
+
return name, (repo / name).read_text(encoding="utf-8", errors="replace")
|
|
30
|
+
except OSError:
|
|
31
|
+
continue
|
|
32
|
+
return None, ""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def pre_promote(pkg: dict) -> bool:
|
|
36
|
+
"""Not public yet: GitHub-dependent items are reported as pending promote (#23.3)."""
|
|
37
|
+
return pkg.get("status") not in publish_mod.ALREADY_PUBLIC
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def github_items(pkg: dict, nwo: str | None) -> list[tuple[str, str]]:
|
|
41
|
+
name, pending = pkg["name"], pre_promote(pkg)
|
|
42
|
+
if not nwo:
|
|
43
|
+
if pending:
|
|
44
|
+
return [("✗", f"{PENDING}repo {pkg.get('repo')!r} is not a GitHub URL yet (Reservoir indexes "
|
|
45
|
+
f"GitHub repositories); create the GitHub repository, point the registry at it "
|
|
46
|
+
f"(`lean-pkg update {name} --url git@github.com:OWNER/REPO.git`), then "
|
|
47
|
+
f"`lean-pkg promote {name} --yes` makes it public")]
|
|
48
|
+
return [("✗", f"repo {pkg.get('repo')!r} is not on GitHub (Reservoir indexes GitHub repositories)")]
|
|
49
|
+
p = core.gh("repo", "view", nwo, "--json", "visibility,isFork,stargazerCount")
|
|
50
|
+
try:
|
|
51
|
+
info = json.loads(p.stdout) if p.returncode == 0 else None
|
|
52
|
+
except ValueError:
|
|
53
|
+
info = None
|
|
54
|
+
if not isinstance(info, dict):
|
|
55
|
+
err = ((p.stderr or p.stdout or "").strip().splitlines() or ["no output"])[0]
|
|
56
|
+
if pending:
|
|
57
|
+
return [("✗", f"{PENDING}gh query for {nwo} failed ({err}); the GitHub repository must exist "
|
|
58
|
+
f"before `lean-pkg promote {name} --yes` makes it public")]
|
|
59
|
+
return [("WARN", f"gh query for {nwo} failed ({err}); visibility, fork and stars not checked")]
|
|
60
|
+
items = []
|
|
61
|
+
vis = str(info.get("visibility", "")).lower()
|
|
62
|
+
if vis == "public":
|
|
63
|
+
items.append(("✓", f"{nwo} is public"))
|
|
64
|
+
elif pending:
|
|
65
|
+
items.append(("✗", f"{PENDING}{nwo} is {vis or 'of unknown visibility'}; "
|
|
66
|
+
f"`lean-pkg promote {name} --yes` makes it public (Reservoir lists public "
|
|
67
|
+
f"repositories)"))
|
|
68
|
+
else:
|
|
69
|
+
items.append(("✗", f"{nwo} is {vis or 'of unknown visibility'} (Reservoir lists public repositories; "
|
|
70
|
+
f"`lean-pkg promote {name}`)"))
|
|
71
|
+
if "isFork" in info:
|
|
72
|
+
items.append(("✗", f"{nwo} is a fork (a 'Use this template' repository counts as one); Reservoir "
|
|
73
|
+
f"skips forks") if info["isFork"] else ("✓", "not a fork"))
|
|
74
|
+
if "stargazerCount" in info:
|
|
75
|
+
stars = int(info.get("stargazerCount") or 0)
|
|
76
|
+
items.append(("✓", f"{stars} star(s)") if stars >= MIN_STARS else
|
|
77
|
+
("✗", f"{stars} star(s); Reservoir needs at least {MIN_STARS}"))
|
|
78
|
+
return items
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def lakefile_items(pkg: dict, repo) -> list[tuple[str, str]]:
|
|
82
|
+
name, text = lakefile_text(repo)
|
|
83
|
+
if name is None:
|
|
84
|
+
return [("✗", "no lakefile.lean or lakefile.toml at the repo root")]
|
|
85
|
+
items = []
|
|
86
|
+
lake_name = publish_mod.lakefile_package_name(repo)
|
|
87
|
+
items.append(("✓", f"{name}: package {lake_name}") if lake_name else
|
|
88
|
+
("✗", f"{name}: no package name"))
|
|
89
|
+
if OPT_OUT_RE.search(text):
|
|
90
|
+
items.append(("✗", f"{name} sets reservoir false: the package opted out of Reservoir"))
|
|
91
|
+
missing = [k for k in DISPLAY_KEYS if not re.search(rf"^\s*{k}\s*(?::=|=)", text, re.MULTILINE)]
|
|
92
|
+
if missing:
|
|
93
|
+
items.append(("WARN", f"{name} has no {', '.join(missing)} (what Reservoir displays and searches)"))
|
|
94
|
+
else:
|
|
95
|
+
items.append(("✓", f"{name} sets {', '.join(DISPLAY_KEYS)}"))
|
|
96
|
+
return items
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def repo_items(pkg: dict, repo) -> list[tuple[str, str]]:
|
|
100
|
+
items = []
|
|
101
|
+
for rel, why in (("lake-manifest.json", "Reservoir requires a root manifest"),
|
|
102
|
+
("lean-toolchain", "Reservoir builds on the declared toolchain")):
|
|
103
|
+
items.append(("✓", f"{rel} tracked at HEAD") if core.tracked_at(repo, rel) else
|
|
104
|
+
("✗", f"{rel} not tracked at HEAD ({why})"))
|
|
105
|
+
if any((repo / f).is_file() for f in core.LICENSE_NAMES):
|
|
106
|
+
items += publish_mod.license_items(pkg, repo)
|
|
107
|
+
else:
|
|
108
|
+
items.append(("✗", "no LICENSE/COPYING at the repo root (Reservoir needs a GitHub-detected OSI license)"))
|
|
109
|
+
items.append(toolchain_item(repo))
|
|
110
|
+
tags = publish_mod.tags_at_head(repo)
|
|
111
|
+
items.append(("✓", f"tag at HEAD: {', '.join(tags)}") if tags else
|
|
112
|
+
("WARN", "no tag at HEAD (versionTags select the versions Reservoir shows)"))
|
|
113
|
+
return items
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def toolchain_item(repo) -> tuple[str, str]:
|
|
117
|
+
"""#23.3: Reservoir builds and shows the declared toolchain; a release candidate or a nightly may be
|
|
118
|
+
displayed poorly, so it is a WARN (never a refusal)."""
|
|
119
|
+
try:
|
|
120
|
+
tc = (repo / "lean-toolchain").read_text(encoding="utf-8").strip()
|
|
121
|
+
except OSError:
|
|
122
|
+
return ("WARN", "lean-toolchain unreadable; release check skipped")
|
|
123
|
+
low = tc.lower()
|
|
124
|
+
if "nightly" in low or re.search(r"-rc\d*\b", low):
|
|
125
|
+
kind = "a nightly" if "nightly" in low else "a release candidate"
|
|
126
|
+
return ("WARN", f"lean-toolchain {tc} is {kind}; Reservoir may display it poorly "
|
|
127
|
+
f"(prefer a release toolchain for the listed tag)")
|
|
128
|
+
return ("✓", f"lean-toolchain {tc} is a release")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def listing_item(pkg: dict, nwo: str | None, offline: bool,
|
|
132
|
+
pending: bool = False) -> tuple[tuple[str, str], str | None]:
|
|
133
|
+
"""(item, the record command to run when listed and not yet recorded). pending: the repository is
|
|
134
|
+
not public yet and promote will make it so (#23.3)."""
|
|
135
|
+
if offline or not nwo:
|
|
136
|
+
return ("WARN", "Reservoir listing not queried" + (" (--offline)" if offline else "")), None
|
|
137
|
+
owner, name = nwo.split("/", 1)
|
|
138
|
+
code = core.reservoir_listing_status(owner, name)
|
|
139
|
+
url = f"https://reservoir.lean-lang.org/@{owner}/{name}"
|
|
140
|
+
if code == 200:
|
|
141
|
+
cmd = None if pkg.get("reservoir") else \
|
|
142
|
+
f"lean-pkg record {pkg['name']} reservoir-listed --field url={url}"
|
|
143
|
+
return ("✓", f"listed on Reservoir: {url}" + ("" if cmd else " (recorded)")), cmd
|
|
144
|
+
if code == 404 and pending:
|
|
145
|
+
return ("WARN", f"{PENDING}not listed on Reservoir ({url} API: 404); Reservoir lists public "
|
|
146
|
+
f"repositories and {pkg['name']} is {pkg.get('status')}"), None
|
|
147
|
+
if code == 404:
|
|
148
|
+
return ("WARN", f"not listed on Reservoir yet ({url} API: 404); indexing runs periodically"), None
|
|
149
|
+
return ("WARN", f"Reservoir unreachable (HTTP {code}); listing skipped" if code else
|
|
150
|
+
"Reservoir unreachable; listing skipped"), None
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def do_reservoir_check(reg: dict, name: str, offline: bool) -> tuple[list[str], int, dict]:
|
|
154
|
+
pkg = core.get_pkg(reg, name)
|
|
155
|
+
repo = core.repo_path(pkg)
|
|
156
|
+
if not repo.is_dir() or core.git_head(repo) is None:
|
|
157
|
+
raise core.Fail(f"{name}: the git checkout {repo} does not exist")
|
|
158
|
+
nwo = core.gh_nwo(pkg.get("repo") or "")
|
|
159
|
+
gh_items = github_items(pkg, nwo)
|
|
160
|
+
items = gh_items + repo_items(pkg, repo) + lakefile_items(pkg, repo)
|
|
161
|
+
listed, cmd = listing_item(pkg, nwo, offline, pending=any(i[1].startswith(PENDING) for i in gh_items))
|
|
162
|
+
items.append(listed)
|
|
163
|
+
eligible = not any(i[0] == "✗" for i in items)
|
|
164
|
+
pending = [label for _m, label in items if label.startswith(PENDING)]
|
|
165
|
+
lines = [f"reservoir check for {name}:"] + [f" {m} {label}" for m, label in items]
|
|
166
|
+
others = sum(1 for m, label in items if m == "✗" and not label.startswith(PENDING))
|
|
167
|
+
lines.append("eligible: Reservoir's listing criteria are met" if eligible else
|
|
168
|
+
"not eligible yet (pre-promote): publish --yes will satisfy the ✗ items above"
|
|
169
|
+
if pending and not others else "not eligible: fix every ✗ above")
|
|
170
|
+
if pending:
|
|
171
|
+
lines.append(f"pre-promote: {name} is {pkg.get('status')}; {len(pending)} GitHub-dependent item(s) "
|
|
172
|
+
f"pending promote (`lean-pkg promote {name} --yes`, one-way, makes the repository "
|
|
173
|
+
f"public, which they need)" + (f"; {others} other ✗ to fix first" if others else ""))
|
|
174
|
+
if cmd:
|
|
175
|
+
lines.append(f"next: {cmd}")
|
|
176
|
+
payload = {"ok": eligible, "name": name, "eligible": eligible,
|
|
177
|
+
"checklist": [{"status": cli._MARK_TO_STATUS[m], "label": label} for m, label in items],
|
|
178
|
+
"record": cmd, "pre_promote": pre_promote(pkg), "pending_promote": pending}
|
|
179
|
+
return lines, 0 if eligible else 1, payload
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def cmd_reservoir(args) -> int:
|
|
183
|
+
if getattr(args, "reservoir_cmd", None) != "check":
|
|
184
|
+
raise core.UsageError("usage: lean-pkg reservoir check NAME [--offline]")
|
|
185
|
+
lines, rc, payload = do_reservoir_check(core.load_registry(core.registry_path(args)), args.name,
|
|
186
|
+
args.offline)
|
|
187
|
+
if getattr(args, "json_out", False):
|
|
188
|
+
core.print_json(payload)
|
|
189
|
+
else:
|
|
190
|
+
print("\n".join(lines))
|
|
191
|
+
return rc
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def add_parsers(sub, add_json) -> None:
|
|
195
|
+
s = sub.add_parser("reservoir", help="Reservoir: check (read-only listing criteria)")
|
|
196
|
+
add_json(s)
|
|
197
|
+
s.set_defaults(fn=cmd_reservoir, reservoir_cmd=None)
|
|
198
|
+
rsub = s.add_subparsers(dest="reservoir_cmd")
|
|
199
|
+
c = rsub.add_parser("check", help="would Reservoir list this package? read-only; exit 0 eligible / 1 not")
|
|
200
|
+
c.add_argument("name")
|
|
201
|
+
c.add_argument("--offline", action="store_true", help="do not query Reservoir's package API")
|
|
202
|
+
add_json(c)
|
|
203
|
+
c.set_defaults(fn=cmd_reservoir)
|