delivering applications with zc.buildout and a distributed model - Plone Conference 2008

83
delivering applications with zc.buildout and a distributed model Tarek Ziadé <[email protected] > 1

description

Slides from Plone Conf 2008 (Washington D.C.)

Transcript of delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Page 1: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

delivering applicationswith zc.buildout

and a distributed modelTarek Ziadé <[email protected]>

1

Page 2: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Who am I ?New to Plone (~1 year) -> I worked on peripheral matters Used to Zope (CPS core developer)

CTO at Ingeniweb - a Plone company (>20 developers)

Python fan - wrote some books about it(even in english, because you don’t hear my accent in a book)

involved in plone.org migration, PSC, zc.buildout

2

Page 3: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Special promotion during the PloneConf :buy one book == get a big hug

It will look good on your deskbesides Martin Aspeli’s book

3

Page 4: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Thanks ! * Andreas Jung * Veda Williams * David Glick * Jeff Kowalczyk * Youenn Boussard * Christian Klinger * Jesse Snyder * Alec Mitchell * John Habermann * Maurits van Rees * Jean-François Roche * Martin Aspeli * Alain Meurant * Aleksandr Vladimirskiy * Jon Stahl * Alexander Limi * Stephen McMahon

4

Page 5: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Part 1 - working with packages

Part 2 - working with zc.buildout

Part 3 - application lifecycle

5

Page 6: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Part 1 - working with packages

6

Page 7: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

7

builds and distributes a packageregisters and uploads it to PyPI

distutils

7

Page 8: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

8

get the screencast at http://ziade.org/ploneconf

8

Page 9: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

9

distutils is

the standardin the whole Python community.

+1

9

Page 10: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

10

distutils is

broken (but there’s hope)

-1

10

Page 11: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

11

setuptools

simple dependencies management, namespaced package egg distribution

provides easy_install

11

Page 12: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

12

“python setup.py bdist_egg”

one single .egg file

12

Page 13: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

13

egg=

deployment formatin a zip archive

"Eggs are to Pythons as Jars are to Java..."

13

Page 14: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

14

“sdist” is enough, though(and should be mandatory)

14

Page 15: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

15

get the screencast at http://ziade.org/ploneconf

15

Page 16: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

16

easy_install my_package=

will get and install “my_package”from “PyPI”

16

Page 17: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

17

setuptools is

the de facto standardin the Plone community.

+1

17

Page 18: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

18

setuptools is

brokentoo (pje says)

(but there’s hope)

-1

18

Page 19: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

19

packaging future in Python

?

19

Page 20: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

20

PJE Debian packagers BSD packagers Us !

DiscussionsRepoze guys

TG2 guys

Pylons guys

PEPs

distutils 2

Pythoncore

developers

Heaven

Zope 3 guys

Guido

Ian

20

Page 21: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

21

Packaging future in Python

hard to know.but community-drivencome sprint with us saturday !

21

Page 22: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

22

It’s OK, fellowswe will eventuallymake it through.

22

Page 23: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

23

#1 PyPI == SPOF

#2 packages need privacy sometimes

#3 plone.org/products is *dying*

Problems with packaging ?

23

Page 24: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

24

Make a PyPI mirror

Run you own private PyPI

Make plone.org/products PyPI compatible

Solutions ?

#1 PyPI == SPOF

#2 packages need privacy sometimes

#3 plone.org/products is *dying*

24

Page 25: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

25

easy_install collective.eggproxy

#1 Make a PyPI mirror : Smart mirroring

25

Page 26: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

26

26

Page 27: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

27

all calls will go through the proxythe mirror is filled on-demand

In zc.buildout : the index option[buildout]

index = http://my.mirror:8888

27

Page 28: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

28

#2 Run your own private PyPI

PloneSoftwareCenter !

28

Page 29: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

29

get the screencast on http://ziade.org/ploneconf

29

Page 30: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

30

collective.dist

python 2.6 new “register” and “upload” commands

“mregister” and “mupload” in 2.4 and 2.5

$ python setup.py mregister sdist mupload$ python setup.py mregister sdist mupload -r plone.org$ python setup.py mregister sdist mupload -r my-company...

30

Page 31: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

31

Developer side : multiple servers with .pypirc[distutils]index-servers = pypi plone.org my-company

[pypi]username:tarekpassword:hahaha

[plone.org]username:tarekpassword:hahaha...repository:http://plone.org/products

[my-company]username:tarekpassword:hahaha..hahaha.haha...ha..pfiiiuuuuuu..and..hahahaahah.i..am..dying..repository:http://my-company.com/products

31

Page 32: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

32

Let’s try our new PyPIwith collective.dist

32

Page 33: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

33

get the screencast on http://ziade.org/ploneconf

33

Page 34: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

34

#3 Make plone.org/productsPyPI compatible

plone.org was suppose

to switch to that for months.Lazy guys

34

Page 35: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

35

Let’s try new.plone.org

35

Page 36: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

36

get the screencast on http://ziade.org/ploneconf

36

Page 37: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

37

The big picture

37

Page 38: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

38

Yes !!!

developer #138

Page 39: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

39

Yepeee !!!Releasing everywhere

let’s spam PyPI and plone.orgtchak ! tchak ! tchak !

developer #2

39

Page 40: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

40

Hahaha !

We have our package all over the place.

developer #3

40

Page 41: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

41

end of part 1

questions ?

#1 Make mirror

#2 Run your own PyPI

#3 push to several servers

#3 use “mregister” and “mupload”

41

Page 42: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

42

Part 2 - working with zc.buildout(reminders)

42

Page 43: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

43

5 hours in 2006

43

Page 44: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

