valbridge-cli 1.0.2__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.
@@ -0,0 +1,2 @@
1
+ """Installable valbridge CLI launcher."""
2
+
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ import subprocess
4
+ import sys
5
+
6
+ from ._runtime import resolve_binary
7
+
8
+
9
+ def main() -> int:
10
+ try:
11
+ binary = resolve_binary()
12
+ except RuntimeError as exc:
13
+ sys.stderr.write(f"{exc}\n")
14
+ return 1
15
+ completed = subprocess.run([binary, *sys.argv[1:]], check=False)
16
+ return completed.returncode
17
+
18
+
19
+ if __name__ == "__main__":
20
+ raise SystemExit(main())
@@ -0,0 +1,84 @@
1
+ from __future__ import annotations
2
+
3
+ import importlib.metadata
4
+ import os
5
+ import platform
6
+ import shutil
7
+ import stat
8
+ import sys
9
+ import tempfile
10
+ from urllib.parse import urlparse
11
+ import urllib.request
12
+ from pathlib import Path
13
+
14
+ OWNER = "vectorfy-co"
15
+ REPO = "valbridge"
16
+ ENV_BIN = "VALBRIDGE_CLI_BIN"
17
+ DOWNLOAD_TIMEOUT_SECONDS = 30
18
+
19
+
20
+ def _package_version() -> str:
21
+ return importlib.metadata.version("valbridge-cli")
22
+
23
+
24
+ def _platform_info() -> tuple[str, str, str]:
25
+ machine = platform.machine().lower()
26
+ if machine in {"x86_64", "amd64"}:
27
+ arch = "x64"
28
+ elif machine in {"arm64", "aarch64"}:
29
+ arch = "arm64"
30
+ else:
31
+ raise RuntimeError(f"Unsupported valbridge CLI architecture: {machine}")
32
+
33
+ if sys_platform := sys.platform:
34
+ if sys_platform.startswith("darwin"):
35
+ return "darwin", arch, ""
36
+ if sys_platform.startswith("linux"):
37
+ return "linux", arch, ""
38
+ if sys_platform.startswith("win"):
39
+ return "windows", arch, ".exe"
40
+
41
+ raise RuntimeError(f"Unsupported valbridge CLI platform: {sys.platform}")
42
+
43
+
44
+ def _release_asset(version: str) -> tuple[str, str]:
45
+ platform_name, arch, ext = _platform_info()
46
+ filename = f"valbridge-{platform_name}-{arch}{ext}"
47
+ tag = f"cli-v{version}"
48
+ return filename, f"https://github.com/{OWNER}/{REPO}/releases/download/{tag}/{filename}"
49
+
50
+
51
+ def _cache_path(version: str, filename: str) -> Path:
52
+ return Path.home() / ".cache" / "valbridge" / "cli" / version / filename
53
+
54
+
55
+ def resolve_binary() -> str:
56
+ override = os.getenv(ENV_BIN)
57
+ if override:
58
+ return override
59
+
60
+ version = _package_version()
61
+ filename, url = _release_asset(version)
62
+ destination = _cache_path(version, filename)
63
+ if not destination.exists():
64
+ destination.parent.mkdir(parents=True, exist_ok=True)
65
+ parsed = urlparse(url)
66
+ if parsed.scheme != "https":
67
+ raise RuntimeError(f"Refusing to download valbridge CLI over non-HTTPS scheme: {parsed.scheme or '<missing>'}")
68
+
69
+ with tempfile.NamedTemporaryFile(delete=False, dir=destination.parent) as temp_file:
70
+ temp_path = Path(temp_file.name)
71
+
72
+ try:
73
+ with urllib.request.urlopen(url, timeout=DOWNLOAD_TIMEOUT_SECONDS) as response:
74
+ with temp_path.open("wb") as file_obj:
75
+ shutil.copyfileobj(response, file_obj)
76
+ temp_path.replace(destination)
77
+ except Exception:
78
+ temp_path.unlink(missing_ok=True)
79
+ raise
80
+
81
+ if os.name != "nt":
82
+ destination.chmod(destination.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
83
+
84
+ return str(destination)
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: valbridge-cli
3
+ Version: 1.0.2
4
+ Summary: Installable CLI launcher for valbridge
5
+ Project-URL: Homepage, https://github.com/vectorfy-co/valbridge
6
+ Project-URL: Documentation, https://github.com/vectorfy-co/valbridge
7
+ Project-URL: Repository, https://github.com/vectorfy-co/valbridge
8
+ Project-URL: Issues, https://github.com/vectorfy-co/valbridge/issues
9
+ Project-URL: Changelog, https://github.com/vectorfy-co/valbridge/blob/main/CHANGELOG.md
10
+ Author: vectorfyco
11
+ Maintainer: vectorfyco
12
+ License: MIT
13
+ Keywords: cli,code-generation,json-schema,valbridge
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+
26
+ <div align="center">
27
+
28
+ # ![valbridge-cli](https://img.shields.io/static/v1?label=&message=valbridge-cli&color=3776AB&style=for-the-badge&logo=pypi&logoColor=white)
29
+
30
+ Installable valbridge CLI launcher for pip and uvx. Downloads the correct platform binary automatically.
31
+
32
+ <a href="https://pypi.org/project/valbridge-cli/"><img src="https://img.shields.io/pypi/v/valbridge-cli?style=flat&logo=pypi&logoColor=white" alt="PyPI" /></a>
33
+ <a href="https://github.com/vectorfy-co/valbridge/blob/main/LICENSE"><img src="https://img.shields.io/github/license/vectorfy-co/valbridge?style=flat" alt="License" /></a>
34
+
35
+ </div>
36
+
37
+ ---
38
+
39
+ ## Zero-install usage
40
+
41
+ Run directly without installing globally:
42
+
43
+ ```bash
44
+ uvx valbridge-cli generate
45
+ uvx valbridge-cli generate --help
46
+ ```
47
+
48
+ ## Global installation
49
+
50
+ ```bash
51
+ # pip
52
+ pip install valbridge-cli
53
+
54
+ # uv (recommended)
55
+ uv tool install valbridge-cli
56
+ ```
57
+
58
+ Then use the `valbridge` command directly:
59
+
60
+ ```bash
61
+ valbridge generate
62
+ valbridge extract --schema user:Profile
63
+ valbridge --help
64
+ ```
65
+
66
+ ## How it works
67
+
68
+ The launcher downloads the matching `valbridge` Go binary for the current platform on first run and caches it locally. Subsequent runs use the cached binary.
69
+
70
+ ## Environment variables
71
+
72
+ | Variable | Description |
73
+ | --- | --- |
74
+ | `VALBRIDGE_CLI_BIN` | Override the binary path. Set to a local build to skip the download. |
75
+
76
+ ## Related packages
77
+
78
+ | Package | Purpose |
79
+ | --- | --- |
80
+ | [`@vectorfyco/valbridge-cli`](https://www.npmjs.com/package/@vectorfyco/valbridge-cli) | npm/npx CLI launcher (same binary, different installer) |
81
+ | [`valbridge`](https://pypi.org/project/valbridge/) | Runtime client for generated validators |
82
+ | [`valbridge-pydantic`](https://pypi.org/project/valbridge-pydantic/) | Pydantic adapter for code generation |
83
+
84
+ ## Learn more
85
+
86
+ - [GitHub repository](https://github.com/vectorfy-co/valbridge)
87
+ - [Full documentation](https://github.com/vectorfy-co/valbridge#readme)
@@ -0,0 +1,7 @@
1
+ valbridge_cli/__init__.py,sha256=Iu9W50xm_hQ9NxXmlEWrf819iaNnwd6CZQAHWp1NoP8,43
2
+ valbridge_cli/__main__.py,sha256=SthaZyQEM5afBi-dwPEpEks3JVr0uf6V2DAEKIs0ssc,412
3
+ valbridge_cli/_runtime.py,sha256=_SLiUl6WgC3KRC7qGsATdtCj-YQdtUIsNHiKUqKbKBE,2672
4
+ valbridge_cli-1.0.2.dist-info/METADATA,sha256=rP88wLgW0fadHvvajXRrMYLUb8zet4kSk-tY0m07Ogs,2984
5
+ valbridge_cli-1.0.2.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
6
+ valbridge_cli-1.0.2.dist-info/entry_points.txt,sha256=f5osMvxd63HG2mXIjy_l7u278X8j5uZQ_vDv6Tuy994,58
7
+ valbridge_cli-1.0.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ valbridge = valbridge_cli.__main__:main