-
Notifications
You must be signed in to change notification settings - Fork 20
Advertise zig and ziglang entry points for uv
's sake
#32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If you run
This is more layers of course than I would like... but it works and has pretty low overhead |
I believe that this would make |
Ok so I was really curious about this, so I added some printouts: zig version
from __main__.py: __name__='ziglang.__main__'
from 'zig' entry_point: __name__='__main__'
0.14.1 So I think how name works is that it is set differently by the import mechanism? |
Actually, forget that. I now realize what your PR is doing, which I initially didn't because I forgot how This is intentionally not done in this package, see #7. |
Ohhhh I see. Yeah that makes sense. FWIW One idea is to mark this as an "extra" feature, so that users have to |
I'm fairly sure that I've evaluated this and found that that even disabled "extra" features result in a binary being installed unconditionally, the binary just errors out when launched. I would suggest you re-check that; if it no longer installs a binary we can use it. Alternately, since this is a repeatedly requested feature, we could simply generate and publish a new package, say |
To be clear, this is still a problem: if you install something that depends on |
Yep, yeah I get that for sure. I think tbh ziglang-cli is a better option. This isn't really the use case for features. Then maybe the ziglang PyPI page could link to either the ziglang-cli or simply the direct downloads page on https://ziglang.org/? |
I would expand the "Usage" section, something like this at the end:
and the ziglang-cli README should likewise direct library authors to ziglang. |
Oh wait, you know what, wouldn't this be trivially fixed by just naming the contributed script |
It would; people just usually want an entry point that overlaps the system one. Let's call it |
In fact, wouldn't the original exported tool name "ziglang" also satisfy this? ziglang doesn't conflict with anything, though it doesn't make it clear that it's a python wrapper script in the same way |
This is true but I would find it extremely confusing if I found two executables called |
done
named it :) |
small note: if we instead used the previous main() fn approach, I could add a little printout at the top that says "you are calling the python wrapper for zig" but otherwise I like this outcome! Also updated the readme |
Co-authored-by: Catherine <whitequark@whitequark.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
🫡 |
This PR advertises
zig
andziglang
executables in theentry_points.txt
portion of the wheel. That means that tools likeuv
(https://docs.astral.sh/uv/guides/tools/#running-tools) can automagically pick them up:uvx --refresh --from dist/ziglang-0.14.1-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl python-zig version Installed 1 package in 667ms 0.14.1
When this is published to pypi, uv and pipx users will be able to invoke the zig compiler magically with