rtk-py 0.28.2.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
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.
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: rtk-py
3
+ Version: 0.28.2.1
4
+ Summary: Python wrapper around invoking rtk (https://github.com/rtk-ai/rtk)
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/markjm/rtk-py
7
+ Project-URL: Upstream, https://github.com/rtk-ai/rtk
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: Implementation :: CPython
11
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # rtk-py
18
+
19
+ Python wrapper around [rtk](https://github.com/rtk-ai/rtk) — a CLI proxy that reduces LLM token consumption by 60-90% on common dev commands.
20
+
21
+ This package downloads and installs the pre-built `rtk` binary for your platform, making it available via `pip install`.
22
+
23
+ All thanks to @pszymkowiak for the real meat, I am just a lowly wrapper man.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install rtk-py
29
+ uv pip install rtk-py
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ After installation, `rtk` is available for use:
35
+
36
+ ```bash
37
+ rtk --version
38
+ rtk init --global
39
+ ```
40
+
41
+ See the [rtk documentation](https://github.com/rtk-ai/rtk#readme) for full usage details.
42
+
43
+
44
+ ## Packaging Inspirations
45
+
46
+ This package follows the same pattern as [shfmt-py](https://github.com/MaxWinterstein/shfmt-py) and [shellcheck-py](https://github.com/shellcheck-py/shellcheck-py). During `pip install`, it downloads the appropriate pre-built binary from the [rtk GitHub releases](https://github.com/rtk-ai/rtk/releases) and installs it into your Python environment's `bin/` (or `Scripts/`) directory.
47
+
48
+ ## Version
49
+
50
+ The Python package version tracks the upstream rtk version with an additional Python release suffix: `{rtk_version}.{py_release}` (e.g., `0.28.2.1`).
51
+
52
+ ## License
53
+
54
+ For the code in this repository — see [LICENSE](LICENSE) for details.
55
+
56
+ The `rtk` binary is distributed under [MIT](https://github.com/rtk-ai/rtk/blob/master/Cargo.toml).
@@ -0,0 +1,40 @@
1
+ # rtk-py
2
+
3
+ Python wrapper around [rtk](https://github.com/rtk-ai/rtk) — a CLI proxy that reduces LLM token consumption by 60-90% on common dev commands.
4
+
5
+ This package downloads and installs the pre-built `rtk` binary for your platform, making it available via `pip install`.
6
+
7
+ All thanks to @pszymkowiak for the real meat, I am just a lowly wrapper man.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install rtk-py
13
+ uv pip install rtk-py
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ After installation, `rtk` is available for use:
19
+
20
+ ```bash
21
+ rtk --version
22
+ rtk init --global
23
+ ```
24
+
25
+ See the [rtk documentation](https://github.com/rtk-ai/rtk#readme) for full usage details.
26
+
27
+
28
+ ## Packaging Inspirations
29
+
30
+ This package follows the same pattern as [shfmt-py](https://github.com/MaxWinterstein/shfmt-py) and [shellcheck-py](https://github.com/shellcheck-py/shellcheck-py). During `pip install`, it downloads the appropriate pre-built binary from the [rtk GitHub releases](https://github.com/rtk-ai/rtk/releases) and installs it into your Python environment's `bin/` (or `Scripts/`) directory.
31
+
32
+ ## Version
33
+
34
+ The Python package version tracks the upstream rtk version with an additional Python release suffix: `{rtk_version}.{py_release}` (e.g., `0.28.2.1`).
35
+
36
+ ## License
37
+
38
+ For the code in this repository — see [LICENSE](LICENSE) for details.
39
+
40
+ The `rtk` binary is distributed under [MIT](https://github.com/rtk-ai/rtk/blob/master/Cargo.toml).
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=70.1"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "rtk-py"
7
+ dynamic = ["version"]
8
+ description = "Python wrapper around invoking rtk (https://github.com/rtk-ai/rtk)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Programming Language :: Python :: Implementation :: CPython",
16
+ "Programming Language :: Python :: Implementation :: PyPy",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://github.com/markjm/rtk-py"
21
+ Upstream = "https://github.com/rtk-ai/rtk"
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: rtk-py
3
+ Version: 0.28.2.1
4
+ Summary: Python wrapper around invoking rtk (https://github.com/rtk-ai/rtk)
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/markjm/rtk-py
7
+ Project-URL: Upstream, https://github.com/rtk-ai/rtk
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: Programming Language :: Python :: Implementation :: CPython
11
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: license-file
16
+
17
+ # rtk-py
18
+
19
+ Python wrapper around [rtk](https://github.com/rtk-ai/rtk) — a CLI proxy that reduces LLM token consumption by 60-90% on common dev commands.
20
+
21
+ This package downloads and installs the pre-built `rtk` binary for your platform, making it available via `pip install`.
22
+
23
+ All thanks to @pszymkowiak for the real meat, I am just a lowly wrapper man.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install rtk-py
29
+ uv pip install rtk-py
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ After installation, `rtk` is available for use:
35
+
36
+ ```bash
37
+ rtk --version
38
+ rtk init --global
39
+ ```
40
+
41
+ See the [rtk documentation](https://github.com/rtk-ai/rtk#readme) for full usage details.
42
+
43
+
44
+ ## Packaging Inspirations
45
+
46
+ This package follows the same pattern as [shfmt-py](https://github.com/MaxWinterstein/shfmt-py) and [shellcheck-py](https://github.com/shellcheck-py/shellcheck-py). During `pip install`, it downloads the appropriate pre-built binary from the [rtk GitHub releases](https://github.com/rtk-ai/rtk/releases) and installs it into your Python environment's `bin/` (or `Scripts/`) directory.
47
+
48
+ ## Version
49
+
50
+ The Python package version tracks the upstream rtk version with an additional Python release suffix: `{rtk_version}.{py_release}` (e.g., `0.28.2.1`).
51
+
52
+ ## License
53
+
54
+ For the code in this repository — see [LICENSE](LICENSE) for details.
55
+
56
+ The `rtk` binary is distributed under [MIT](https://github.com/rtk-ai/rtk/blob/master/Cargo.toml).
@@ -0,0 +1,8 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ rtk_py.egg-info/PKG-INFO
6
+ rtk_py.egg-info/SOURCES.txt
7
+ rtk_py.egg-info/dependency_links.txt
8
+ rtk_py.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env python3
2
+ """Custom build commands that download the rtk binary at install time."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import hashlib
7
+ import http
8
+ import io
9
+ import os.path
10
+ import platform
11
+ import stat
12
+ import sys
13
+ import tarfile
14
+ import urllib.request
15
+ import zipfile
16
+
17
+ from setuptools import Command, setup
18
+ from setuptools.command.build import build as orig_build
19
+ from setuptools.command.install import install as orig_install
20
+ from setuptools.command.bdist_wheel import bdist_wheel as orig_bdist_wheel
21
+
22
+
23
+ RTK_VERSION = '0.28.2'
24
+ PY_VERSION = '1'
25
+
26
+ ARCHIVE_SHA256 = {
27
+ ("linux", "x86_64"): (
28
+ "x86_64-unknown-linux-musl",
29
+ "c7b61e87b8430e42b04ab84fbe1b3b41b563454b0181247fd04844b8e9194371",
30
+ ),
31
+ ("linux", "aarch64"): (
32
+ "aarch64-unknown-linux-gnu",
33
+ "9dbf6dd22cfdf8b85b916505a5e96e1721d7af4cbe2f3dc90b87c9d677d01636",
34
+ ),
35
+ ("darwin", "x86_64"): (
36
+ "x86_64-apple-darwin",
37
+ "5ce5dab3b744a6ecce7ff9deea9fd4606f72c6490c9ee447d74883d9393dcbc7",
38
+ ),
39
+ ("darwin", "arm64"): (
40
+ "aarch64-apple-darwin",
41
+ "5dede8ac36648960a3ad52611856b9047a7817b755750d2bdbda8d4e9931db4d",
42
+ ),
43
+ ("win32", "AMD64"): (
44
+ "x86_64-pc-windows-msvc",
45
+ "8bd4ae58b8657f9afd82c76f28e06232b0e8f994e949176206425dcc6005936a",
46
+ ),
47
+ }
48
+ ARCHIVE_SHA256[("cygwin", "x86_64")] = ARCHIVE_SHA256[("win32", "AMD64")]
49
+
50
+
51
+ def _get_platform_key() -> tuple[str, str]:
52
+ system = sys.platform
53
+ machine = platform.machine()
54
+ if system == "linux":
55
+ if machine in ("x86_64", "amd64"):
56
+ machine = "x86_64"
57
+ elif machine in ("aarch64", "arm64"):
58
+ machine = "aarch64"
59
+ elif system == "darwin":
60
+ if machine in ("x86_64", "amd64"):
61
+ machine = "x86_64"
62
+ elif machine in ("aarch64", "arm64"):
63
+ machine = "arm64"
64
+ return system, machine
65
+
66
+
67
+ def get_download_url() -> tuple[str, str]:
68
+ key = _get_platform_key()
69
+ if key not in ARCHIVE_SHA256:
70
+ raise ValueError(
71
+ f"Unsupported platform: {key}. Supported: {sorted(ARCHIVE_SHA256.keys())}"
72
+ )
73
+ target, sha256 = ARCHIVE_SHA256[key]
74
+ is_windows = key[0] in ("win32", "cygwin")
75
+ ext = "zip" if is_windows else "tar.gz"
76
+ url = (
77
+ f"https://github.com/rtk-ai/rtk/releases/download/"
78
+ f"v{RTK_VERSION}/rtk-{target}.{ext}"
79
+ )
80
+ return url, sha256
81
+
82
+
83
+ def download(url: str, sha256: str) -> bytes:
84
+ with urllib.request.urlopen(url) as resp:
85
+ code = resp.getcode()
86
+ if code != http.HTTPStatus.OK:
87
+ raise ValueError(f"HTTP failure. Code: {code}")
88
+ data = resp.read()
89
+
90
+ checksum = hashlib.sha256(data).hexdigest()
91
+ if checksum != sha256:
92
+ raise ValueError(f"sha256 mismatch, expected {sha256}, got {checksum}")
93
+
94
+ return data
95
+
96
+
97
+ def extract_binary(data: bytes, base_dir: str) -> None:
98
+ """Extract the rtk binary from the downloaded archive."""
99
+ is_windows = sys.platform in ("win32", "cygwin")
100
+ exe = "rtk.exe" if is_windows else "rtk"
101
+ os.makedirs(base_dir, exist_ok=True)
102
+ output_path = os.path.join(base_dir, exe)
103
+
104
+ if is_windows:
105
+ with zipfile.ZipFile(io.BytesIO(data)) as zf:
106
+ names = zf.namelist()
107
+ binary_name = next(
108
+ (n for n in names if n.endswith("rtk.exe") or n == "rtk.exe"),
109
+ names[0],
110
+ )
111
+ with zf.open(binary_name) as src, open(output_path, "wb") as dst:
112
+ dst.write(src.read())
113
+ else:
114
+ with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as tf:
115
+ members = tf.getnames()
116
+ binary_name = next(
117
+ (m for m in members if m == "rtk" or m.endswith("/rtk")),
118
+ members[0],
119
+ )
120
+ member = tf.getmember(binary_name)
121
+ extracted = tf.extractfile(member)
122
+ if extracted is None:
123
+ raise ValueError(f"Could not extract {binary_name} from archive")
124
+ with open(output_path, "wb") as dst:
125
+ dst.write(extracted.read())
126
+
127
+ st = os.stat(output_path)
128
+ os.chmod(output_path, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
129
+
130
+
131
+ class build(orig_build):
132
+ sub_commands = orig_build.sub_commands + [("fetch_binaries", None)]
133
+
134
+
135
+ class install(orig_install):
136
+ sub_commands = orig_install.sub_commands + [("install_rtk", None)]
137
+
138
+
139
+ class fetch_binaries(Command):
140
+ build_temp = None
141
+ description = "download the rtk binary for the current platform"
142
+ user_options = []
143
+
144
+ def initialize_options(self):
145
+ pass
146
+
147
+ def finalize_options(self):
148
+ self.set_undefined_options("build", ("build_temp", "build_temp"))
149
+
150
+ def run(self):
151
+ url, sha256 = get_download_url()
152
+ data = download(url, sha256)
153
+ extract_binary(data, self.build_temp)
154
+
155
+
156
+ class install_rtk(Command):
157
+ description = "install the rtk executable"
158
+ outfiles = ()
159
+ build_dir = install_dir = None
160
+ user_options = []
161
+
162
+ def initialize_options(self):
163
+ pass
164
+
165
+ def finalize_options(self):
166
+ self.set_undefined_options("build", ("build_temp", "build_dir"))
167
+ self.set_undefined_options(
168
+ "install",
169
+ ("install_scripts", "install_dir"),
170
+ )
171
+
172
+ def run(self):
173
+ self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
174
+
175
+ def get_outputs(self):
176
+ return self.outfiles
177
+
178
+
179
+ command_overrides = {
180
+ "install": install,
181
+ "install_rtk": install_rtk,
182
+ "build": build,
183
+ "fetch_binaries": fetch_binaries,
184
+ }
185
+
186
+
187
+ class bdist_wheel(orig_bdist_wheel):
188
+ def finalize_options(self):
189
+ orig_bdist_wheel.finalize_options(self)
190
+ self.root_is_pure = False
191
+
192
+ def get_tag(self):
193
+ _, _, plat = orig_bdist_wheel.get_tag(self)
194
+ if plat.startswith('linux_'):
195
+ arch = plat.split('_', 1)[1]
196
+ plat = f'manylinux_2_17_{arch}'
197
+ return 'py2.py3', 'none', plat
198
+
199
+
200
+ command_overrides["bdist_wheel"] = bdist_wheel
201
+
202
+ setup(version=f'{RTK_VERSION}.{PY_VERSION}', cmdclass=command_overrides)