Re: lightweight way to create new projects from templates

2011-05-12 Thread Jonathan Hartley
Hey Chris,

Thanks for the thoughts. I must confess I had already given up on a 'single 
file' approach, because I want to make it easy for people to create their own 
templates, so I have to handle copying a template defined by creating a new 
directory full of diles. If I'm already handling this case, I thought, I might 
as well bundle the built-in default templates as a bunch of files.

I'd hope to provide platform binaries to make download and install easy for 
end-users, regardless of what Python version they already have installed.

Which reminds me, I should make sure the default template works on Python2.x as 
well as 3.x. Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


lightweight way to create new projects from templates

2011-05-11 Thread Jonathan Hartley

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/genesis/src/tip/genesis/config/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 Hartleytart...@tartley.comhttp://tartley.com
Made of meat.   +44 7737 062 225   twitter/skype: tartley

--
http://mail.python.org/mailman/listinfo/python-list


Re: lightweight way to create new projects from templates

2011-05-11 Thread Chris Angelico
On Thu, May 12, 2011 at 4:34 AM, Jonathan Hartley tart...@tartley.com wrote:
 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.

Depending on how simple your goals are, it might be possible to do it
with a simple shell or Python script that creates multiple files
and/or directories. That way, your template is all contained in a
single file, which is convenient for distribution and such; and the
scripting facilities can handle the search and replace operations.

Chris Angelico
-- 
http://mail.python.org/mailman/listinfo/python-list