-
Notifications
You must be signed in to change notification settings - Fork 439
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
[feature] Support pipx run with different name in entry point natively if a package wants to support it #600
Comments
The entry point usage would be appropriate, and I like it best among the proposed solutions. |
Great page on entry points: https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html So: [options.entry_points]
pipx.run =
build = build.__main__:entrypoint For example? Any thoughts to implementation? |
Implementation should be the simplest part. pipx already depends on importlib.metadata, which has an API for it. https://importlib-metadata.readthedocs.io/en/latest/using.html#entry-points |
The most problematic issue to this approach would be to design a resolution logic both straightforward to explain and do what users expect most of the time in edge cases. One scenario from the top of my head are when a package defines both |
Given that any package supporting this would be adding an explicit entrypoint for pipx, I think that should take precedence and there's no reason to offer options. I would expect it to be entirely used to allow packages to work with pipx that don't already have a matching Console entrypoint, but if someone did add a pipx.run entrypoint and a Console entrypoint with matching names, I would expect pipx to use the dedicated one. I would expect them to be the same, but maybe a package "X" provides two scripts, "A" and "X", but "A" is the main one and the one it wants to expose to pipx run. Or maybe a package can optimize something (like config lookup or something) if run through pipx.run. I really don't expect this to be used in this way, but just pointing out which one makes the most logical sense. It's probably already going to be hard enough to talk packages with unusual script names into adding the pipx.run entrypoint. |
Makes sense. I may find some time to implement this and see how it works in practice. |
I like the idea of a pipx entry point, and using |
Draft implementation in #602. |
This is implemented and released in 0.16.1, I believe. |
@uranusjr are you making a PR to build, or should I? |
This was completed in #615 and released in 0.16, and is now even available on all the GitHub Actions runners! :) |
How would this feature be useful?
Currently, running
pipx run build
does not work; it requirespipx run --spec build pyproject-build
. It would not be safe to add abuild
script entry point topypa/build
, due to how common that name would be. It would be nice to have a way for a package to tell pipx run "here's my entry point, use this". I know the author of pypa/build (@FFY00) was interested in supporting pipx (andpipx run build
would be fantastic, imo). This affects projects with a common or unsafe name for an entry point.Describe the solution you'd like
These are some initial ideas:
pipx run
could fall back onpython -m <name>
if<name>/__main__.py
is present."pipx.run.<name>"
. If this was specified, then that would be used by run. (I'm not very familiar with non-console entry points, but I think this is a valid way to use them)These ideas would allow a package that supports pipx to have a dependency that supports pipx and not trip up the discovery.
Describe alternatives you've considered
This potentially would be a useful alternative to #177. I really like the idea of
pipx run -m
, as it would let me do things likepipx run -m rich
, sincerich
so far has resisted adding an entry point and ispython -m rich.<stuff>
only.The text was updated successfully, but these errors were encountered: