Slide 1

Slide 1 text

Autogenrating Python project skeleton Pastescript Pastescript is part of paste core. q Paste is set of utilities to make web development in Python simpler. q Pastescript is command line tool to create python project structure. q Installation pip install pastescript #This installs paste as well q Example please ? !bash ➜ paster_and_cookiecutter paster create fooproject Selected and implied templates: PasteScript#basic_package A basic setuptools-enabled package Variables: egg: fooproject package: fooproject project: fooproject Enter version (Version (like 0.1)) ['']: 0.0.1 Enter description (One-line description of the package) ['']: Foo Project in Python Enter long_description (Multi-line description (in reST)) ['']: Foo Bar Baz Project in Python. Enter keywords (Space-separated keywords/tags) ['']: Enter author (Author name) ['']: Kracekumar Enter author_email (Author email) ['']: [email protected] Enter url (URL of homepage) ['']: http://kracekumar.com/pagenotexists Enter license_name (License name) ['']: BSD Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]: True Creating template basic_package Creating directory ./fooproject Recursing into +package+ Creating ./fooproject/fooproject/ Copying __init__.py to ./fooproject/fooproject/__init__.py Copying setup.cfg to ./fooproject/setup.cfg Copying setup.py_tmpl to ./fooproject/setup.py Running /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/Ma cOS/Python setup.py egg_info

Slide 2

Slide 2 text

Other commands !bash ➜ paster_and_cookiecutter paster create --list-templates Available templates: basic_package: A basic setuptools-enabled package paste_deploy: A web application deployed through paste.deploy Let's create a Flask project using paste !bash ➜ paster_and_cookiecutter hg clone https://bitbucket.org/eka/flask-skel .... ➜ paster_and_cookiecutter cd flask-skel ➜ paster_and_cookiecutter sudo python setup.py install ➜ paster_and_cookiecutter paster create -t flask-skel flask_skel_project Selected and implied templates: flask-skel#flask-skel Flask Skel template Variables: egg: flask_skel_project package: flask_skel_project project: flask_skel_project Enter flask_project_name (Name of the main Flask project folder) ['project']: flask_skel_project Creating template flask-skel Creating directory ./flask_skel_project Recursing into +flask_project_name+ Creating ./flask_skel_project/flask_skel_project/ Copying __init__.py_tmpl to ./flask_skel_project/flask_skel_project/__init__.py Recursing into blueprints Creating ./flask_skel_project/flask_skel_project/blueprints/ Copying __init__.py to ./flask_skel_project/flask_skel_project/blueprints/__init__.py Copying home.py to ./flask_skel_project/flask_skel_project/blueprints/home.py Copying config.py_tmpl to ./flask_skel_project/flask_skel_project/config.py Copying local_config.py to ./flask_skel_project/flask_skel_project/local_config.py Recursing into static Creating ./flask_skel_project/flask_skel_project/static/ Recursing into css Creating ./flask_skel_project/flask_skel_project/static/css/ Copying README to ./flask_skel_project/flask_skel_project/static/css/README Copying favicon.ico to ./flask_skel_project/flask_skel_project/static/favicon.ico Recursing into js Creating ./flask_skel_project/flask_skel_project/static/js/ Copying README to ./flask_skel_project/flask_skel_project/static/js/README Copying robots.txt to ./flask_skel_project/flask_skel_project/static/robots.txt

Slide 3

Slide 3 text

