setuptools: Problem with auto-scripts and standalone scripts
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
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 <fmcingvale@gmail.com> 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 - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
Thanks! That did the trick. frank On 7/5/07, Nathan R. Yergler <nathan@yergler.net> 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.
Hi, I'm trying to use setuptools auto-script feature with standalone
On 7/5/07, Frank McIngvale <fmcingvale@gmail.com> wrote: 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 - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
participants (2)
-
Frank McIngvale
-
Nathan R. Yergler