[Distutils] Interrogate distribution for an entry point command path

Nick Timkovich prometheus235 at gmail.com
Sat Oct 15 09:51:39 EDT 2016


Usually that entry point is on the PATH, so it should be somewhere in
os.environ['PATH'], so if you just `subprocess.run(['myentrything'])` that
would fire it.

If you want to call that entry point from your code, the clean way (same
environment/version, and especially if you don't need to bother
multiprocessing it) would be to import the corresponding entry point
function & call that.

I might not be answering your question directly, but hopefully there's a
workaround there. What's your use-case for grabbing the exec path?


On Sat, Oct 15, 2016 at 2:06 AM, Ben Finney <ben+python at benfinney.id.au>
wrote:

> Howdy,
>
> How can a Python application discover at run-time where on the
> filesystem its own ‘entry_points’ programs are available?
>
> The Setuptools ‘entry_points’ are available at run-time to the
> distribution, via the ‘pkg_resources’ API for entry points
> <URL:https://setuptools.readthedocs.io/en/latest/pkg_
> resources.html#entry-points>.
>
> I don't see there how to interrogate for which filesystem path to invoke
> for a specific entry point's command.
>
> How can I reliably ask ‘pkg_resources’ for “where is the entry point
> named ‘foo’ installed?” such that I get a filesystem path of a command
> to invoke?
>
> --
>  \         “Geeks like to think that they can ignore politics. You can |
>   `\        leave politics alone, but politics won't leave you alone.” |
> _o__)                                 —Richard M. Stallman, 2002-07-26 |
> Ben Finney
>
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> https://mail.python.org/mailman/listinfo/distutils-sig
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/distutils-sig/attachments/20161015/4afe0629/attachment.html>


More information about the Distutils-SIG mailing list