Mercurial > hg > MakeItSo
changeset 109:697568ba4a22
make the python package template a little fancier
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 14 Jan 2011 17:55:08 -0800 |
parents | 32893f67f85d |
children | 613e9c19a98c |
files | makeitso/python.py makeitso/python_package/setup.py |
diffstat | 2 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/makeitso/python.py Fri Jan 14 07:35:19 2011 -0800 +++ b/makeitso/python.py Fri Jan 14 17:55:08 2011 -0800 @@ -16,8 +16,10 @@ * ./web.py : a webob web handler """ +import os import sys from cli import MakeItSoCLI +from makeitso import ContentTemplate from optparse import OptionParser from template import MakeItSoTemplate from template import Variable @@ -37,23 +39,46 @@ # things that go in setup.py dependencies = {'web.py': ['webob'], 'template.py': ['MakeItSo']} - console_scripts = {'main.py': '{{project}}.main:main', - 'template.py': '{{project}}.template:main' + console_scripts = {'main.py': '{{project}} = {{project}}.main:main', + 'template.py': '{{project}}-template = {{project}}.template:main' } def __init__(self, **kw): MakeItSoTemplate.__init__(self, **kw) + # TODO: get the templates you actually care about [maybe from the CLI?] + def pre(self, variables, output): """ sanitize some variables """ + # get project from output directory + variables['project'] = os.path.basename(output) + # dependencies - dependencies = [] - + dependencies = set([]) + for template, dependency in self.dependencies: + dependencies.update(dependency) + dependencies = list(dependencies) + variables['dependencies'] = dependencies + # console_scripts console_scripts = [] + for template, console_script in self.console_scripts: + console_scripts.add(console_script) + if console_scripts: + s = 'setup(' # placeholder string + script_strings = ['[console_scripts]'] + for console_script in console_scripts: + template = ContentTemplate(console_script) + output = template.substitute(project=variables['project']) + script_strings.append(output) + variables['console_scripts'] = '\n'.join([' ' * len(s) + i + for i in script_strings]) + else: + variables['console_scripts'] = '' + class PythonPackageCLI(MakeItSoCLI): """
--- a/makeitso/python_package/setup.py Fri Jan 14 07:35:19 2011 -0800 +++ b/makeitso/python_package/setup.py Fri Jan 14 17:55:08 2011 -0800 @@ -9,6 +9,8 @@ version = "0.0" +depdendencies = {{dependencies}} + setup(name='{{project}}', version=version, description="{{description}}", @@ -21,11 +23,11 @@ packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=False, - install_requires=[ - # -*- Extra requirements: -*- - ], + install_requires=dependencies, entry_points=""" # -*- Entry points: -*- + + {{console_scripts}} """, )