ator 0.1.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.
- ator-0.1.1/.gitignore +15 -0
- ator-0.1.1/PKG-INFO +23 -0
- ator-0.1.1/README.md +12 -0
- ator-0.1.1/ator_runtime/__init__.py +3 -0
- ator-0.1.1/ator_runtime/cli.py +93 -0
- ator-0.1.1/pyproject.toml +20 -0
ator-0.1.1/.gitignore
ADDED
ator-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ator
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: AToR Agent-to-Runtime command-line launcher
|
|
5
|
+
Author: AToR contributors
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# ator
|
|
13
|
+
|
|
14
|
+
Install the AToR CLI with pip:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
python -m pip install ator
|
|
18
|
+
ator
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The launcher downloads and caches the matching AToR release binary from the
|
|
22
|
+
project's GitHub release on first use. Set `ATOR_RELEASE_BASE_URL` when using a
|
|
23
|
+
private release mirror.
|
ator-0.1.1/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# ator
|
|
2
|
+
|
|
3
|
+
Install the AToR CLI with pip:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python -m pip install ator
|
|
7
|
+
ator
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The launcher downloads and caches the matching AToR release binary from the
|
|
11
|
+
project's GitHub release on first use. Set `ATOR_RELEASE_BASE_URL` when using a
|
|
12
|
+
private release mirror.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import platform
|
|
3
|
+
import stat
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tarfile
|
|
7
|
+
import tempfile
|
|
8
|
+
import urllib.request
|
|
9
|
+
import urllib.error
|
|
10
|
+
import zipfile
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
VERSION = os.environ.get("ATOR_VERSION", "0.1.0")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _target():
|
|
17
|
+
system = platform.system().lower()
|
|
18
|
+
machine = platform.machine().lower()
|
|
19
|
+
if system == "darwin":
|
|
20
|
+
system = "darwin"
|
|
21
|
+
elif system == "windows":
|
|
22
|
+
system = "windows"
|
|
23
|
+
elif system == "linux":
|
|
24
|
+
system = "linux"
|
|
25
|
+
else:
|
|
26
|
+
raise RuntimeError(f"unsupported operating system: {system}")
|
|
27
|
+
if machine in ("x86_64", "amd64"):
|
|
28
|
+
machine = "amd64"
|
|
29
|
+
elif machine in ("aarch64", "arm64"):
|
|
30
|
+
machine = "arm64"
|
|
31
|
+
else:
|
|
32
|
+
raise RuntimeError(f"unsupported CPU architecture: {machine}")
|
|
33
|
+
return system, machine
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _binary_path():
|
|
37
|
+
name = "ator.exe" if platform.system().lower() == "windows" else "ator"
|
|
38
|
+
root = Path(os.environ.get("ATOR_HOME", Path.home() / ".ator"))
|
|
39
|
+
target = root / "bin" / name
|
|
40
|
+
if target.exists():
|
|
41
|
+
return target
|
|
42
|
+
bundled = Path(__file__).resolve().parent / "bin" / name
|
|
43
|
+
if bundled.exists():
|
|
44
|
+
return bundled
|
|
45
|
+
# A source checkout can use its already-built binary without a download.
|
|
46
|
+
here = Path(__file__).resolve()
|
|
47
|
+
for parent in here.parents:
|
|
48
|
+
candidate = parent / "bin" / name
|
|
49
|
+
if candidate.exists():
|
|
50
|
+
return candidate
|
|
51
|
+
return _download(target)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _download(target):
|
|
55
|
+
system, machine = _target()
|
|
56
|
+
base = os.environ.get(
|
|
57
|
+
"ATOR_RELEASE_BASE_URL",
|
|
58
|
+
f"https://github.com/Vijaydaswani/AToR/releases/download/v{VERSION}",
|
|
59
|
+
).rstrip("/")
|
|
60
|
+
archive = f"ator_{VERSION}_{system}_{machine}." + ("zip" if system == "windows" else "tar.gz")
|
|
61
|
+
url = f"{base}/{archive}"
|
|
62
|
+
target.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
63
|
+
with tempfile.TemporaryDirectory() as tmp:
|
|
64
|
+
downloaded = Path(tmp) / archive
|
|
65
|
+
urllib.request.urlretrieve(url, downloaded)
|
|
66
|
+
extract = Path(tmp) / "extract"
|
|
67
|
+
extract.mkdir()
|
|
68
|
+
if archive.endswith(".zip"):
|
|
69
|
+
with zipfile.ZipFile(downloaded) as bundle:
|
|
70
|
+
bundle.extractall(extract)
|
|
71
|
+
else:
|
|
72
|
+
with tarfile.open(downloaded, "r:gz") as bundle:
|
|
73
|
+
for member in bundle.getmembers():
|
|
74
|
+
destination = (extract / member.name).resolve()
|
|
75
|
+
if extract.resolve() not in destination.parents and destination != extract.resolve():
|
|
76
|
+
raise RuntimeError("release archive contains an unsafe path")
|
|
77
|
+
bundle.extractall(extract)
|
|
78
|
+
matches = list(extract.rglob("ator.exe" if system == "windows" else "ator"))
|
|
79
|
+
if not matches:
|
|
80
|
+
raise RuntimeError(f"release archive did not contain {archive}")
|
|
81
|
+
target.write_bytes(matches[0].read_bytes())
|
|
82
|
+
if system != "windows":
|
|
83
|
+
target.chmod(target.stat().st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
|
|
84
|
+
return target
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def main():
|
|
88
|
+
try:
|
|
89
|
+
binary = _binary_path()
|
|
90
|
+
raise SystemExit(subprocess.call([str(binary), *sys.argv[1:]]))
|
|
91
|
+
except (OSError, RuntimeError, urllib.error.URLError) as exc:
|
|
92
|
+
print(f"ator: {exc}", file=sys.stderr)
|
|
93
|
+
raise SystemExit(1)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ator"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "AToR Agent-to-Runtime command-line launcher"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = { text = "Apache-2.0" }
|
|
12
|
+
authors = [{ name = "AToR contributors" }]
|
|
13
|
+
classifiers = ["Programming Language :: Python :: 3", "Operating System :: OS Independent"]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
ator = "ator_runtime.cli:main"
|
|
17
|
+
|
|
18
|
+
[tool.hatch.build.targets.wheel]
|
|
19
|
+
packages = ["ator_runtime"]
|
|
20
|
+
include = ["ator_runtime/bin/*"]
|