29
Paver: the build tool you missed Lukas Linhart Centrum Holdings

Paver: the build tool you missed

  • Upload
    almadcz

  • View
    1.813

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Paver: the build tool you missed

Paver: the build tool you missed

Lukas LinhartCentrum Holdings

www.princexml.com
Prince - Non-commercial License
This document was created with Prince, a great way of getting web content onto paper.
Page 2: Paver: the build tool you missed

About Me• Regular pythonista since '05

• Testing and automation obsession

• Centrum Holdings, mostly Django-related work

• Lots of smallish projects

Page 3: Paver: the build tool you missed

Stumbling upon Paver• "Setuptools no more"

• Kevin Dangoor To The Rescue

Page 4: Paver: the build tool you missed

SurveyWho would use a build tool...

Page 5: Paver: the build tool you missed

Build tool in an interpreted world• Generated Content In Repository (TM)

• Moving (files) around

Page 6: Paver: the build tool you missed

...and why in Python?• Batteries included (tm)

• Integration with pythonic tools

Page 7: Paver: the build tool you missed

...and why Paver?• Simple things stay simple

• Complex is possible (or integrated)

Page 8: Paver: the build tool you missed

Single Point of EntryAs in "Console API"

1 paver bootstrap2 paver prepare3 paver run

Page 9: Paver: the build tool you missed

Getting started (First Task!)pavement.py :

1 from paver.easy import *23 @task4 def install_dependencies():5 sh('pip install --upgrade -r requirements.txt')

Page 10: Paver: the build tool you missed

Embrace distutils/setuptools1 from paver.easy import *2 from paver.setuputils import setup34 setup(**same_args_as_in_setup)

Page 11: Paver: the build tool you missed

setup.py compatibilitypaver minilib

paver generate_setup

(pip install -e worky)

Page 12: Paver: the build tool you missed

Dependencies1 @task2 @needs('install_dependencies')3 def prepare():4 """ Prepare complete environment """5 sh("python setup.py develop")

Page 13: Paver: the build tool you missed

Overwriting distutils commands1 @task2 @needs('html', "minilib", "generate_setup", "distutils.command.sdist")3 def sdist():4 pass

Page 14: Paver: the build tool you missed

Positional arguments1 @task2 @consume_args3 def unit(args):4 import nose5 nose.run_exit(6 argv = ["nosetests"] + args7 )

Page 15: Paver: the build tool you missed

CMD options, GNU style1 @task2 @cmdopts([3 ('domain-username=', 'd', 'Domain username'),4 ('upload-url=', 'u', 'URL to upload to')5 ])6 @needs('download_diff_packages')7 def upload_packages(options):8 # censored

Page 16: Paver: the build tool you missed

Oh, options1 options(2 minilib=Bunch(3 extra_files=['doctools', 'virtual']4 )5 )

Page 17: Paver: the build tool you missed

Options (cont.)1 # inside minilib task2 options.get('extra_files', [])

Page 18: Paver: the build tool you missed

Namespace search1 options(setup=Bunch(version="1.1"))2 options.version3 '1.1'4 options.order('minilib')5 options.version6 AttributeError: version

Page 19: Paver: the build tool you missed

sh1 myval = sh("cat /etc/fstab", capture=True)

Page 20: Paver: the build tool you missed

dry1 # prepare2 dry("Modify", do_fs_mumbo_jumbo)

Page 21: Paver: the build tool you missed

path.py1 @task2 def publish_docs():3 builtdocs = path("docs") / options.sphinx.builddir / "html"4 destdir = options.docroot5 destdir.rmtree()6 builtdocs.move(destdir)

Page 22: Paver: the build tool you missed

Documentation (sphinx)1 options(2 sphinx=Bunch(3 builddir="build",4 sourcedir="source"5 )6 )

And run

1 paver html

Page 23: Paver: the build tool you missed

Documentation (cog)1 #<== include('started/oldway/setup.py')==>2 #<==end==>

configured with

1 options(2 cog=Bunch(3 includedir="docs/samples",4 beginspec="<==",5 endspec="==>",6 endoutput="<==end==>"7 )8 )

Page 24: Paver: the build tool you missed

Virtualenv1 options(2 virtualenv=Bunch(3 packages_to_install=["nose", "virtualenv"],4 install_paver=True,5 script_name='bootstrap.py',6 paver_command_line=None,7 dest_dir="virtualenv"8 )9 )

Page 25: Paver: the build tool you missed

Discovery

Page 26: Paver: the build tool you missed

Setting up django discovery1 from paver.discovery import discover_django23 options(4 discovery = Bunch(5 django = Bunch(6 settings_path = "subdir"7 )8 )9 )

1011 discover_django(options)

Page 27: Paver: the build tool you missed

Happy Django command pandapaver django.validate

Page 28: Paver: the build tool you missed

Future• virtualenv improvements

• VIRTUAL_ENV context autodetection

• more integration (first-class fabric, ...)

• what would you like?

Page 29: Paver: the build tool you missed

Q & (some) AFork us on githubhttp://github.com/paver/paver/[email protected]