setuptools: Problem with auto-scripts and standalone scripts

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

setuptools: Problem with auto-scripts and standalone scripts

Frank McIngvale
Hi, I'm trying to use setuptools auto-script feature with standalone scripts and am having problems.

Say I have a script "mypkg/scripts/foo.py":
---------------------
import sys
print "Hello foo! My args are:", sys.argv
---------------------

When I try wrapping it like this:

            'console_scripts': [
                'foo = mypkg.scripts.foo',
            ]

Then run like this:
$ foo aa bb cc

It appears to start OK (and it gets the cmdline args) but crashes with a traceback:
------------
Hello foo! My args are: ['c:\\frank\\py25\\Scripts\\foo-script.py', 'aa', 'bb', 'cc']
Traceback (most recent call last):
  File "c:\frank\py25\Scripts\foo-script.py", line 8, in <module>
    load_entry_point('mypkg==0.99.50-rc1', 'console_scripts', 'foo')()
TypeError: 'module' object is not callable
------------

Am I setting up 'console_scripts' incorrectly, or is this kind of usage not supported?

thanks,
Frank

_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: setuptools: Problem with auto-scripts and standalone scripts

Nathan R. Yergler-4
Scripts need to address a callable, not a module.  See
http://peak.telecommunity.com/DevCenter/setuptools#automatic-script-creation
and inline below for corrections.

On 7/5/07, Frank McIngvale <[hidden email]> wrote:
> Hi, I'm trying to use setuptools auto-script feature with standalone scripts
> and am having problems.
>
> Say I have a script "mypkg/scripts/foo.py":
> ---------------------
> import sys
> print "Hello foo! My args are:", sys.argv

import sys

def main():
   print "Hello foo! My args are:", sys.argv"

if __name__ == '__main__':
   # here for compatibility
   main()

> ---------------------
>
> When I try wrapping it like this:
>
>             'console_scripts': [
>                 'foo = mypkg.scripts.foo',
>             ]

             'console_scripts': [
                 'foo = mypkg.scripts.foo:main',
             ]

>
> Then run like this:
>  $ foo aa bb cc
>
> It appears to start OK (and it gets the cmdline args) but crashes with a
> traceback:
> ------------
> Hello foo! My args are:
> ['c:\\frank\\py25\\Scripts\\foo-script.py', 'aa', 'bb',
> 'cc']
> Traceback (most recent call last):
>   File "c:\frank\py25\Scripts\foo-script.py", line 8, in <module>
>     load_entry_point('mypkg==0.99.50-rc1', 'console_scripts', 'foo')()
> TypeError: 'module' object is not callable
> ------------
>
> Am I setting up 'console_scripts' incorrectly, or is this kind of usage not
> supported?
>
> thanks,
> Frank
>
> _______________________________________________
> Distutils-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/distutils-sig
>
>
_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig
Reply | Threaded
Open this post in threaded view
|

Re: setuptools: Problem with auto-scripts and standalone scripts

Frank McIngvale
Thanks! That did the trick.

frank

On 7/5/07, Nathan R. Yergler <[hidden email]> wrote:
Scripts need to address a callable, not a module.  See
http://peak.telecommunity.com/DevCenter/setuptools#automatic-script-creation
and inline below for corrections.

On 7/5/07, Frank McIngvale <[hidden email]> wrote:
> Hi, I'm trying to use setuptools auto-script feature with standalone scripts
> and am having problems.
>
> Say I have a script "mypkg/scripts/foo.py":
> ---------------------
> import sys
> print "Hello foo! My args are:", sys.argv

import sys

def main():
   print "Hello foo! My args are:", sys.argv"

if __name__ == '__main__':
   # here for compatibility
   main()

> ---------------------
>
> When I try wrapping it like this:
>
>             'console_scripts': [
>                 'foo = mypkg.scripts.foo',
>             ]

             'console_scripts': [
                 'foo = mypkg.scripts.foo:main ',
             ]

>
> Then run like this:
>  $ foo aa bb cc
>
> It appears to start OK (and it gets the cmdline args) but crashes with a
> traceback:
> ------------
> Hello foo! My args are:

> ['c:\\frank\\py25\\Scripts\\foo-script.py', 'aa', 'bb',
> 'cc']
> Traceback (most recent call last):
>   File "c:\frank\py25\Scripts\foo- script.py", line 8, in <module>
>     load_entry_point('mypkg==0.99.50-rc1', 'console_scripts', 'foo')()
> TypeError: 'module' object is not callable
> ------------
>
> Am I setting up 'console_scripts' incorrectly, or is this kind of usage not
> supported?
>
> thanks,
> Frank
>
> _______________________________________________
> Distutils-SIG maillist  -  [hidden email]
> http://mail.python.org/mailman/listinfo/distutils-sig
>
>


_______________________________________________
Distutils-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/distutils-sig