30
open source nowhere to go but sixfeetup.com/immerse Using Buildout to Develop and Deploy Python Projects Clayton Parker PyOhio 2009

Using Buildout to Develop and Deploy Python Projects

Embed Size (px)

DESCRIPTION

Buildout gives you a way to manage, build and deploy your Python project with ease. Large Python projects such as Plone use it to distribute repeatable development environments. Buildout allows you to easily get up and running with your project versus the traditional method of installing all the dependancies and manually configuring your applications instance for each environment. The buildout community is rapidly growing with a large repository of recipes that allow you to extend it's functionality. This talk will show you the basics of using buildout and how to make it a vital part of your project's life cycle.

Citation preview

Page 1: Using Buildout to Develop and Deploy Python Projects

open sourcenowhere to go but

sixfeetup.com/immerse

Using Buildout to Develop and Deploy

Python ProjectsClayton ParkerPyOhio 2009

Page 2: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Who am I?

• Lead Developer at Six Feet Up, Inc.

• claytron on IRC

Page 3: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

What’s in store?• What is buildout?

• Who uses it?

• Syntax

• Pinning

• Recipes

• Command line usage

Page 4: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Why buildout?

Page 5: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Eliminate Confusion

Page 6: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Who is using it?

• Plone

• Zope

• Grok

• Pinax

Page 7: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Page 8: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Lingo

Page 9: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Syntax[buildout]parts = zope2 instance

# copied from dist.plone.org/releaseextends = plone-versions.cfgversions = versions

[zope2]recipe = plone.recipe.zope2installurl = ${versions:zope2-url}fake-zope-eggs = Trueadditional-fake-eggs = ZODB3 ZConfig

[instance]recipe = plone.recipe.zope2instancezope2-location = ${zope2:location}user = admin:admineggs = Plone

Page 10: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Advanced Syntax

${part:option}

${zope2:location} ${buildout:directory}option = ${buildout:directory}/somefolder

Variable Substitution

options = foo bar

options += bazoptions -= foo

Option Addition and Removal

Page 11: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Reserved Characters

: $ % { }

Page 12: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Pinning

Page 13: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

[buildout]...extensions = buildout.dumppickedversionsdump-picked-versions-file = dumped-versions.cfgoverwrite-picked-versions-file = True

# tell buildout to use our versions partversions = versions

[versions]SQLAlchemy = 0.5.5

Page 14: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Recipes

Page 15: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

[plonesite]recipe = collective.recipe.plonesiteinstance = instancezeoserver = zeoserversite-id = Ploneadmin-user = adminproducts = profiles-initial = my.package:initialprofiles = my.package:default

Page 16: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

[omelette]recipe = collective.recipe.omeletteeggs = ${instance:eggs}ignore-develop = Trueignores = setuptools# uncomment the line below to have the whole# zope stack available in the omelettepackages = ${zope2:location}/lib/python zope2

Page 17: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

# add the /opt path for local dev so that the egg# can find mysql_config[sql-env]PATH = %(PATH)s:/opt/local/lib/mysql5/bin/:/opt/local/lib/mysql/bin/

[MySQL-python]recipe = zc.recipe.egg:customegg = MySQL-pythonenvironment = sql-env

Page 18: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Roll Your Own

$ easy_install ZopeSkel$ paster create --list-templatesAvailable templates: ... recipe: A recipe project for zc.buildout ...$ paster create -t recipe my.recipe.name

Page 19: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Command Line

Page 20: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Baby Steps

$ cd path/to/mybuildout

$ python2.4 bootstrap.pyCreating directory 'mybuildout/bin'.Creating directory 'mybuildout/parts'.Creating directory 'mybuildout/develop-eggs'.Generated script 'mybuildout/bin/buildout'.

$ bin/buildout

Page 21: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Options• -v and -q

• increase and decrease verbosity

• -n and -N

• Newest and non-newest modes

• -O and -o

• online and offline mode

• -t

• socket timeout

Page 22: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Update your buildout

$ bin/buildout -v

$ bin/buildout -Nvvv

$ bin/buildout -No

$ bin/buildout -t 10

Page 23: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Assignments

$ bin/buildout instance:debug-mode=on

$ bin/buildout buildout:log-level=70

$ bin/buildout -N instance:debug-mode=on -v

$ bin/buildout -Nv plonesite:enabled=false

$ bin/buildout plonesite:site-replace=true

Page 24: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Commands

$ bin/buildout install

$ bin/buildout -Nv install zope2 instance

$ bin/buildout -nv install instance

Page 25: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Default Settings

[buildout]eggs-directory = /Users/clayton/.buildout/eggsdownload-cache = /Users/clayton/.buildout/downloads

zope-directory = /Users/clayton/.buildout/zope

~/.buildout/default.cfg

Page 26: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Helpful Tools

• http://pypi.python.org/pypi/collective.eggproxy

• http://pypi.python.org/pypi/collective.dist

• Fabric or Paver

Page 27: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

What did we learn?• What is buildout?

• Who is using it?

• Syntax

• Pinning

• Recipes

• Command line usage

Page 29: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

1 non-profit project • 10 workshops • 14 mentors • 3 days

Learn Plone by building a website from A to Z

Page 30: Using Buildout to Develop and Deploy Python Projects

sixfeetup.com/immerse

Photo Credits• http://flickr.com/photos/monsieurlam/2645956083/

• http://flickr.com/photos/_boris/2796908072/

• http://flickr.com/photos/b-tal/163450213/

• http://flickr.com/photos/bullish1974/2648544508/

• http://flickr.com/photos/haydnseek/87432002/

• http://flickr.com/photos/disowned/1158260369/

• http://flickr.com/photos/7603557@N08/2662531345/

• http://flickr.com/photos/julishannon/2151986631/

• http://flickr.com/photos/julishannon/2152778524/

• http://flickr.com/photos/lollyknit/1155225799/

• http://flickr.com/photos/binary_koala/86227485/

• http://flickr.com/photos/marcoveringa/2951042391