[Distutils] executable egg & top-level __main__.py

Daniel Holth dholth at gmail.com
Fri Jun 19 04:15:21 CEST 2015


You are doing the right thing zipping it up yourself instead of relying on
bdist_egg. Eggs are a plugin or package format and are not designed to be
directly runnable.

There are some utilities to help you make executable zip files:

https://docs.python.org/dev/library/zipapp.html

https://pex.readthedocs.org/en/latest/

If you find it helpful to create your executable more manually, you could
unzip the egg and __main__.py into a directory and then zip everything back
up.

On Thu, Jun 18, 2015 at 8:51 PM Alex Clark <aclark at aclark.net> wrote:

> On 6/18/15 4:46 PM, Dimitri Maziuk wrote:
> > Hi all,
> >
> > I have the following directory structure:
> >
> > myegg/
> >      pkg1/
> >          __init__.py
> >          ...
> >      pkg2/
> >          __init__.py
> >          ...
> >      pkg3/
> >          __init__.py
> >          ...
> >      setup.py
> >      __main__.py
> >
> > If I zip this into myegg.egg and run "python myegg.egg", that runs the
> > top-level __main__.py. If I run "python setup.py bdist_egg" and run the
> > resulting egg, I get "/usr/bin/python: can't find '__main__.py'" in the
> > egg. That is correct: according to "unzip -l" __main__.py is not there.
> >
> > How do I get it included?
> >
> > Or more to the point, how do I make that egg directly executable? --
> > note that I want it to run a script that isn't in any of the bundled
> > packages (but imports from them).
> >
> > (centos 6 with python 2.6 and python-setuptools-0.6.10 and centos 7 with
> > python 2.7 and python-setuptools-0.9.8)
>
>
> Probably can't answer that without seeing setup.py where there should at
> least be ``packages = find_packages()``. Also sounds like you may be
> looking for console_scripts.
>
>
> >
> >
> >
> > _______________________________________________
> > Distutils-SIG maillist  -  Distutils-SIG at python.org
> > https://mail.python.org/mailman/listinfo/distutils-sig
> >
>
> --
> Alex Clark · http://aclark.net
>
>
> _______________________________________________
> 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/20150619/6be788a9/attachment.html>


More information about the Distutils-SIG mailing list