44

5 hours in 2006get zopeinstall zope

install python extra packages

get extra products

install extra products dependency

doesn’t work

ahhh right, install python-ldap

create an instance

checkout products in development

start to work

doesn’t work

ahhh right, wrong python-ldap version

read extra products doc

install extra products

44

Page 45: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

45

Me in 2006

45

Page 46: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

46

5 minutes in 2008

46

Page 47: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

47

5 minutes in 2008get the “buildout”$ python bootstrap.py$ bin/buildoutstart to work

47

Page 48: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

48

But that was not the main reason

48

Page 49: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

49

Zopeone big-Opackage.

zope.interface

zope.schemas

zope.stuff

zope.whatsthat

zope.makecoffee

zope.dodishes

“eggification”

over 100 packages...

2005 Now

49

Page 50: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

50

Ploneproducts

plone.ista

plone.portlets

plone.stuff

plone.whatsthat

plone.makecoffee

plone.enolp

“eggification”

...

2005 Now

50

Page 51: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

51

YourKillerPloneApp

app.site

app.skin

...

51

Page 52: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

52

YourDistribution

app.site

app.skin

zope.stuff

plone.stuff

...

...

52

Page 53: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

+100 packagesto run Plone

Pythonsite-packages

Increase conflictprobabilities

something is going wrong here

53

Page 54: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

54

zc.buildout =

isolated environment

54

Page 55: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

55

zc.buildout best practices

#1 use the same layout for all your projects

#2 make sure all developers have the same environment

#3 use one cfg per target

55

Page 56: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

56

project1 docs buildout packages releases

project2 docs buildout packages releases....

#1 same layout for all projects

56

Page 57: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

57

easy_install collective.releaser

57

Page 58: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

58

get the screencast on http://ziade.org/ploneconf

58

Page 59: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

59

#2 make sure all developers have the same environment

Plone buildouts are source based Warning

Get my Windows installer : python2.4.4-win32.zipGoogle “An installer for a buildout-ready Windows”

Windows developers

59

Page 60: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

60

Typical buildout layout uses the extends feature

dev.cfg (extends buildout.cfg)buildout.cfg

prod.cfg (extends buildout.cfg)+ bootstrap.py

#3 use one cfg per target

60

Page 61: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

61

[buildout]extends = buildout.cfgparts = threedevelop = ...

[buildout]parts = one two

buildout.cfg :

dev.cfg :

[buildout]parts = one two threedevelop = ...

61

Page 62: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

62

democreating a fresh Plone 3 buildout (Paste)adding the dev.cfghooking a new development packageadding a prod.cfg

62

Page 63: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

63

get the screencast on http://ziade.org/ploneconf

63

Page 64: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

64

end of part 2

questions ?

#1 use the same layout for all projects

#2 make sure all developers have the same environment

#3 use one cfg per target

64

Page 65: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Part 3 - application lifecycle

65

Page 66: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

66

Page 67: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

Releasing packages Releasing the buildout

67

Page 68: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

68

Releasing packages

for package in packages: raise the version edit CHANGES.txt create a branch (svn) go to that branch remove the dev tag (setup.cfg) release it with “mregister sdist mupload -r somehwere” release it with “mregister sdist mupload -r somehwereelse”

68

Page 69: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

69

Releasing packages with collective.releaser:

for package in packages: python setup.py release

69

Page 70: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

70

Defining targets in .pypirc

[distutils]

index-servers = pypi plone.org private

glob-style = true

[pypi]...release-command = mregister sdist muploadrelease-packages = iw.*

[plone.org]...release-command = mregister sdist muploadrelease-packages = plone.* collective.*

[private]...

70

Page 71: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

71

get the screencast on http://ziade.org/ploneconf

71

Page 72: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

72

collective.releaser makes a lot of assumptionsit’s svn-oriented (the first use case)

72

Page 73: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

73

- recipes

- your released packages - exceptions (security fixes, major bug fixes)

What packages should be frozen ?

Release the buildout

73

Page 74: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

74

authentication: use lovely.buildouthttp

Release the buildout

[buildout]...extensions=lovely.buildouthttp...repository:http://my-company.com/products

pypi,http://my-company.com/products,tarek,hahahapypi,http://plone.org/products,tarek,hahaha

HOME/.buildout/.httpauth

74

Page 75: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

75

$ cd buildout$ svn cp . http://somewhere/releases/0.1

Release the buildout -> project layout

project ... buildout packages release/0.1 <- tag for the buildout

75

Page 76: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

76

Release the buildout with collective.releaser :with project_release

$ cd buildout$ project_releaseWhat version you are releasing ? 0.1Added version file.

76

Page 77: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

77

- bin/buildout on target system

- remove some stuff

- offline mode to ‘true’ - tar -czvf release-0.1.tgz release/0.1

Build your release distribution

77

Page 78: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

78

$ svn co http://somesvn/my_projet/releases/0.1 project$ cd project$ project_deploy prod.cfg

Build your distribution with collective.releaserwith project_deploy

78

Page 79: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

79

Upgrading the application

79

Page 80: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

80

Upgrading the application : 3 strategies

#1 full release#2 diff release, using collective.releaser#3 egg pack release, using collective.releaser

80

Page 81: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

81

collective.releaser :

the releaser_project templateproject_releaseproject_deployproject_eggs

project_diff

81

Page 82: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

82

That’s it ! Thanks !

questions ?

82

Page 83: delivering applications with zc.buildout and a distributed model - Plone Conference 2008

83

http://tarekziade.wordpress.com

zc.buildout @ PyPI

collective.dist @ PyPI

collective.releaser @ PyPI

http://alterway.fr

83