lightweight way to create new projects from templates

Discussion in 'Python' started by Jonathan Hartley, May 11, 2011.

  1. Hi.

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

    I understand that 'Paste' ( 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

    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:

    * The default template should include a, 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

    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:

    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 Hartley
    Made of meat. +44 7737 062 225 twitter/skype: tartley
    Jonathan Hartley, May 11, 2011
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jaredea

    Can't create projects / open projects

    jaredea, Jun 9, 2005, in forum: ASP .Net
    Aug 10, 2005
  2. JKop
  3. recover
    Jul 25, 2006
  4. Julio C. Hernandez Castro

    New lightweight block cipher algorithm

    Julio C. Hernandez Castro, Oct 20, 2006, in forum: C++
    Klaus Pommerening
    Oct 23, 2006
  5. Mike Nelson
    Mike Nelson
    Feb 25, 2007

Share This Page