byt3d4nc3 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,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: byt3d4nc3
3
+ Version: 0.1.0
4
+ Summary: Bundled Python runtimes per platform with an architecture-aware selector
5
+ License: Proprietary
6
+ Keywords: runtime,binary,platform
7
+ Classifier: Operating System :: POSIX :: Linux
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Software Development :: Build Tools
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
13
+ # byt3d4nc3
14
+
15
+ Self-contained Python runtimes for a few ABIs, with a small loader that picks
16
+ the binary matching the running machine.
17
+
18
+ Bundled ABIs:
19
+
20
+ - `linux64` — x86-64 Linux
21
+ - `armv8` — aarch64 Linux/Android
22
+ - `armv7` — armv7 Linux/Android
23
+
24
+ The package ships only the runtimes themselves. No tooling, no sources, no
25
+ keys.
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install ./pypi
31
+ ```
32
+
33
+ ## CLI
34
+
35
+ ```sh
36
+ byt3d4nc3 targets # list bundled ABIs
37
+ byt3d4nc3 arch # print the running machine's ABI
38
+ byt3d4nc3 path # path to the runtime for the host
39
+ byt3d4nc3 path armv8 # path to the armv8 runtime
40
+ byt3d4nc3 run app.py # run app.py under the host's runtime
41
+ ```
42
+
43
+ ## Python API
44
+
45
+ ```python
46
+ from byt3d4nc3 import loader
47
+
48
+ loader.targets() # {'linux64': ..., 'armv8': ..., 'armv7': ...}
49
+ loader.abi_for_host() # e.g. 'linux64'
50
+ loader.match_arch('armv8')# path to the armv8 runtime
51
+ loader.run('app.py') # execute under the host runtime
52
+ ```
53
+
54
+ `run()` accepts a path or a source string and passes extra args through.
@@ -0,0 +1,42 @@
1
+ # byt3d4nc3
2
+
3
+ Self-contained Python runtimes for a few ABIs, with a small loader that picks
4
+ the binary matching the running machine.
5
+
6
+ Bundled ABIs:
7
+
8
+ - `linux64` — x86-64 Linux
9
+ - `armv8` — aarch64 Linux/Android
10
+ - `armv7` — armv7 Linux/Android
11
+
12
+ The package ships only the runtimes themselves. No tooling, no sources, no
13
+ keys.
14
+
15
+ ## Install
16
+
17
+ ```sh
18
+ pip install ./pypi
19
+ ```
20
+
21
+ ## CLI
22
+
23
+ ```sh
24
+ byt3d4nc3 targets # list bundled ABIs
25
+ byt3d4nc3 arch # print the running machine's ABI
26
+ byt3d4nc3 path # path to the runtime for the host
27
+ byt3d4nc3 path armv8 # path to the armv8 runtime
28
+ byt3d4nc3 run app.py # run app.py under the host's runtime
29
+ ```
30
+
31
+ ## Python API
32
+
33
+ ```python
34
+ from byt3d4nc3 import loader
35
+
36
+ loader.targets() # {'linux64': ..., 'armv8': ..., 'armv7': ...}
37
+ loader.abi_for_host() # e.g. 'linux64'
38
+ loader.match_arch('armv8')# path to the armv8 runtime
39
+ loader.run('app.py') # execute under the host runtime
40
+ ```
41
+
42
+ `run()` accepts a path or a source string and passes extra args through.
@@ -0,0 +1,5 @@
1
+ __version__ = "0.1.0"
2
+
3
+ from . import loader
4
+
5
+ __all__ = ["loader"]
Binary file
Binary file
@@ -0,0 +1,181 @@
1
+ """Launcher for a host-installed byt3d4nc3 runtime.
2
+
3
+ Import-side note: this module is both an importable library (``targets()``) and
4
+ a console entry point. When run *as a script* the interpreter puts the script's
5
+ own directory at ``sys.path[0]``, and every module needed below (``platform``,
6
+ ``shutil``, ``tempfile``, ...) is resolved through ``sys.path`` rather than being
7
+ a builtin. Anything that can write beside this file could therefore execute
8
+ code in the host interpreter just by being imported, before any of byt3d4nc3's
9
+ own logic runs. So in script mode we drop that entry before the first stdlib
10
+ import and then confirm nothing we imported came from our own directory.
11
+
12
+ In library mode we deliberately do not touch ``sys.path``: an importer has no
13
+ reason to expect a global path mutation as a side effect of ``import
14
+ byt3d4nc3.loader``, and a directory containing an installed package is not a
15
+ meaningful place to stage an attack against a file you can already edit.
16
+ """
17
+ import sys as _sy
18
+
19
+ # Entry-point names that resolve next to this file. ``byt3d4nc3`` is the
20
+ # installed console script; ``runnerx`` is retained so the shadow check still
21
+ # fires for an older checkout, where being wrong here would mean skipping the
22
+ # sys.path sanitisation above.
23
+ _SCRIPT = _sy.argv and _sy.argv[0] and _sy.argv[0].endswith(
24
+ ("byt3d4nc3", "byt3d4nc3.exe", "runnerx", "runnerx.exe", "loader.py",
25
+ "loader.exe", "python", "python3"))
26
+ _OD = ''
27
+ if _SCRIPT and _sy.argv[0]:
28
+ _a = _sy.argv[0]
29
+ _OD = _a.rsplit('/', 1)[0] if '/' in _a else ''
30
+ _sy.path[:] = [p for p in _sy.path if p not in ('', '.', _OD)]
31
+
32
+ import os
33
+ import platform
34
+ import shutil
35
+ import subprocess
36
+ import tempfile
37
+
38
+ _SHADOW = []
39
+ for _m in (os, platform, shutil, subprocess, tempfile):
40
+ _f = getattr(_m, '__file__', '') or ''
41
+ if _OD and _f.startswith(_OD):
42
+ _SHADOW.append(_f)
43
+
44
+ _DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
45
+
46
+ _TARGETS = {
47
+ "linux64": ("linux64", "x86_64"),
48
+ "armv8": ("armv8", "aarch64/arm64"),
49
+ "armv7": ("armv7", "armv6l/armv7l"),
50
+ }
51
+
52
+
53
+ def _host_abi():
54
+ machine = platform.machine().lower()
55
+ if machine in ("x86_64", "amd64"):
56
+ return "linux64"
57
+ if machine in ("aarch64", "arm64"):
58
+ return "armv8"
59
+ if machine in ("armv6l", "armv6", "armv7l", "armv7", "arm"):
60
+ return "armv7"
61
+ raise RuntimeError("unsupported host machine: %s" % platform.machine())
62
+
63
+
64
+ def targets():
65
+ return dict(_TARGETS)
66
+
67
+
68
+ def abi_for_host():
69
+ return _host_abi()
70
+
71
+
72
+ def binary_path(abi=None):
73
+ if abi is None:
74
+ abi = _host_abi()
75
+ if abi not in _TARGETS:
76
+ raise ValueError("unknown ABI %r; choose from %s"
77
+ % (abi, ", ".join(sorted(_TARGETS))))
78
+ return os.path.join(_DATA, abi, "run")
79
+
80
+
81
+ def match_arch(abi=None):
82
+ path = binary_path(abi)
83
+ if not os.path.isfile(path):
84
+ raise RuntimeError("missing runtime for %s" % (abi or _host_abi()))
85
+ return path
86
+
87
+
88
+ def host_site_dirs():
89
+ """Host interpreter's site-packages dirs, handed to the runtime so it can
90
+ import host-installed packages without any scan in the deployed script.
91
+ The runtime (crates/vm/src/getpath.rs) consumes BYT3D4NC3_SITEPACKAGES and
92
+ appends each entry to its own sys.path."""
93
+ import sys
94
+ out, seen = [], set()
95
+ try:
96
+ import sysconfig
97
+ for key in ("purelib", "platlib"):
98
+ p = sysconfig.get_paths().get(key)
99
+ if p and os.path.isdir(p) and p not in seen:
100
+ seen.add(p)
101
+ out.append(p)
102
+ except Exception:
103
+ pass
104
+ for p in sys.path:
105
+ if os.path.isdir(p) and (
106
+ p.endswith(("site-packages", "dist-packages"))
107
+ or "site-packages" in p or "dist-packages" in p
108
+ ) and p not in seen:
109
+ seen.add(p)
110
+ out.append(p)
111
+ return out
112
+
113
+
114
+ def run(script, argv=(), binary=None, env=None, timeout=None):
115
+ prog = shutil.which(binary) if binary else match_arch()
116
+ if not prog:
117
+ raise RuntimeError("no usable runtime for %s" % _host_abi())
118
+
119
+ script_path = script
120
+ _tmp = None
121
+ if not os.path.isfile(script):
122
+ fd, script_path = tempfile.mkstemp(suffix=".py", prefix="_sc_")
123
+ with os.fdopen(fd, "w") as f:
124
+ f.write(script)
125
+ _tmp = script_path
126
+
127
+ try:
128
+ spawn_env = dict(os.environ if env is None else env)
129
+ if not spawn_env.get("BYT3D4NC3_SITEPACKAGES"):
130
+ dirs = host_site_dirs()
131
+ if dirs:
132
+ spawn_env["BYT3D4NC3_SITEPACKAGES"] = os.pathsep.join(dirs)
133
+ return subprocess.run(
134
+ [prog, script_path, *map(str, argv)],
135
+ env=spawn_env, timeout=timeout, check=False,
136
+ )
137
+ finally:
138
+ if _tmp:
139
+ os.unlink(_tmp)
140
+
141
+
142
+ def main(argv=None):
143
+ if _SHADOW:
144
+ raise SystemExit(
145
+ 'byt3d4nc3: refusing to run -- these modules resolved from the '
146
+ 'launcher directory and may have executed already: '
147
+ + ', '.join(_SHADOW))
148
+ import argparse
149
+ ap = argparse.ArgumentParser(prog="byt3d4nc3")
150
+ sub = ap.add_subparsers(dest="cmd", required=True)
151
+
152
+ p_targets = sub.add_parser("targets")
153
+ _ = p_targets
154
+
155
+ p_arch = sub.add_parser("arch")
156
+ _ = p_arch
157
+
158
+ p_path = sub.add_parser("path")
159
+ p_path.add_argument("abi", nargs="?", default=None)
160
+
161
+ p_run = sub.add_parser("run")
162
+ p_run.add_argument("script")
163
+ p_run.add_argument("args", nargs="*")
164
+
165
+ args = ap.parse_args(argv)
166
+
167
+ if args.cmd == "targets":
168
+ for abi in sorted(_TARGETS):
169
+ print("%-8s %s" % (abi, _TARGETS[abi][1]))
170
+ elif args.cmd == "arch":
171
+ print(_host_abi())
172
+ elif args.cmd == "path":
173
+ print(match_arch(args.abi))
174
+ else:
175
+ cp = run(args.script, args.args)
176
+ return cp.returncode
177
+ return 0
178
+
179
+
180
+ if __name__ == "__main__":
181
+ raise SystemExit(main())
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: byt3d4nc3
3
+ Version: 0.1.0
4
+ Summary: Bundled Python runtimes per platform with an architecture-aware selector
5
+ License: Proprietary
6
+ Keywords: runtime,binary,platform
7
+ Classifier: Operating System :: POSIX :: Linux
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Software Development :: Build Tools
10
+ Requires-Python: >=3.8
11
+ Description-Content-Type: text/markdown
12
+
13
+ # byt3d4nc3
14
+
15
+ Self-contained Python runtimes for a few ABIs, with a small loader that picks
16
+ the binary matching the running machine.
17
+
18
+ Bundled ABIs:
19
+
20
+ - `linux64` — x86-64 Linux
21
+ - `armv8` — aarch64 Linux/Android
22
+ - `armv7` — armv7 Linux/Android
23
+
24
+ The package ships only the runtimes themselves. No tooling, no sources, no
25
+ keys.
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install ./pypi
31
+ ```
32
+
33
+ ## CLI
34
+
35
+ ```sh
36
+ byt3d4nc3 targets # list bundled ABIs
37
+ byt3d4nc3 arch # print the running machine's ABI
38
+ byt3d4nc3 path # path to the runtime for the host
39
+ byt3d4nc3 path armv8 # path to the armv8 runtime
40
+ byt3d4nc3 run app.py # run app.py under the host's runtime
41
+ ```
42
+
43
+ ## Python API
44
+
45
+ ```python
46
+ from byt3d4nc3 import loader
47
+
48
+ loader.targets() # {'linux64': ..., 'armv8': ..., 'armv7': ...}
49
+ loader.abi_for_host() # e.g. 'linux64'
50
+ loader.match_arch('armv8')# path to the armv8 runtime
51
+ loader.run('app.py') # execute under the host runtime
52
+ ```
53
+
54
+ `run()` accepts a path or a source string and passes extra args through.
@@ -0,0 +1,12 @@
1
+ README.md
2
+ pyproject.toml
3
+ byt3d4nc3/__init__.py
4
+ byt3d4nc3/loader.py
5
+ byt3d4nc3.egg-info/PKG-INFO
6
+ byt3d4nc3.egg-info/SOURCES.txt
7
+ byt3d4nc3.egg-info/dependency_links.txt
8
+ byt3d4nc3.egg-info/entry_points.txt
9
+ byt3d4nc3.egg-info/top_level.txt
10
+ byt3d4nc3/data/armv7/run
11
+ byt3d4nc3/data/armv8/run
12
+ byt3d4nc3/data/linux64/run
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ byt3d4nc3 = byt3d4nc3.loader:main
@@ -0,0 +1 @@
1
+ byt3d4nc3
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "byt3d4nc3"
7
+ version = "0.1.0"
8
+ description = "Bundled Python runtimes per platform with an architecture-aware selector"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "Proprietary" }
12
+ keywords = ["runtime", "binary", "platform"]
13
+ classifiers = [
14
+ "Operating System :: POSIX :: Linux",
15
+ "Programming Language :: Python :: 3",
16
+ "Topic :: Software Development :: Build Tools",
17
+ ]
18
+
19
+ [project.scripts]
20
+ byt3d4nc3 = "byt3d4nc3.loader:main"
21
+
22
+ [tool.setuptools]
23
+ packages = ["byt3d4nc3"]
24
+
25
+ [tool.setuptools.package-data]
26
+ byt3d4nc3 = [
27
+ "data/linux64/run",
28
+ "data/armv8/run",
29
+ "data/armv7/run",
30
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+