Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > lightweight way to create new projects from templates

Reply
Thread Tools

lightweight way to create new projects from templates

 
 
Jonathan Hartley
Guest
Posts: n/a
 
      05-11-2011
Hi.

I'm looking for a quick way to create new Python projects from a template.

I understand that 'Paste' (http://pythonpaste.org/) is one way to do
this, but I find Paste very intimidating because of all the
functionality it includes. I'm not even sure whether 'creating new
projects from templates' is the central goal of Paste, or just an
incidental benefit that it provides while performing some other task.

As a lightweight alternative, I'm creating a project called 'Genesis'.
Functionally, it will be little more than a 'cp -r' followed by a few
search and replace operations.


I realise this idea is modest, but I think it could be helpful for:

a) people who are just getting started with Python, and want to see how
best to structure their projects, and

b) people who are already up-to-speed, and who want to create their own
templates and spawn projects from them with a minimum of effort.

c) for the community, to exemplify and publicise best practices for new
projects.


My goals include:

* Create a new project using the default template:

$ genesis myproj

* or using a particular project template:

$ genesis --template=mytemplate myproj

* Allow people to create their own templates, simply stored as
directories under '~/.genesis'

* Files in a template contain 'tags' of the form 'G{author}'. When a new
project is created, these tags are replaced. For example, G{author} will
be replaced with the value for 'author' supplied either on the command-line:

$ genesis myproj author=Jonathan

Or in your ~/.genesis/config file (a python file read using 'exec'):

author = 'Jonathan'

* The default template should embody good practices like those
demonstrated in the Python Project howto:
http://infinitemonkeycorps.net/docs/pph/

* The default template should include a setup.py, supporting sdist,
register and upload commands.

* I'd also like the default template to include things like creating
Windows binaries, so that it is easier for projects to include this out
of the box. It would be nice to extend this to binaries for other
platforms too.

* The default template for command-line applications should include an
acceptance test, which invokes the script in a new process and makes
assertions about stdout, stderr and exit value.

* One of my inspirations is to create a good template for events like
pyweek, where many people set out to write opengl or pyglet applications
from scratch, and yet every time, many entrants fail to properly create
binaries, etc.


Genesis is only partially written, so is not yet on PyPI, but is on
bitbucket:
https://bitbucket.org/tartley/genesis/overview

If you have any feedback, it would be very welcome. In particular:

What do you think about the approach in general?

What do you think about the contents of my default template:
https://bitbucket.org/tartley/genesi...onfig/default/

Do you think a single default template containing all the above ideas is
viable? Or is it likely to be so idiosyncratic that I might be better
shipping with several built-in templates, including a 'minimal' one? Do
I need different templates for applications than for libraries? For
console apps vs GUI apps?

What do you think of my choice of 'G{name}' for replaceable tags in the
template? I wanted something that would not be valid Python, and would
be unlikely to occur naturally in a project.

Best regards,

Jonathan

--
Jonathan Hartley http://tartley.com
Made of meat. +44 7737 062 225 twitter/skype: tartley

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lightweight way to create jpeg files? Mike Nelson Ruby 2 02-25-2007 02:14 PM
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Can't create projects / open projects jaredea ASP .Net 4 08-10-2005 07:01 PM
ASP.NET projects aren’t 'real' projects in VS.NET 2005 Patrick Olurotimi Ige ASP .Net 0 06-09-2005 12:31 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57