enchi 0.8.0__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.
enchi-0.8.0/.gitignore ADDED
@@ -0,0 +1,58 @@
1
+ /target/
2
+ /dist/
3
+ /python-package/dist/
4
+ /python-package-legacy/dist/
5
+ /packaging/homebrew/Formula/
6
+ /python-package/src/**/*.pyc
7
+ /python-package/tests/**/*.pyc
8
+ /python-package-legacy/src/**/*.pyc
9
+ /python-package-legacy/tests/**/*.pyc
10
+ **/__pycache__/
11
+ /.tmp*/
12
+ /test-install/
13
+
14
+ # Compiled binaries and debug symbols
15
+ *.exe
16
+ *.pdb
17
+
18
+ # AI Memory & Interaction artifacts
19
+ MEMORY.md
20
+ .gemini/
21
+ /walkthrough.md
22
+ /implementation_plan.md
23
+ /task.md
24
+ /analysis_results.md
25
+ /research_notes.md
26
+ /experiment_results.md
27
+
28
+ # IDEs
29
+ .vscode/
30
+ .idea/
31
+
32
+ # Rust (Commit Cargo.lock for reproducible builds in apps)
33
+ # Cargo.lock
34
+
35
+ # Tauri & GUI
36
+ crates/enchi-gui/src-tauri/target/
37
+ crates/enchi-gui/target/
38
+
39
+ # Python Virtual Environments
40
+ /venv/
41
+ /.venv/
42
+ /env/
43
+
44
+ # OS Junk
45
+ .DS_Store
46
+ Thumbs.db
47
+
48
+ # Local publish script (operator-only, not for distribution)
49
+ /scripts/publish.ps1
50
+
51
+ # Reproduction and scratch scripts
52
+ /repro_*.rs
53
+ /temp_*.rs
54
+ /clippy_errors.txt
55
+ *.tmp
56
+ /scripts/wcagate/node_modules/
57
+ /scripts/wcagate/wcag-audit/
58
+ /scripts/gui-a11y/node_modules/
enchi-0.8.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roy Dawson IV
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.
enchi-0.8.0/PKG-INFO ADDED
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.5
2
+ Name: enchi
3
+ Version: 0.8.0
4
+ Summary: Python install package for the native Enchi release bundles (formerly pyenv-native).
5
+ Project-URL: Homepage, https://github.com/imyourboyroy
6
+ Project-URL: Repository, https://github.com/imyourboyroy/pyenv-native
7
+ Project-URL: Issues, https://github.com/imyourboyroy/pyenv-native/issues
8
+ Author-email: Roy Dawson IV <Roy.Dawson.IV@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: bootstrap,enchi,pipx,pyenv,python,windows
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Operating System :: Microsoft :: Windows
18
+ Classifier: Operating System :: POSIX
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: Python :: 3.8
22
+ Classifier: Programming Language :: Python :: 3.9
23
+ Classifier: Programming Language :: Python :: 3.10
24
+ Classifier: Programming Language :: Python :: 3.11
25
+ Classifier: Programming Language :: Python :: 3.12
26
+ Classifier: Programming Language :: Python :: 3.13
27
+ Classifier: Programming Language :: Python :: 3.14
28
+ Classifier: Programming Language :: Python :: 3.15
29
+ Classifier: Topic :: Software Development
30
+ Classifier: Topic :: System :: Installation/Setup
31
+ Requires-Python: >=3.8
32
+ Description-Content-Type: text/markdown
33
+
34
+ # enchi (Python install package)
35
+
36
+ ![PyPI Channel](https://img.shields.io/badge/channel-PyPI%20%2F%20pipx-3775A9?style=for-the-badge&logo=pypi&logoColor=white)
37
+ ![Runtime](https://img.shields.io/badge/runtime-install%20package%20for%20native%20bundles-2563eb?style=for-the-badge)
38
+ ![License](https://img.shields.io/badge/license-MIT-15803D?style=for-the-badge)
39
+
40
+ `enchi` on PyPI is the Python convenience package for installing the native Enchi release bundles.
41
+ Enchi was called `pyenv-native` before; the `pyenv-native` PyPI package is now a thin wrapper that
42
+ depends on this one.
43
+
44
+ Those bundles install:
45
+ - `enchi` (the CLI)
46
+ - `enchi-mcp` (the MCP server for coding agents)
47
+ - `enchi-gui` (desktop builds)
48
+
49
+ It exists for users who:
50
+ - already have Python installed,
51
+ - want a `pip` or `pipx` entrypoint,
52
+ - still want the real runtime to remain native.
53
+
54
+ The console script this package adds is **`enchi-bootstrap`**, not `enchi`, so it never shadows the
55
+ real `enchi` binary the bundle installs.
56
+
57
+ ## Important principle
58
+
59
+ > This package installs Enchi.
60
+ > It does **not** replace Enchi with a Python implementation.
61
+
62
+ ## Release selection behavior
63
+
64
+ By default, the package targets the **latest published GitHub release**.
65
+
66
+ ## What it does
67
+
68
+ - downloads native release bundles (`enchi-<platform>-<arch>`),
69
+ - verifies checksums,
70
+ - reads bundle metadata,
71
+ - extracts the bundle,
72
+ - runs the bundled installer (`enchi self-install`),
73
+ - installs the companion `enchi-mcp` server when the bundle provides it,
74
+ - supports GitHub Release-based installs,
75
+ - works with Windows ZIP bundles and Linux/macOS `.tar.gz` bundles.
76
+
77
+ Where the install goes is decided by `enchi self-install`: a fresh install uses `~/.enchi`, and an
78
+ existing pyenv-native install keeps its `~/.pyenv` root. Pass `--install-root` to choose one.
79
+
80
+ ## Quick start
81
+
82
+ ### `pipx` latest release
83
+
84
+ ```powershell
85
+ pipx install enchi
86
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native
87
+ ```
88
+
89
+ ### `pip` latest release
90
+
91
+ ```powershell
92
+ python -m pip install enchi
93
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native
94
+ ```
95
+
96
+ ### POSIX latest release
97
+
98
+ ```sh
99
+ python -m pip install enchi
100
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native
101
+ ```
102
+
103
+ (`imyourboyroy/pyenv-native` is the GitHub repository that publishes the releases; it keeps that
104
+ name until the repository itself is renamed.)
105
+
106
+ ## Commands
107
+
108
+ ```text
109
+ enchi-bootstrap verify <bundle-archive> [--checksum-path <bundle.sha256>]
110
+ enchi-bootstrap download [--bundle-url <url> | --release-base-url <url> | --github-repo <owner/repo>] [--tag <tag>]
111
+ enchi-bootstrap install [--bundle-path <bundle-archive> | --release-base-url <url> | --github-repo <owner/repo>] [--tag <tag>] [--install-root <dir>]
112
+ ```
113
+
114
+ `python -m enchi_bootstrap` runs the same commands.
115
+
116
+ Environment variables: `ENCHI_BOOTSTRAP_RELEASE_BASE_URL` and `ENCHI_BOOTSTRAP_GITHUB_REPO` supply
117
+ the download source. The earlier `PYENV_NATIVE_BOOTSTRAP_*` names are still read as a fallback.
118
+
119
+ ## Examples
120
+
121
+ Verify a local bundle:
122
+
123
+ ```powershell
124
+ enchi-bootstrap verify .\dist\enchi-windows-x64.zip --checksum-path .\dist\enchi-windows-x64.zip.sha256
125
+ ```
126
+
127
+ Install from a local bundle:
128
+
129
+ ```powershell
130
+ enchi-bootstrap install --bundle-path .\dist\enchi-windows-x64.zip --checksum-path .\dist\enchi-windows-x64.zip.sha256
131
+ ```
132
+
133
+ Install from the latest GitHub release into a chosen root:
134
+
135
+ ```powershell
136
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native --install-root ~\.enchi
137
+ ```
138
+
139
+ Install a POSIX bundle:
140
+
141
+ ```sh
142
+ enchi-bootstrap install --bundle-path ./dist/enchi-linux-x64.tar.gz --checksum-path ./dist/enchi-linux-x64.tar.gz.sha256 --shell bash
143
+ ```
144
+
145
+ Releases published before the rename only carry `pyenv-native-<platform>-<arch>` bundles. When a
146
+ release has no `enchi-…` bundle, the GitHub download falls back to that name.
147
+
148
+ ## Relationship to the main project
149
+
150
+ For the full project overview, install scripts, release-bundle flow, and command reference, see the main repository README:
151
+
152
+ - <https://github.com/imyourboyroy/pyenv-native>
enchi-0.8.0/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # enchi (Python install package)
2
+
3
+ ![PyPI Channel](https://img.shields.io/badge/channel-PyPI%20%2F%20pipx-3775A9?style=for-the-badge&logo=pypi&logoColor=white)
4
+ ![Runtime](https://img.shields.io/badge/runtime-install%20package%20for%20native%20bundles-2563eb?style=for-the-badge)
5
+ ![License](https://img.shields.io/badge/license-MIT-15803D?style=for-the-badge)
6
+
7
+ `enchi` on PyPI is the Python convenience package for installing the native Enchi release bundles.
8
+ Enchi was called `pyenv-native` before; the `pyenv-native` PyPI package is now a thin wrapper that
9
+ depends on this one.
10
+
11
+ Those bundles install:
12
+ - `enchi` (the CLI)
13
+ - `enchi-mcp` (the MCP server for coding agents)
14
+ - `enchi-gui` (desktop builds)
15
+
16
+ It exists for users who:
17
+ - already have Python installed,
18
+ - want a `pip` or `pipx` entrypoint,
19
+ - still want the real runtime to remain native.
20
+
21
+ The console script this package adds is **`enchi-bootstrap`**, not `enchi`, so it never shadows the
22
+ real `enchi` binary the bundle installs.
23
+
24
+ ## Important principle
25
+
26
+ > This package installs Enchi.
27
+ > It does **not** replace Enchi with a Python implementation.
28
+
29
+ ## Release selection behavior
30
+
31
+ By default, the package targets the **latest published GitHub release**.
32
+
33
+ ## What it does
34
+
35
+ - downloads native release bundles (`enchi-<platform>-<arch>`),
36
+ - verifies checksums,
37
+ - reads bundle metadata,
38
+ - extracts the bundle,
39
+ - runs the bundled installer (`enchi self-install`),
40
+ - installs the companion `enchi-mcp` server when the bundle provides it,
41
+ - supports GitHub Release-based installs,
42
+ - works with Windows ZIP bundles and Linux/macOS `.tar.gz` bundles.
43
+
44
+ Where the install goes is decided by `enchi self-install`: a fresh install uses `~/.enchi`, and an
45
+ existing pyenv-native install keeps its `~/.pyenv` root. Pass `--install-root` to choose one.
46
+
47
+ ## Quick start
48
+
49
+ ### `pipx` latest release
50
+
51
+ ```powershell
52
+ pipx install enchi
53
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native
54
+ ```
55
+
56
+ ### `pip` latest release
57
+
58
+ ```powershell
59
+ python -m pip install enchi
60
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native
61
+ ```
62
+
63
+ ### POSIX latest release
64
+
65
+ ```sh
66
+ python -m pip install enchi
67
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native
68
+ ```
69
+
70
+ (`imyourboyroy/pyenv-native` is the GitHub repository that publishes the releases; it keeps that
71
+ name until the repository itself is renamed.)
72
+
73
+ ## Commands
74
+
75
+ ```text
76
+ enchi-bootstrap verify <bundle-archive> [--checksum-path <bundle.sha256>]
77
+ enchi-bootstrap download [--bundle-url <url> | --release-base-url <url> | --github-repo <owner/repo>] [--tag <tag>]
78
+ enchi-bootstrap install [--bundle-path <bundle-archive> | --release-base-url <url> | --github-repo <owner/repo>] [--tag <tag>] [--install-root <dir>]
79
+ ```
80
+
81
+ `python -m enchi_bootstrap` runs the same commands.
82
+
83
+ Environment variables: `ENCHI_BOOTSTRAP_RELEASE_BASE_URL` and `ENCHI_BOOTSTRAP_GITHUB_REPO` supply
84
+ the download source. The earlier `PYENV_NATIVE_BOOTSTRAP_*` names are still read as a fallback.
85
+
86
+ ## Examples
87
+
88
+ Verify a local bundle:
89
+
90
+ ```powershell
91
+ enchi-bootstrap verify .\dist\enchi-windows-x64.zip --checksum-path .\dist\enchi-windows-x64.zip.sha256
92
+ ```
93
+
94
+ Install from a local bundle:
95
+
96
+ ```powershell
97
+ enchi-bootstrap install --bundle-path .\dist\enchi-windows-x64.zip --checksum-path .\dist\enchi-windows-x64.zip.sha256
98
+ ```
99
+
100
+ Install from the latest GitHub release into a chosen root:
101
+
102
+ ```powershell
103
+ enchi-bootstrap install --github-repo imyourboyroy/pyenv-native --install-root ~\.enchi
104
+ ```
105
+
106
+ Install a POSIX bundle:
107
+
108
+ ```sh
109
+ enchi-bootstrap install --bundle-path ./dist/enchi-linux-x64.tar.gz --checksum-path ./dist/enchi-linux-x64.tar.gz.sha256 --shell bash
110
+ ```
111
+
112
+ Releases published before the rename only carry `pyenv-native-<platform>-<arch>` bundles. When a
113
+ release has no `enchi-…` bundle, the GitHub download falls back to that name.
114
+
115
+ ## Relationship to the main project
116
+
117
+ For the full project overview, install scripts, release-bundle flow, and command reference, see the main repository README:
118
+
119
+ - <https://github.com/imyourboyroy/pyenv-native>
@@ -0,0 +1,59 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.33.0"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "enchi"
7
+ version = "0.8.0"
8
+ description = "Python install package for the native Enchi release bundles (formerly pyenv-native)."
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Roy Dawson IV", email = "Roy.Dawson.IV@gmail.com" },
14
+ ]
15
+ keywords = ["enchi", "pyenv", "python", "windows", "bootstrap", "pipx"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: Microsoft :: Windows",
22
+ "Operating System :: POSIX",
23
+ "Operating System :: MacOS",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.8",
27
+ "Programming Language :: Python :: 3.9",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Programming Language :: Python :: 3.13",
32
+ "Programming Language :: Python :: 3.14",
33
+ "Programming Language :: Python :: 3.15",
34
+ "Topic :: Software Development",
35
+ "Topic :: System :: Installation/Setup",
36
+ ]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/imyourboyroy"
40
+ Repository = "https://github.com/imyourboyroy/pyenv-native"
41
+ Issues = "https://github.com/imyourboyroy/pyenv-native/issues"
42
+
43
+ [project.scripts]
44
+ enchi-bootstrap = "enchi_bootstrap.cli:main"
45
+
46
+ [tool.hatch.build.targets.wheel]
47
+ packages = ["src/enchi_bootstrap"]
48
+
49
+ [tool.hatch.build.targets.sdist]
50
+ include = [
51
+ "src/enchi_bootstrap",
52
+ "tests",
53
+ "LICENSE",
54
+ "README.md",
55
+ "pyproject.toml",
56
+ ]
57
+
58
+
59
+
@@ -0,0 +1,6 @@
1
+ # ./python-package/src/enchi_bootstrap/__init__.py
2
+ """Package metadata for the Enchi bootstrap helper."""
3
+
4
+ __all__ = ["__version__"]
5
+
6
+ __version__ = "0.8.0"
@@ -0,0 +1,8 @@
1
+ # ./python-package/src/enchi_bootstrap/__main__.py
2
+ """Module runner for `python -m enchi_bootstrap`."""
3
+
4
+ from .cli import main
5
+
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(main())
@@ -0,0 +1,171 @@
1
+ # ./python-package/src/enchi_bootstrap/bundle.py
2
+ """Bundle metadata, checksum, and download helpers for Enchi release assets."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import hashlib
7
+ import json
8
+ import tarfile
9
+ import urllib.request
10
+ from dataclasses import dataclass
11
+ from pathlib import Path
12
+ from typing import Optional
13
+ from zipfile import ZipFile
14
+
15
+ from . import __version__
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class BundleManifest:
20
+ """Describes a built release bundle.
21
+
22
+ Current bundles install through the bundled binary (`<executable> self-install`) and carry no
23
+ scripts. Bundles published before that change name `install_script`/`uninstall_script`
24
+ instead; both are optional so either generation can be installed. Bundles that also carry a
25
+ `pyenv`-named copy of the CLI (the legacy-compat archives) name it in `legacy_executable`.
26
+ """
27
+
28
+ bundle_name: str
29
+ bundle_version: str
30
+ platform: str
31
+ architecture: str
32
+ executable: str
33
+ install_script: Optional[str] = None
34
+ uninstall_script: Optional[str] = None
35
+ legacy_executable: Optional[str] = None
36
+
37
+
38
+ def sha256_file(path: Path) -> str:
39
+ """Return the SHA-256 digest for a file."""
40
+
41
+ digest = hashlib.sha256()
42
+ with path.open("rb") as handle:
43
+ for chunk in iter(lambda: handle.read(1024 * 1024), b""):
44
+ digest.update(chunk)
45
+ return digest.hexdigest()
46
+
47
+
48
+ def parse_checksum_text(text: str, expected_file_name: Optional[str] = None) -> str:
49
+ """Extract a SHA-256 value from a checksum file or raw string."""
50
+
51
+ lines = [line.strip() for line in text.splitlines() if line.strip()]
52
+ if not lines:
53
+ raise ValueError("checksum text did not contain any usable lines")
54
+
55
+ for line in lines:
56
+ parts = line.split()
57
+ if len(parts) == 1 and len(parts[0]) == 64:
58
+ return parts[0].lower()
59
+ if len(parts) >= 2 and len(parts[0]) == 64:
60
+ candidate_name = parts[-1].lstrip("*")
61
+ if expected_file_name is None or candidate_name == expected_file_name:
62
+ return parts[0].lower()
63
+
64
+ raise ValueError("checksum text did not contain a valid SHA-256 entry")
65
+
66
+
67
+ def is_tar_bundle(bundle_path: Path) -> bool:
68
+ """Return true when a bundle path uses a tar-based archive format."""
69
+
70
+ suffixes = [suffix.lower() for suffix in bundle_path.suffixes]
71
+ return suffixes[-2:] == [".tar", ".gz"] or bundle_path.suffix.lower() == ".tgz"
72
+
73
+
74
+ def read_manifest_from_bundle(bundle_path: Path) -> BundleManifest:
75
+ """Read and parse the bundle manifest embedded inside a release archive."""
76
+
77
+ if is_tar_bundle(bundle_path):
78
+ with tarfile.open(bundle_path, "r:*") as archive:
79
+ member = next(
80
+ (
81
+ candidate
82
+ for candidate in archive.getmembers()
83
+ if Path(candidate.name).name == "bundle-manifest.json"
84
+ ),
85
+ None,
86
+ )
87
+ if member is None:
88
+ raise FileNotFoundError("bundle-manifest.json was not found in the bundle archive")
89
+ handle = archive.extractfile(member)
90
+ if handle is None:
91
+ raise FileNotFoundError("bundle-manifest.json could not be extracted")
92
+ payload = json.loads(handle.read().decode("utf-8-sig"))
93
+ else:
94
+ with ZipFile(bundle_path, "r") as archive:
95
+ with archive.open("bundle-manifest.json", "r") as handle:
96
+ payload = json.loads(handle.read().decode("utf-8-sig"))
97
+
98
+ return BundleManifest(
99
+ bundle_name=payload["bundle_name"],
100
+ bundle_version=payload["bundle_version"],
101
+ platform=payload["platform"],
102
+ architecture=payload["architecture"],
103
+ executable=payload["executable"],
104
+ install_script=payload.get("install_script"),
105
+ uninstall_script=payload.get("uninstall_script"),
106
+ legacy_executable=payload.get("legacy_executable"),
107
+ )
108
+
109
+
110
+ def read_manifest_from_zip(bundle_path: Path) -> BundleManifest:
111
+ """Backward-compatible wrapper for zip-based bundle manifest reads."""
112
+
113
+ return read_manifest_from_bundle(bundle_path)
114
+
115
+
116
+ def download_file(url: str, destination: Path) -> Path:
117
+ """Download a file to a destination path, replacing any prior file."""
118
+
119
+ destination.parent.mkdir(parents=True, exist_ok=True)
120
+ request = urllib.request.Request(
121
+ url,
122
+ headers={"User-Agent": f"enchi-bootstrap/{__version__}"},
123
+ )
124
+ with urllib.request.urlopen(request) as response, destination.open("wb") as handle: # noqa: S310
125
+ handle.write(response.read())
126
+ return destination
127
+
128
+
129
+ def load_checksum_text(
130
+ checksum: Optional[str],
131
+ checksum_path: Optional[Path],
132
+ checksum_url: Optional[str],
133
+ cache_path: Path,
134
+ ) -> Optional[str]:
135
+ """Load checksum content from an inline value, local file, or remote URL."""
136
+
137
+ if checksum:
138
+ return checksum.strip()
139
+ if checksum_path:
140
+ return checksum_path.read_text(encoding="utf-8")
141
+ if checksum_url:
142
+ checksum_target = cache_path.with_suffix(cache_path.suffix + ".sha256")
143
+ download_file(checksum_url, checksum_target)
144
+ return checksum_target.read_text(encoding="utf-8")
145
+ return None
146
+
147
+
148
+ def verify_bundle_checksum(
149
+ bundle_path: Path,
150
+ checksum: Optional[str] = None,
151
+ checksum_path: Optional[Path] = None,
152
+ checksum_url: Optional[str] = None,
153
+ ) -> str:
154
+ """Verify the bundle against a supplied checksum source and return the digest."""
155
+
156
+ checksum_text = load_checksum_text(
157
+ checksum=checksum,
158
+ checksum_path=checksum_path,
159
+ checksum_url=checksum_url,
160
+ cache_path=bundle_path,
161
+ )
162
+ actual = sha256_file(bundle_path)
163
+ if checksum_text is None:
164
+ return actual
165
+
166
+ expected = parse_checksum_text(checksum_text, bundle_path.name)
167
+ if actual.lower() != expected.lower():
168
+ raise ValueError(
169
+ f"checksum mismatch for {bundle_path}: expected {expected}, got {actual}"
170
+ )
171
+ return actual