proxyhubb-provider 0.1.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.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyhubb-provider
3
+ Version: 0.1.0
4
+ Summary: Download and run ProxyHubb provider-cli / provider-node binaries
5
+ Author: ProxyHubb
6
+ License: MIT
7
+ Project-URL: Homepage, https://proxyhubb.com
8
+ Project-URL: Repository, https://github.com/samuel-1-avson/ProxySocialHub
9
+ Keywords: proxyhubb,provider,cli,provider-node
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+
16
+ # proxyhubb-provider
17
+
18
+ Thin PyPI wrapper that downloads official **provider-cli** / **provider-node** binaries from
19
+ `GET /v1/cli/download` and proxies CLI arguments.
20
+
21
+ ```bash
22
+ pip install proxyhubb-provider
23
+ proxyhubb-provider doctor
24
+ # or
25
+ pipx run proxyhubb-provider doctor
26
+ ```
27
+
28
+ | Command | Behavior |
29
+ |---------|----------|
30
+ | `proxyhubb-provider install` | Force re-download binary, print path |
31
+ | `proxyhubb-provider path` | Ensure cached binary exists, print path |
32
+ | `proxyhubb-provider …` | Forward args to `provider-cli` |
33
+ | `proxyhubb-provider --daemon …` | Forward to `provider-node` |
34
+
35
+ Env: `PROXYHUBB_API_URL` (default `https://api.proxyhubb.com`), `PROXYHUBB_CLI_VERSION`.
36
+
37
+ There is no separate “seller CLI” — sellers are providers. Automate listings with `pip install proxyhubb`.
@@ -0,0 +1,22 @@
1
+ # proxyhubb-provider
2
+
3
+ Thin PyPI wrapper that downloads official **provider-cli** / **provider-node** binaries from
4
+ `GET /v1/cli/download` and proxies CLI arguments.
5
+
6
+ ```bash
7
+ pip install proxyhubb-provider
8
+ proxyhubb-provider doctor
9
+ # or
10
+ pipx run proxyhubb-provider doctor
11
+ ```
12
+
13
+ | Command | Behavior |
14
+ |---------|----------|
15
+ | `proxyhubb-provider install` | Force re-download binary, print path |
16
+ | `proxyhubb-provider path` | Ensure cached binary exists, print path |
17
+ | `proxyhubb-provider …` | Forward args to `provider-cli` |
18
+ | `proxyhubb-provider --daemon …` | Forward to `provider-node` |
19
+
20
+ Env: `PROXYHUBB_API_URL` (default `https://api.proxyhubb.com`), `PROXYHUBB_CLI_VERSION`.
21
+
22
+ There is no separate “seller CLI” — sellers are providers. Automate listings with `pip install proxyhubb`.
@@ -0,0 +1,5 @@
1
+ """ProxyHubb provider CLI wrapper package."""
2
+
3
+ from proxyhubb_provider.cli import __version__, download_binary, main, run
4
+
5
+ __all__ = ["__version__", "download_binary", "main", "run"]
@@ -0,0 +1,162 @@
1
+ """Download and run ProxyHubb provider-cli / provider-node binaries."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import platform
7
+ import shutil
8
+ import stat
9
+ import subprocess
10
+ import sys
11
+ import tempfile
12
+ from pathlib import Path
13
+ from typing import Optional
14
+ from urllib.error import HTTPError, URLError
15
+ from urllib.parse import urlencode
16
+ from urllib.request import urlopen
17
+
18
+ DEFAULT_API_URL = "https://api.proxyhubb.com"
19
+
20
+ __version__ = "0.1.0"
21
+
22
+
23
+ def api_base() -> str:
24
+ return os.environ.get("PROXYHUBB_API_URL", DEFAULT_API_URL).rstrip("/")
25
+
26
+
27
+ def resolve_platform() -> str:
28
+ system = platform.system().lower()
29
+ if system == "windows":
30
+ return "windows"
31
+ if system == "darwin":
32
+ return "macos"
33
+ return "linux"
34
+
35
+
36
+ def resolve_arch() -> str:
37
+ machine = platform.machine().lower()
38
+ if machine in ("x86_64", "amd64"):
39
+ return "amd64"
40
+ if machine in ("arm64", "aarch64"):
41
+ return "arm64"
42
+ raise RuntimeError(f"Unsupported architecture: {machine}")
43
+
44
+
45
+ def cache_dir() -> Path:
46
+ if sys.platform == "win32":
47
+ base = os.environ.get("LOCALAPPDATA") or str(
48
+ Path.home() / "AppData" / "Local"
49
+ )
50
+ return Path(base) / "proxyhubb" / "cli"
51
+ base = os.environ.get("XDG_CACHE_HOME") or str(Path.home() / ".cache")
52
+ return Path(base) / "proxyhubb" / "cli"
53
+
54
+
55
+ def binary_name(package_type: str, plat: str) -> str:
56
+ base = "provider-node" if package_type == "daemon" else "provider-cli"
57
+ return f"{base}.exe" if plat == "windows" else base
58
+
59
+
60
+ def cached_binary_path(package_type: str, version: Optional[str] = None) -> Path:
61
+ plat = resolve_platform()
62
+ arch = resolve_arch()
63
+ ver = version or os.environ.get("PROXYHUBB_CLI_VERSION") or "latest"
64
+ return (
65
+ cache_dir()
66
+ / ver
67
+ / plat
68
+ / arch
69
+ / package_type
70
+ / binary_name(package_type, plat)
71
+ )
72
+
73
+
74
+ def download_binary(
75
+ *, package_type: str = "wrapper", force: bool = False
76
+ ) -> Path:
77
+ version = (os.environ.get("PROXYHUBB_CLI_VERSION") or "").strip()
78
+ dest = cached_binary_path(package_type, version or "latest")
79
+ if dest.exists() and not force:
80
+ return dest
81
+
82
+ params = {
83
+ "platform": resolve_platform(),
84
+ "arch": resolve_arch(),
85
+ "package_type": package_type,
86
+ }
87
+ if version:
88
+ params["version"] = version
89
+ url = f"{api_base()}/v1/cli/download?{urlencode(params)}"
90
+
91
+ try:
92
+ with urlopen(url) as resp:
93
+ data = resp.read()
94
+ except HTTPError as exc:
95
+ body = exc.read().decode("utf-8", errors="replace")
96
+ raise RuntimeError(
97
+ f"Failed to download {package_type}: HTTP {exc.code} {body}"
98
+ ) from exc
99
+ except URLError as exc:
100
+ raise RuntimeError(f"Failed to download {package_type}: {exc}") from exc
101
+
102
+ dest.parent.mkdir(parents=True, exist_ok=True)
103
+ fd, tmp_name = tempfile.mkstemp(prefix="proxyhubb-cli-", dir=str(dest.parent))
104
+ try:
105
+ with os.fdopen(fd, "wb") as tmp:
106
+ tmp.write(data)
107
+ if sys.platform != "win32":
108
+ os.chmod(tmp_name, os.stat(tmp_name).st_mode | stat.S_IEXEC | 0o755)
109
+ shutil.move(tmp_name, dest)
110
+ finally:
111
+ if os.path.exists(tmp_name):
112
+ try:
113
+ os.unlink(tmp_name)
114
+ except OSError:
115
+ pass
116
+ return dest
117
+
118
+
119
+ def parse_args(argv: list[str]) -> tuple[str, list[str]]:
120
+ package_type = "wrapper"
121
+ args = list(argv)
122
+ passthrough: list[str] = []
123
+ while args:
124
+ a = args.pop(0)
125
+ if a == "--daemon":
126
+ package_type = "daemon"
127
+ continue
128
+ if a in ("--cli", "--wrapper"):
129
+ package_type = "wrapper"
130
+ continue
131
+ passthrough = [a, *args]
132
+ break
133
+ return package_type, passthrough
134
+
135
+
136
+ def run(argv: Optional[list[str]] = None) -> int:
137
+ if argv is None:
138
+ argv = sys.argv[1:]
139
+ package_type, passthrough = parse_args(argv)
140
+ cmd = passthrough[0] if passthrough else None
141
+
142
+ if cmd == "install":
143
+ path = download_binary(package_type=package_type, force=True)
144
+ print(path)
145
+ return 0
146
+
147
+ if cmd == "path":
148
+ path = download_binary(package_type=package_type, force=False)
149
+ print(path)
150
+ return 0
151
+
152
+ path = download_binary(package_type=package_type, force=False)
153
+ completed = subprocess.run([str(path), *passthrough])
154
+ return completed.returncode
155
+
156
+
157
+ def main() -> None:
158
+ try:
159
+ raise SystemExit(run())
160
+ except Exception as exc: # noqa: BLE001 — CLI top-level
161
+ print(exc, file=sys.stderr)
162
+ raise SystemExit(1) from exc
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyhubb-provider
3
+ Version: 0.1.0
4
+ Summary: Download and run ProxyHubb provider-cli / provider-node binaries
5
+ Author: ProxyHubb
6
+ License: MIT
7
+ Project-URL: Homepage, https://proxyhubb.com
8
+ Project-URL: Repository, https://github.com/samuel-1-avson/ProxySocialHub
9
+ Keywords: proxyhubb,provider,cli,provider-node
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+
16
+ # proxyhubb-provider
17
+
18
+ Thin PyPI wrapper that downloads official **provider-cli** / **provider-node** binaries from
19
+ `GET /v1/cli/download` and proxies CLI arguments.
20
+
21
+ ```bash
22
+ pip install proxyhubb-provider
23
+ proxyhubb-provider doctor
24
+ # or
25
+ pipx run proxyhubb-provider doctor
26
+ ```
27
+
28
+ | Command | Behavior |
29
+ |---------|----------|
30
+ | `proxyhubb-provider install` | Force re-download binary, print path |
31
+ | `proxyhubb-provider path` | Ensure cached binary exists, print path |
32
+ | `proxyhubb-provider …` | Forward args to `provider-cli` |
33
+ | `proxyhubb-provider --daemon …` | Forward to `provider-node` |
34
+
35
+ Env: `PROXYHUBB_API_URL` (default `https://api.proxyhubb.com`), `PROXYHUBB_CLI_VERSION`.
36
+
37
+ There is no separate “seller CLI” — sellers are providers. Automate listings with `pip install proxyhubb`.
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ proxyhubb_provider/__init__.py
4
+ proxyhubb_provider/cli.py
5
+ proxyhubb_provider.egg-info/PKG-INFO
6
+ proxyhubb_provider.egg-info/SOURCES.txt
7
+ proxyhubb_provider.egg-info/dependency_links.txt
8
+ proxyhubb_provider.egg-info/entry_points.txt
9
+ proxyhubb_provider.egg-info/top_level.txt
10
+ tests/test_cli.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ proxyhubb-provider = proxyhubb_provider.cli:main
@@ -0,0 +1 @@
1
+ proxyhubb_provider
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "proxyhubb-provider"
7
+ version = "0.1.0"
8
+ description = "Download and run ProxyHubb provider-cli / provider-node binaries"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.9"
12
+ authors = [{ name = "ProxyHubb" }]
13
+ keywords = ["proxyhubb", "provider", "cli", "provider-node"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = []
20
+
21
+
22
+ [project.urls]
23
+ Homepage = "https://proxyhubb.com"
24
+ Repository = "https://github.com/samuel-1-avson/ProxySocialHub"
25
+
26
+ [project.scripts]
27
+ proxyhubb-provider = "proxyhubb_provider.cli:main"
28
+
29
+ [tool.setuptools.packages.find]
30
+ include = ["proxyhubb_provider*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,18 @@
1
+ from proxyhubb_provider.cli import parse_args, resolve_arch, resolve_platform
2
+
3
+
4
+ def test_parse_daemon():
5
+ package_type, passthrough = parse_args(["--daemon", "doctor", "--json"])
6
+ assert package_type == "daemon"
7
+ assert passthrough == ["doctor", "--json"]
8
+
9
+
10
+ def test_parse_wrapper_default():
11
+ package_type, passthrough = parse_args(["join", "--key", "x"])
12
+ assert package_type == "wrapper"
13
+ assert passthrough == ["join", "--key", "x"]
14
+
15
+
16
+ def test_resolve_platform_arch():
17
+ assert resolve_platform() in ("windows", "macos", "linux")
18
+ assert resolve_arch() in ("amd64", "arm64")