Recursing into templates Creating ./flask_skel_project/flask_skel_project/templates/ Copying README to ./flask_skel_project/flask_skel_project/templates/README Copying manage.py_tmpl to ./flask_skel_project/manage.py Copying requirements.txt to ./flask_skel_project/requirements.txt Good and Bad parts Lot of tools. q Python specific. q Cookiecutter Cookiecutter command-line utility that creates projects from cookiecutters. E.g : Python Package, q jQuery plugin. Installation pip install cookiecutter q Example ? !bash ➜ paster_and_cookiecutter cookiecutter https://github.com/audreyr/cookiecutter-pypackage.git Cloning into 'cookiecutter-pypackage'... remote: Counting objects: 246, done. remote: Compressing objects: 100% (153/153), done. remote: Total 246 (delta 121), reused 191 (delta 80) Receiving objects: 100% (246/246), 38.13 KiB, done. Resolving deltas: 100% (121/121), done. full_name (default is "Audrey Roy")? kracekumar email (default is "[email protected]")? [email protected] github_username (default is "audreyr")? kracekumar project_name (default is "Python Boilerplate")? cheese repo_name (default is "boilerplate")? cheese project_short_description (default is "Python Boilerplate contains all the boilerplate you need to create a Python package.")? Cheese and python release_date (default is "2013-08-11")? year (default is "2013")? version (default is "0.1.0")? 0.0.1

Slide 4

Slide 4 text

What happened ? !bash ➜ paster_and_cookiecutter ls cheese flask_skel_project presentation.html flask-skel fooproject presentation.md ➜ paster_and_cookiecutter ls -la ~/.cookiecutters total 0 drwxr-xr-x 4 kracekumarramaraju staff 136 Nov 15 10:21 . drwxr-xr-x+ 176 kracekumarramaraju staff 5984 Nov 15 10:23 .. drwxr-xr-x 7 kracekumarramaraju staff 238 Nov 11 23:25 cookiecutter-flask drwxr-xr-x 7 kracekumarramaraju staff 238 Nov 15 10:21 cookiecutter-pypackage cheese !bash ➜ paster_and_cookiecutter cd cheese ➜ cheese ls AUTHORS.rst LICENSE README.rst requirements.txt tox.ini CONTRIBUTING.rst MANIFEST.in cheese setup.py ➜ cheese cat requirements.txt ➜ cheese cd docs ➜ docs ls Makefile conf.py history.rst installation.rst readme.rst authors.rst contributing.rst index.rst make.bat usage.rst ➜ docs cd .. ➜ cheese cd tests ➜ tests ls __init__.py test_cheese.py ➜ tests cat test_cheese.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ test_cheese ---------------------------------- Tests for `cheese` module. """ import unittest from cheese import cheese

Slide 5

Slide 5 text

class TestCheese(unittest.TestCase): def setUp(self): pass def test_something(self): pass def tearDown(self): pass if __name__ == '__main__': unittest.main() inside cookiecutter-pypackage? !bash ➜ tests cd ~/.cookiecutters/cookiecutter-pypackage ➜ cookiecutter-pypackage git:(master) ls README.rst cookiecutter.json {{cookiecutter.repo_name}} ➜ cookiecutter-pypackage git:(master) cat cookiecutter.json { "full_name": "Audrey Roy", "email": "[email protected]", "github_username": "audreyr", "project_name": "Python Boilerplate", "repo_name": "boilerplate", "project_short_description": "Python Boilerplate contains all the boilerplate you need to create a Python package.", "release_date": "2013-08-11", "year": "2013", "version": "0.1.0" } More !bash ➜ {{cookiecutter.repo_name}} git:(master) ls AUTHORS.rst Makefile tests CONTRIBUTING.rst README.rst tox.ini HISTORY.rst docs {{cookiecutter.repo_name}} LICENSE requirements.txt MANIFEST.in setup.py ➜ {{cookiecutter.repo_name}} git:(master) ls docs Makefile conf.py history.rst installation.rst readme.rst

Slide 6

Slide 6 text

authors.rst contributing.rst index.rst make.bat usage.rst ➜ {{cookiecutter.repo_name}} git:(master) cd {{cookiecutter.repo_name}} ➜ {{cookiecutter.repo_name}} git:(master) ls __init__.py {{cookiecutter.repo_name}}.py ➜ {{cookiecutter.repo_name}} git:(master) cat {{cookiecutter.repo_name}}.py #!/usr/bin/env python # -*- coding: utf-8 -*- Features Language agnostics. q Accepts git or hg url. q Jinja2 <3. q You can import inside python code like from cookiecutter.main import cookiecutter q cookiecutter('https://github.com/audreyr/cookiecutter-pypackage.git') Thanks