sarj-standards-bootstrap 1.0.1__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.
- sarj_standards_bootstrap-1.0.1/.gitignore +40 -0
- sarj_standards_bootstrap-1.0.1/LICENSE +21 -0
- sarj_standards_bootstrap-1.0.1/PKG-INFO +40 -0
- sarj_standards_bootstrap-1.0.1/README.md +19 -0
- sarj_standards_bootstrap-1.0.1/pyproject.toml +61 -0
- sarj_standards_bootstrap-1.0.1/src/sarj_standards_bootstrap/__init__.py +6 -0
- sarj_standards_bootstrap-1.0.1/src/sarj_standards_bootstrap/cli.py +189 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
node_modules/
|
|
2
|
+
.astro/
|
|
3
|
+
dist/
|
|
4
|
+
build/
|
|
5
|
+
*.tgz
|
|
6
|
+
.npm/
|
|
7
|
+
*.tsbuildinfo
|
|
8
|
+
.turbo/
|
|
9
|
+
.tsup/
|
|
10
|
+
.vitest-cache/
|
|
11
|
+
.eslintcache
|
|
12
|
+
coverage/
|
|
13
|
+
|
|
14
|
+
__pycache__/
|
|
15
|
+
*.py[co]
|
|
16
|
+
.pytest_cache/
|
|
17
|
+
.ruff_cache/
|
|
18
|
+
.mypy_cache/
|
|
19
|
+
.basedpyright/
|
|
20
|
+
.coverage
|
|
21
|
+
.coverage.*
|
|
22
|
+
htmlcov/
|
|
23
|
+
.tox/
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
.zed/
|
|
33
|
+
*.swp
|
|
34
|
+
|
|
35
|
+
# Claude Code local state (shared settings.json is tracked)
|
|
36
|
+
.claude/*
|
|
37
|
+
!.claude/settings.json
|
|
38
|
+
.worktrees/
|
|
39
|
+
.sarj-private-refs.toml
|
|
40
|
+
.sarj-standards-rollout.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sarj-ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sarj-standards-bootstrap
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Manifest-driven launcher for an exact Sarj Standards bundle.
|
|
5
|
+
Project-URL: Homepage, https://code-standards.sarj.ai/
|
|
6
|
+
Project-URL: Documentation, https://code-standards.sarj.ai/cli/
|
|
7
|
+
Project-URL: Changelog, https://github.com/sarj-ai/standards/releases
|
|
8
|
+
Project-URL: Repository, https://github.com/sarj-ai/standards
|
|
9
|
+
Project-URL: Issues, https://github.com/sarj-ai/standards/issues
|
|
10
|
+
Author: sarj-ai
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
19
|
+
Requires-Python: >=3.14
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
<!-- Generated by `sarj-standards maintain docs sync`; do not edit. -->
|
|
23
|
+
|
|
24
|
+
# sarj-standards-bootstrap
|
|
25
|
+
|
|
26
|
+
Manifest-driven launcher for an exact Sarj Standards bundle.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv tool install sarj-standards-bootstrap
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Generated CI and hooks pin this protocol package exactly; ordinary Standards upgrades change only `.sarj-standards.toml`.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
uvx --no-config --isolated --python 3.14 --from sarj-standards-bootstrap==1.0.1 sarj-standards check
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The bootstrap deliberately inherits UV/PIP registry, proxy, certificate, cache, and offline environment policy. `--no-config --isolated` prevents consumer project configuration and installed tools from changing the selected bootstrap or Standards bundle.
|
|
39
|
+
|
|
40
|
+
[Documentation](https://code-standards.sarj.ai/) · [Source](https://github.com/sarj-ai/standards)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- Generated by `sarj-standards maintain docs sync`; do not edit. -->
|
|
2
|
+
|
|
3
|
+
# sarj-standards-bootstrap
|
|
4
|
+
|
|
5
|
+
Manifest-driven launcher for an exact Sarj Standards bundle.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
uv tool install sarj-standards-bootstrap
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Generated CI and hooks pin this protocol package exactly; ordinary Standards upgrades change only `.sarj-standards.toml`.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uvx --no-config --isolated --python 3.14 --from sarj-standards-bootstrap==1.0.1 sarj-standards check
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The bootstrap deliberately inherits UV/PIP registry, proxy, certificate, cache, and offline environment policy. `--no-config --isolated` prevents consumer project configuration and installed tools from changing the selected bootstrap or Standards bundle.
|
|
18
|
+
|
|
19
|
+
[Documentation](https://code-standards.sarj.ai/) · [Source](https://github.com/sarj-ai/standards)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sarj-standards-bootstrap"
|
|
3
|
+
version = "1.0.1"
|
|
4
|
+
description = "Manifest-driven launcher for an exact Sarj Standards bundle."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
authors = [{ name = "sarj-ai" }]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 5 - Production/Stable",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
16
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
17
|
+
]
|
|
18
|
+
dependencies = []
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
sarj-standards = "sarj_standards_bootstrap:main"
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://code-standards.sarj.ai/"
|
|
25
|
+
Documentation = "https://code-standards.sarj.ai/cli/"
|
|
26
|
+
Changelog = "https://github.com/sarj-ai/standards/releases"
|
|
27
|
+
Repository = "https://github.com/sarj-ai/standards"
|
|
28
|
+
Issues = "https://github.com/sarj-ai/standards/issues"
|
|
29
|
+
|
|
30
|
+
[dependency-groups]
|
|
31
|
+
dev = [
|
|
32
|
+
"basedpyright>=1.39",
|
|
33
|
+
"pytest>=9.0",
|
|
34
|
+
"ruff>=0.16.1",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["hatchling==1.31.0"]
|
|
39
|
+
build-backend = "hatchling.build"
|
|
40
|
+
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
packages = ["src/sarj_standards_bootstrap"]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.sdist]
|
|
45
|
+
include = [
|
|
46
|
+
"src",
|
|
47
|
+
"README.md",
|
|
48
|
+
"LICENSE",
|
|
49
|
+
"pyproject.toml",
|
|
50
|
+
]
|
|
51
|
+
exclude = [
|
|
52
|
+
"tests/",
|
|
53
|
+
"**/__pycache__/",
|
|
54
|
+
"**/*.pyc",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[tool.pytest.ini_options]
|
|
58
|
+
testpaths = ["tests"]
|
|
59
|
+
|
|
60
|
+
[tool.ruff]
|
|
61
|
+
extend = "../../.ruff-strict.toml"
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"""Resolve and execute the exact Standards bundle selected by a repository."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import re
|
|
9
|
+
import shutil
|
|
10
|
+
import subprocess # ruff: ignore[suspicious-subprocess-import] -- Windows cannot replace the current process.
|
|
11
|
+
import sys
|
|
12
|
+
import tomllib
|
|
13
|
+
from typing import TYPE_CHECKING, Final, NoReturn
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from collections.abc import Mapping, Sequence
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
MANIFEST_NAME: Final = ".sarj-standards.toml"
|
|
21
|
+
MANIFEST_SCHEMA: Final = 3
|
|
22
|
+
TOOL_PYTHON: Final = "3.14"
|
|
23
|
+
_VERSION: Final = re.compile(r"(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\Z")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class BootstrapError(ValueError):
|
|
27
|
+
"""A concise consumer-facing bootstrap failure."""
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass(frozen=True, slots=True)
|
|
31
|
+
class ParsedArguments:
|
|
32
|
+
"""Bootstrap-owned root and untouched Standards arguments."""
|
|
33
|
+
|
|
34
|
+
root: Path | None
|
|
35
|
+
forwarded: tuple[str, ...]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def explicit_root(arguments: Sequence[str], *, cwd: Path) -> ParsedArguments:
|
|
39
|
+
"""Remove one optional global root argument from forwarded arguments."""
|
|
40
|
+
root: Path | None = None
|
|
41
|
+
forwarded: list[str] = []
|
|
42
|
+
index = 0
|
|
43
|
+
while index < len(arguments):
|
|
44
|
+
argument = arguments[index]
|
|
45
|
+
if argument == "--":
|
|
46
|
+
forwarded.extend(arguments[index:])
|
|
47
|
+
break
|
|
48
|
+
if argument == "--root":
|
|
49
|
+
if root is not None:
|
|
50
|
+
message = "--root may be specified only once"
|
|
51
|
+
raise BootstrapError(message)
|
|
52
|
+
index += 1
|
|
53
|
+
if index >= len(arguments):
|
|
54
|
+
message = "--root requires a directory"
|
|
55
|
+
raise BootstrapError(message)
|
|
56
|
+
root = (cwd / arguments[index]).resolve()
|
|
57
|
+
elif argument.startswith("--root="):
|
|
58
|
+
if root is not None:
|
|
59
|
+
message = "--root may be specified only once"
|
|
60
|
+
raise BootstrapError(message)
|
|
61
|
+
value = argument.partition("=")[2]
|
|
62
|
+
if not value:
|
|
63
|
+
message = "--root requires a directory"
|
|
64
|
+
raise BootstrapError(message)
|
|
65
|
+
root = (cwd / value).resolve()
|
|
66
|
+
else:
|
|
67
|
+
forwarded.append(argument)
|
|
68
|
+
index += 1
|
|
69
|
+
return ParsedArguments(root, tuple(forwarded))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def find_root(start: Path) -> Path:
|
|
73
|
+
"""Find the nearest manifest at or above the invocation directory."""
|
|
74
|
+
current = start.resolve()
|
|
75
|
+
for candidate in (current, *current.parents):
|
|
76
|
+
if (candidate / MANIFEST_NAME).is_file():
|
|
77
|
+
return candidate
|
|
78
|
+
message = f"no {MANIFEST_NAME} found at or above {current}"
|
|
79
|
+
raise BootstrapError(message)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def table(value: object) -> Mapping[str, object]:
|
|
83
|
+
"""Narrow one untyped TOML document to a string-keyed table."""
|
|
84
|
+
if not isinstance(value, dict):
|
|
85
|
+
message = f"{MANIFEST_NAME} must contain a TOML table"
|
|
86
|
+
raise BootstrapError(message)
|
|
87
|
+
entries: dict[str, object] = {}
|
|
88
|
+
for key, item in value.items(): # pyright: ignore[reportUnknownVariableType]
|
|
89
|
+
if isinstance(key, str):
|
|
90
|
+
entries[key] = item # ruff: ignore[manual-dict-comprehension] — pyright needs explicit narrowing.
|
|
91
|
+
return entries
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def bundle(root: Path) -> str:
|
|
95
|
+
"""Read the exact bundle selected by one repository manifest."""
|
|
96
|
+
manifest = root / MANIFEST_NAME
|
|
97
|
+
try:
|
|
98
|
+
with manifest.open("rb") as stream:
|
|
99
|
+
document: object = tomllib.load(stream)
|
|
100
|
+
except FileNotFoundError as exc:
|
|
101
|
+
message = f"{manifest} does not exist"
|
|
102
|
+
raise BootstrapError(message) from exc
|
|
103
|
+
except OSError as exc:
|
|
104
|
+
message = f"cannot read {manifest}: {exc}"
|
|
105
|
+
raise BootstrapError(message) from exc
|
|
106
|
+
except tomllib.TOMLDecodeError as exc:
|
|
107
|
+
message = f"{manifest} is not valid TOML: {exc}"
|
|
108
|
+
raise BootstrapError(message) from exc
|
|
109
|
+
data = table(document)
|
|
110
|
+
schema = data.get("schema")
|
|
111
|
+
if schema != MANIFEST_SCHEMA:
|
|
112
|
+
message = f"{manifest} schema must equal {MANIFEST_SCHEMA}, got {schema!r}"
|
|
113
|
+
raise BootstrapError(message)
|
|
114
|
+
selected_bundle = data.get("bundle")
|
|
115
|
+
if not isinstance(selected_bundle, str) or _VERSION.fullmatch(selected_bundle) is None:
|
|
116
|
+
message = f"{manifest} bundle must be one exact canonical X.Y.Z release"
|
|
117
|
+
raise BootstrapError(message)
|
|
118
|
+
return selected_bundle
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def command(uvx: str, root: Path, selected_bundle: str, arguments: Sequence[str]) -> tuple[str, ...]:
|
|
122
|
+
"""Build the exact isolated Standards invocation."""
|
|
123
|
+
return (
|
|
124
|
+
uvx,
|
|
125
|
+
"--no-config",
|
|
126
|
+
"--isolated",
|
|
127
|
+
"--python",
|
|
128
|
+
TOOL_PYTHON,
|
|
129
|
+
"--from",
|
|
130
|
+
f"sarj-standards=={selected_bundle}",
|
|
131
|
+
"sarj-standards",
|
|
132
|
+
"--root",
|
|
133
|
+
str(root),
|
|
134
|
+
*arguments,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def execute(exact_command: Sequence[str], environment: Mapping[str, str], *, platform: str = os.name) -> NoReturn:
|
|
139
|
+
"""Transfer control to Standards while preserving its process result on every OS."""
|
|
140
|
+
arguments = tuple(exact_command)
|
|
141
|
+
if platform == "nt":
|
|
142
|
+
completed = subprocess.run( # ruff: ignore[subprocess-without-shell-equals-true] -- fixed argv; no consumer shell.
|
|
143
|
+
arguments,
|
|
144
|
+
env=environment,
|
|
145
|
+
check=False,
|
|
146
|
+
shell=False,
|
|
147
|
+
)
|
|
148
|
+
raise SystemExit(completed.returncode)
|
|
149
|
+
os.execvpe( # ruff: ignore[start-process-with-no-shell] -- POSIX replacement preserves signals and exit status.
|
|
150
|
+
arguments[0],
|
|
151
|
+
arguments,
|
|
152
|
+
dict(environment),
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def run(arguments: Sequence[str], *, cwd: Path) -> NoReturn:
|
|
157
|
+
"""Replace this bootstrap process with the exact Standards process."""
|
|
158
|
+
parsed = explicit_root(arguments, cwd=cwd)
|
|
159
|
+
explicit = parsed.root
|
|
160
|
+
if explicit is not None:
|
|
161
|
+
if not explicit.is_dir():
|
|
162
|
+
message = f"--root {explicit} is not a directory"
|
|
163
|
+
raise BootstrapError(message)
|
|
164
|
+
root = explicit
|
|
165
|
+
else:
|
|
166
|
+
root = find_root(cwd)
|
|
167
|
+
selected_bundle = bundle(root)
|
|
168
|
+
uvx = shutil.which("uvx")
|
|
169
|
+
if uvx is None:
|
|
170
|
+
message = "uvx is required; install uv and retry"
|
|
171
|
+
raise BootstrapError(message)
|
|
172
|
+
exact_command = command(uvx, root, selected_bundle, parsed.forwarded)
|
|
173
|
+
try:
|
|
174
|
+
execute(
|
|
175
|
+
exact_command,
|
|
176
|
+
os.environ.copy(), # ruff: ignore[banned-api] -- inherit registry, certificate, cache, proxy, and offline policy.
|
|
177
|
+
)
|
|
178
|
+
except OSError as exc:
|
|
179
|
+
message = f"could not execute Standards {selected_bundle}: {exc}"
|
|
180
|
+
raise BootstrapError(message) from exc
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
184
|
+
"""Launch the exact Standards bundle declared by the repository."""
|
|
185
|
+
try:
|
|
186
|
+
run(sys.argv[1:] if argv is None else argv, cwd=Path.cwd())
|
|
187
|
+
except BootstrapError as exc:
|
|
188
|
+
sys.stderr.write(f"sarj-standards bootstrap: {exc}\n")
|
|
189
|
+
return 2
|