Skip to content

Commit f35198f

Browse files
authored
Add a python-zig entry point, for use with uv etc.
1 parent 906e60b commit f35198f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.pypi.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ import sys, subprocess
3131
subprocess.call([sys.executable, "-m", "ziglang"])
3232
```
3333

34+
Binary wrapper
35+
--------------
36+
37+
The [ziglang][pypi] Python package installs a binary wrapper for the Zig compiler under the name `python-zig`; the name is different to avoid conflicts with any system-wide or user-wide `zig` binaries that may be already installed.
38+
39+
40+
Using with `uv`
41+
---------------
42+
43+
The Zig compiler distributed in this Python package can be launched by [uv](https://docs.astral.sh/uv) without installation:
44+
45+
```shell
46+
uvx --from ziglang python-zig
47+
```
48+
3449
License
3550
-------
3651

make_wheels.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def write_wheel(out_dir, *, name, version, tag, metadata, description, contents)
8989

9090
return write_wheel_file(os.path.join(out_dir, wheel_name), {
9191
**contents,
92+
f'{dist_info}/entry_points.txt': make_message([],
93+
'[console_scripts]\npython-zig = ziglang.__main__:dummy'
94+
),
9295
f'{dist_info}/METADATA': make_message([
9396
('Metadata-Version', '2.4'),
9497
('Name', name),
@@ -201,6 +204,8 @@ def write_ziglang_wheel(out_dir, *, version, platform, archive):
201204
os.execv(argv[0], argv)
202205
else:
203206
import subprocess; sys.exit(subprocess.call(argv))
207+
208+
def dummy(): """Dummy function for an entrypoint. Zig is executed as a side effect of the import."""
204209
'''.encode('ascii')
205210

206211
# 1. Check for missing required licenses paths

0 commit comments

Comments
 (0)