Tuesday, May 13, 2008
Installing Python PIL on Mac OS X 10.5.2 Leopard
For some reason, the easy_install of python's PIL 1.1.6 imaging library didn't work for me or my coworkers when using Django.
After much trial-and-error using the various builds out there, the solution I found that works best for me was to use the one that comes with MacPorts.
After installing MacPorts, do the following:
Once the installation is complete, you'll need to supplement your PYTHONPATH with the location of the python libraries that macport uses. In your /etc/profile or ~/.profile, add the following line:
That should be it! Works like a charm for me. Note that these instructions are for python 2.5. If you want python 2.4, you can probably install the py-pil package instead (although I haven't tried this myself)
Resources
After much trial-and-error using the various builds out there, the solution I found that works best for me was to use the one that comes with MacPorts.
After installing MacPorts, do the following:
sudo /opt/local/bin/port install py25-pil
Once the installation is complete, you'll need to supplement your PYTHONPATH with the location of the python libraries that macport uses. In your /etc/profile or ~/.profile, add the following line:
export PYTHONPATH=/opt/local/lib/python2.5/site-packages
That should be it! Works like a charm for me. Note that these instructions are for python 2.5. If you want python 2.4, you can probably install the py-pil package instead (although I haven't tried this myself)
Resources
- http://www.martin-geber.com/weblog/2007/08/22/problems-installing-easy_install-pil/: Installation succeeded, but for some reason Django still couldn't find the PIL library.
- http://effbot.org/zone/pil-index.htm: In addition to installing the PIL dmg, you also have to install their python2.5 dmg, which I wasn't keen to do.
- http://paul.annesley.cc/articles/2007/11/19/django-and-python-imaging-library-pil-on-leopard: If you like building from source, this solution may work for you. I prefer using packages since it makes deinstallation easier.
- http://py25-pil.darwinports.com/
- http://py-pil.darwinports.com/
Wednesday, May 07, 2008
Using Cruise Control with Django
I wanted to set up a Continuous Integration server for our project, and after doing a quick tour of the available options I settled on Cruise Control as one of the better options, even though it doesn't have any python-specific features.
We use mercurial as our source control system, so this example uses mercurial, but resources abound for configuring cruise-control with CVS and SVN if you're using one of those SCCS systems.
- Download and install Cruise Control as per http://cruisecontrol.sourceforge.net/gettingstartedsourcedist.html. I used the binary distribution, the latest being 2.7.2 as of this writing.
- Creating and populate a work directory as per the Running the Build Loop instructions. They make the sensible recommendation to keep your working directory separate from your Cruise Control installation directory. Mine is called "work":
mkdir -p work/checkout work/logs work/artifacts
- Check out your project under work/checkout.
- DO NOT bother creating a delegating build script as per the Running the Build Loop instructions. This is only used if you're using Ant to control your build.
- In your work directory, create config.xml, replacing MY_PROJECT_1 with your django root directory. The following configuration will run "python manage.py test" whenever there are new changes to pull from your mercurial repository.
<cruisecontrol>
<project name="MY_PROJECT_1" buildafterfailed="true">
<listeners>
<currentbuildstatuslistener file="logs/MY_PROJECT_1/status.txt">
</currentbuildstatuslistener>
</listeners>
<!-- Bootstrappers are run every time the build runs, *before* the modification checks -->
<bootstrappers>
<mercurialbootstrapper localworkingcopy="checkout/MY_PROJECT_1">
</mercurialbootstrapper>
</bootstrappers>
<!-- Defines where cruise looks for changes, to decide whether to run the build -->
<modificationset quietperiod="10">
<mercurial localworkingcopy="checkout/MY_PROJECT_1">
</mercurial>
</modificationset>
<!-- Configures the actual build loop, how often and which build file/target -->
<schedule interval="60">
<exec workingdir="checkout/MY_PROJECT_1" command="python" args="manage.py test">
</exec>
</schedule>
<!-- directory to write build logs to -->
<log logdir="logs/MY_PROJECT_1">
<!-- Publishers are run *after* a build completes -->
<publishers>
</publishers>
</log>
</project>
</cruisecontrol> - If you're using mercurial, mercurialbootstrapper won't allow you to specify a username or password for hg pull, so edit the .hg/hgrc in your checked out directory to add authentication to your url. Note that this means your password is stored in plain text on your local machine and will be exposed when doing pulls across the network.
[paths]
default = https://username:password@host/path - Optionally copy dashboard-config.xml from the Cruise Control install directory into your work directory. This'll allow you to view the dashboard at http://yourhost:yourport/dashboard. It's pretty nice, I recommend it.
- Start up your server FROM YOUR WORK DIRECTORY.
cd work
<cruise-control-install-dir>/cruisecontrol.sh
If everything went according to plan, you should now be able to view your builds at http://localhost:8080/dashboard.
Currently, Cruise Control doesn't seem to recognize the django test output format, so it won't show individual testcases. However, if your tests pass the build will succeed, and if your test fail the build will fail.
Resources