Prerequisites:
1) A modern Python 2.x (x > 4)
2) Easy_Install
3) virtualenv
Virtualenv creates a python sandbox that has no dependencies on the system python library. When used this way, the sandbox cannot be broken by system changes.
You can have multiple sandboxes to manage applications that have different dependencies (versions included).
Let's first make sure that we have a sane system python:
bash> which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
bash> python --version
Python 2.7.2
bash> which easy_install
/usr/bin/easy_install
I like to keep all my sandboxes together, in a "sandboxen" dir:
bash> mkdir sandboxen
bash> cd sandboxen
bash> virtualenv pyramid
New python executable in pyramid/bin/python
Installing setuptools............done.
Installing pip...............done.
At this point you need to activate the virtual environment. This is done by sourcing the "activate" script in ~\sandboxen\pyramid\bin. Do not make this script executable! You need to run it as
bash> source ~\sandboxen\pyramid\bin\activate
(pyramid) bash>
The prompt will include the sandbox name to remind you of the special behavior. Use the "deactivate" command to go back to the normal shell. Activate works by prepending the sandbox bin, lib and include to your path.
Pyramid Install
At this point installing pyramid from pypi should be a matter of running
easy_install pyramid==1.2
(at the time of writing 1.3 is still in alpha, so we'll stick with the released version). This will download pyramid and all of its dependencies, and install them into the sandbox. The standard dependencies include a few zope packages, Mako, Chameleon, Paster and a few more.
From this point on we will rely on paster commands to create an application and run it locally in dev mode. If you are familiar with Rails, paster is the rake equivalent.
A logical next step is the excellent tutorial "Pyramid for Humans" .
No comments:
Post a Comment