[Distutils] Using an egg like a Java jar file

mhearne808 mhearne808 at gmail.com
Tue Jul 28 23:36:00 CEST 2009


All: This may be a duplicate post - I can't see the post I just
submitted, so I'm trying again.

Thanks for the suggestions.  I can't use 2.6 because it isn't
installed on the systems where my script will be running.

I'm attempting to use the 'eggsecutable' suggestion.  How do I get
command line parameters passed into my entry point main() function?

Code is appended below.
setup.py:
from setuptools import setup, find_packages

setup(name='testme',
      version='1.0.0',
      py_modules=['testme'],
      description = 'foo',
      author = 'Somebody',
      author_email = 'somebody at foo.com',
      url = 'www.foo.com',
      entry_points = {
        'setuptools.installation': ['eggsecutable = testme:main',]}
      )

testme.py:
#!/usr/bin/env python
import sys

def main(input):
    print 'Command line arguments are ' % input

if __name__ == '__main__':
    main(sys.argv)

On Jul 28, 1:53 am, Floris Bruynooghe <floris.bruynoo... at gmail.com>
wrote:
> On Mon, Jul 27, 2009 at 10:57:28PM +0100, Paul Moore wrote:
> > 2009/7/27 mhearne808 <mhearne... 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.
>
> On UNIX systems you can even do something like IIRC:
>
>   $ echo '#!/usr/bin/python' > tmp
>   $ cat tmp foo.zip > foo
>   $ chmod +x foo
>   $ ./foo arg1 arg2 ...
>
> Regards
> Floris
>
> --
> Debian GNU/Linux -- The Power of Freedomwww.debian.org|www.gnu.org|www.kernel.org
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-... at python.orghttp://mail.python.org/mailman/listinfo/distutils-sig


More information about the Distutils-SIG mailing list