[Distutils] Using an egg like a Java jar file
Paul Moore
p.f.moore at gmail.com
Mon Jul 27 23:57:28 CEST 2009
2009/7/27 mhearne808 <mhearne808 at gmail.com>:
> My questions:
> - Is it possible to embed a script with a "main" entry point in an
> egg, and run that from the command line?
> - If so, how do you pass command line arguments to that main?
> - Is this a massive abuse of the intended usage of setuptools?
In Python 2.6, you can definitely use a zip file like this. See
http://docs.python.org/using/cmdline.html#command-line
python foo.zip arg1 arg2 ...
foo.zip should contain a __main__.py which is run. sys.argv holds the
arguments as usual.
This is not an abuse, it's a standard feature.
Whether this is possible with eggs is another matter. I don't know the
answer to this, beyond saying that eggs are zip format files, so you
can always do it as above, at a pinch (assuming you can force
setuptools to generate the correct layout).
Paul.
More information about the Distutils-SIG
mailing list