root / home / tseaver / obzervationz / 2008 / ploneout_console_script-20080911 Adding Console Scripts to a Plone BuildoutIn a straight 'setupttools'-based application, adding one or more
console scripts is straightforward: you just declare them in the
'setup.py', and set setuptools build them for you. However, when
using 'zc.buildout' for Plone 3.0.x or 3.1.x, you have to arrange to
get the non-eggified Zope2 products on the path, which is not easy.
This recipe works for me.
Created by tseaver. Last modified 2008-09-11 09:45:44. |
import os from setuptools import find_packages from setuptools import setup version = '0.1' setup(name='my.package', #... entry_points=""" [console_scripts] do_something = my.package.scripts.do_something:main """, )
bin
directory:
[parts] ... my_scripts [my_scripts] recipe = zc.recipe.egg eggs = ${instance:eggs} extra-paths = ${zope2:location}/lib/python arguments = '${instance:location}/etc/zope.conf'
config_file
to
get the root object:
class DoSomething: config_file = 'etc/zope.conf' app = None def __init__(self, config_file, argv): if config_file is not None: self.config_file = config_file self.argv = argv def getApplication(self): from Zope2.Startup.run import configure configure(self.config_file) import Zope2 return Zope2.app() def __call__(self): app = self.getApplication() # Do the actual work here, using self.app def main(config_file=None, argv=sys.argv): importer = DoSomething(config_file, argv) importer()