The document discusses various Python tools and techniques for packaging, distributing, and deploying Python applications, including modules, packages, Distutils, Setuptools, eggs, PyPI, virtualenv, zc.buildout, and collective.hostout. It provides an example of using these tools to create a "Hello World" application packaged as an egg and deployed to a remote server using collective.hostout in 20 minutes for $20.
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
How to host an app for $20 in 20min using buildout and hostout
1. Buildout and Hostout or “How to host an app for $20 in 20min” Dylan Jay [email_address] Technical Solutions Manager PretaWeb (Thanks to Darryl Cousins for slides 1-10 from NZPUG presentation)
3. A python module: hello.py We can import the method from the module: def helloworld (): print u"Hello World from hello import helloworld
4. A Python Package: hello A package is a module that contains other modules: hello/ __init__.py hello.py Now we must import the method from the module within the module. from hello.hello import helloworld
5. Disutils Distutils was written so we have a unified way to install python modules. python setup.py install
6. Disutils – creating a distribution To distribute the hello module we need have it in a directory with a setup.py file. workingdir/ setup.py hello/ __init__.py hello.py The setup.py file needs at the least the following. from distutils.core import setup setup(name="hello", )
7. Disutils creating a distribution continued Now we can create a distribution tarball with disutils. python setup.py sdist Our directory now looks like this workingdir/ setup.py hello/ __init__.py hello.py dist/ hello-1.0.tar.gz If we unpack the source distribution it looks like this: Hello-1.0/ PKG-INFO setup.py hello/ __init__.py hello.py
8. setuptools • Setuptools is built on top of distutils • uses the setup.py • uses eggs for distribution • allows us to save our modules as eggs to pypi Installing setuptools wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py
9. Eggs To create an egg change the import line in setup.py from setuptools import setup setup(name="hello", version="1.0", ) We can call that with: python setup.py bdist_egg Which creates a binary egg in our dist directory dist/ hello-1.0-py2.4.egg
10. pypi If we want that egg available on pypi and we have an account we can do that with a single command. python setup.py sdist upload Which all the world can use easy_install hello
11. virtualenv If we want to install without affecting whole system $ easy_install virtualenv $ virtualenv myenv $ source myenv/bin/activate (myenv)$ easy_install hello . . . (myenv)$ deactivate
12.
13. Installing buildout $ easy_install zc.buildout $ cd myproj $ buildout init This creates the following directory structure myproj/ bin/ buildout parts/ develop-eggs/ buildout.cfg
14. buildout.cfg Buildout does very little by itself [buildout] parts = A buildout is made of parts. Parts are instances of recipes. Recipes do the work. [buildout] parts = py [py] recipe = zc.recipe.egg interpreter = py eggs = hello
20. Buildout – manages installation $ bin/buildout -v Uninstalling py. Installing buildout1. Installing 'zc.buildout==1.2.1'. We have the distribution that satisfies 'zc.buildout==1.2.1'. Adding required 'setuptools' required by zc.buildout 1.2.1. Picked: setuptools = 0.6c9 Generated script 'myproj/bin/buildout1'. Installing buildout2. Installing 'zc.buildout==1.2.0'. We have the distribution that satisfies 'zc.buildout==1.2.0'. Adding required 'setuptools' required by zc.buildout 1.2.0. Picked: setuptools = 0.6c9 Generated script 'myproj/bin/buildout2'.