måndag 3 maj 2010

Plone dev on Snow Leopard, the real McCoy

I've got it down now. This is the way to set up your Snow Leopard for some serious Plone (>3.2) development. I work on Plone 3.3.5.

First, Get Xcode and MacPorts. Not entirely sure whether you need it with the instruction below, but it won't hurt unless you're really tight on disk space.

Now, don't even try to use any boiler plate Python-distributions for Mac OS X. The one that ships with Snow Leopard [SL] is of the wrong minor version, you need 2.4 and it's 2.6. The one that comes with Mac Ports doesn't work either because of some missing compiler directives, even though it's of the correct version. No, you have trust Florian to provide you with the Python-distro. Thus, in your directory of choice;

> svn co http://svn.plone.org/svn/collective/buildout/python/
> cd python

Next, you need easy_install for the native Python environment. You get it from http://peak.telecommunity.com/dist/ez_setup.py, and run;

> /usr/bin/python ez_setup.py

Now, use the SL native python interpreter (/usr/bin/python) to

> /usr/bin/python bootstrap.py

Next you build the python environment, but before you do that, take a look in buildout.cfg. Comment out or remove the lines with python25 and python26 if you don't explicitly want those. You don't need them for the purposes here.

> ./bin/buildout

After this step you have a Python distribution that will work for Plone. This is the Python that you'll have to use henceforth. You could set up your system path $PATH to point to this Python to not have to specifically point to it all the time.

> export MY_PYTHON=[the source directory]/python/python2.4
> export PATH=$MY_PYTHON/bin;$PATH

Next, get ZopeSkel;

> python-2.4/bin/easy_install -U ZopeSkel

And you're ready to go! The "paster" tool should be installed (try running "python-2.4/bin/paster create --list-templates"), which is the template engine for creating Plone things. From this point on, you have a working Python environment for working with Plone buildouts for your projects, which is currently the preferred way to do things. Feel free to dig into the tutorials at plone.org, e.g.

Creating a buildout for your project

Setting up Mac OS X Snow Leopard for Plone development Part 2

Ok, so I think I'll do the development as a buildout (as recommended from Plone 3.2 and on). That makes things a bit more exciting, as a bit more preparation is needed. These are the steps I've taken to date.

Given that I've done EVERY step in Part 1 of this tutorial, I continue as follows. My project is called sofitel, for undisclosed reasons. Therefor a create a buildout called sofitel in my source code directory (~/development/buildouts). BTW, I'm following this tutorial on plone.org.

> paster create -t plone3_buildout sofitel
> cd sofitel
> python2.4 bootstrap.py

The next step is checking your buildout.cfg and running ./bin/buildout, and this is where I ran into trouble. What happened for me was that the simplejson v2.0.9 egg did not install properly, resulting in the buildout ending with an error. After searching for help on the internet for several seconds, I concluded that the best way forward was to install simplejson the non-egg way. Hence,

> wget http://pypi.python.org/packages/source/s/simplejson/simplejson-2.0.9.tar.gz#md5=af5e67a39ca3408563411d357e6d5e47
> tar xzf simplejson-2.0.9.tar.gz
> cd simplejson-2.0.9
> sudo python2.4 setup.py install
> sudo python2.4 setup.py clean

I realize that the setup.py steps above perhaps are not all necessary, but anyway they worked for me. What comes after this is;

> ./bin/buildout

Given that you're still in your /sofitel directory. Hope it works for you! =)