Friday, July 27, 2012

Python buildout

The official document quite ugly:

You should follow below tuts to get understanding what id does:

Deploy using zc.buildout and PythonPaste  (if you know flask "just a little", this will help you full understand what it do,)

Then, you can turn back to read the official document

What does zc.buildout do?
Basically, it install packages that you specified in buildout.cfg. So you can develop/deploy isolate to other project, and futhermore, you can help someone has the same environment as yours.

What is build out :
Quoting the Buildout website, "Buildout is a Python-based build system for creating, assembling and deploying applications from multiple parts, some of which may be non-Python-based. It lets you create a buildout configuration and reproduce the same software later.". Buildout originated from the Zope/Plone community to automate deployment of customized instances of their software. Lead by Jim Fulton, CTO of Zope Corporation, Buildout became a stable and mature product over the years.
Buildout is used in SlapOS to define which software must be executed on a Slave Node. It has a key role in SlapOS industrial successes. Without it, SlapOS could not exist. However, buildout is also often misunderstood - sometimes purposely - by observers who criticize its use in SlapOS. Many people still do not realize that there is no possible software standard on the Cloud and that buildout is the solution to this impossibility. Experts know for example that any large scale production system which is operated on the Cloud (ex. a social network system) or privately (ex. a banking software) uses patched software. Relational databases are patched to meet performance requirements of given applications as soon as data grows. If a Cloud operating system does not provide the possibility to patch about any of its software components, it is simply unusable for large scale production applications. SlapOS is usable because its definition of what is a software is based on the possibility of patching any dependent software component.


Nói chung với buildout bạn sẽ:
- Phát triển các phần mềm trên môi trường độc lập (tương tự virtualenv). Tức ở project này bạn dùng package A, phiên bản B còn ở project khác dùng package C phiên bản D. (ở A dùng python2.5 còn ở C dùng python2.7 chẳng han)
- Không cần quyền root để cài các package
- Tự động thiết lập môi trường giống hệt ở mọi nơi chỉ cần file buildout.cfg
- Tạm thế.
hvn@hvnatvcc: ~/python/trunk $ python
Creating directory '/home/hvn/python/trunk/bin'.
Creating directory '/home/hvn/python/trunk/parts'.
Creating directory '/home/hvn/python/trunk/eggs'.
Creating directory '/home/hvn/python/trunk/develop-eggs'.
Getting distribution for 'setuptools'.
Got setuptools 0.6c12dev-r88846.
Generated script '/home/hvn/python/trunk/bin/buildout'.

hvn@hvnatvcc: ~/python/trunk $ ./bin/buildout init
Traceback (most recent call last):
  File "./buildout", line 17, in <module>
    import zc.buildout.buildout
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/", line 39, in <module>
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/", line 20, in <module>
    from zc.buildout.easy_install import realpath
  File "/usr/local/lib/python2.7/dist-packages/zc/buildout/", line 81, in <module>
AttributeError: 'NoneType' object has no attribute 'location'
This happened because you installed zc.buildout into your computer (ex: pip install zc.buildout)
Just uninstalls it(sudo pip uninstall zc.buildout), then run again. Everything will be okay ay ay :D

NOTE2: you must run buildout init from your directory root. In my example is trunk

No comments: