Paver: the build tool you missed

2,067 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,067
On SlideShare
0
From Embeds
0
Number of Embeds
507
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Paver: the build tool you missed

  1. 1. Paver: the build tool you missedLukas LinhartCentrum Holdings
  2. 2. About Me• Regular pythonista since 05• Testing and automation obsession• Centrum Holdings, mostly Django-related work• Lots of smallish projects
  3. 3. Stumbling upon Paver• "Setuptools no more"• Kevin Dangoor To The Rescue
  4. 4. SurveyWho would use a build tool...
  5. 5. Build tool in an interpreted world• Generated Content In Repository (TM)• Moving (files) around
  6. 6. ...and why in Python?• Batteries included (tm)• Integration with pythonic tools
  7. 7. ...and why Paver?• Simple things stay simple• Complex is possible (or integrated)
  8. 8. Single Point of EntryAs in "Console API"1 paver bootstrap2 paver prepare3 paver run
  9. 9. Getting started (First Task!)pavement.py :1 from paver.easy import *23 @task4 def install_dependencies():5 sh(pip install --upgrade -r requirements.txt)
  10. 10. Embrace distutils/setuptools1 from paver.easy import *2 from paver.setuputils import setup34 setup(**same_args_as_in_setup)
  11. 11. setup.py compatibilitypaver minilibpaver generate_setup(pip install -e worky)
  12. 12. Dependencies1 @task2 @needs(install_dependencies)3 def prepare():4 """ Prepare complete environment """5 sh("python setup.py develop")
  13. 13. Overwriting distutils commands1 @task2 @needs(html, "minilib", "generate_setup", "distutils.command.sdist")3 def sdist():4 pass
  14. 14. Positional arguments1 @task2 @consume_args3 def unit(args):4 import nose5 nose.run_exit(6 argv = ["nosetests"] + args7 )
  15. 15. 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
  16. 16. Oh, options1 options(2 minilib=Bunch(3 extra_files=[doctools, virtual]4 )5 )
  17. 17. Options (cont.)1 # inside minilib task2 options.get(extra_files, [])
  18. 18. Namespace search1 options(setup=Bunch(version="1.1"))2 options.version3 1.14 options.order(minilib)5 options.version6 AttributeError: version
  19. 19. sh1 myval = sh("cat /etc/fstab", capture=True)
  20. 20. dry1 # prepare2 dry("Modify", do_fs_mumbo_jumbo)
  21. 21. path.py1 @task2 def publish_docs():3 builtdocs = path("docs") / options.sphinx.builddir / "html"4 destdir = options.docroot5 destdir.rmtree()6 builtdocs.move(destdir)
  22. 22. Documentation (sphinx)1 options(2 sphinx=Bunch(3 builddir="build",4 sourcedir="source"5 )6 )And run1 paver html
  23. 23. Documentation (cog)1 #<== include(started/oldway/setup.py)==>2 #<==end==>configured with1 options(2 cog=Bunch(3 includedir="docs/samples",4 beginspec="<==",5 endspec="==>",6 endoutput="<==end==>"7 )8 )
  24. 24. 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 )
  25. 25. Discovery
  26. 26. Setting up django discovery 1 from paver.discovery import discover_django 2 3 options( 4 discovery = Bunch( 5 django = Bunch( 6 settings_path = "subdir" 7 ) 8 ) 9 )1011 discover_django(options)
  27. 27. Happy Django command pandapaver django.validate
  28. 28. Future• virtualenv improvements• VIRTUAL_ENV context autodetection• more integration (first-class fabric, ...)• what would you like?
  29. 29. Q & (some) AFork us on githubhttp://github.com/paver/paver/paver@googlegroups.com

×