开发者

Got Django and Buildout working, but what about PIL and Postgres?

开发者 https://www.devze.com 2022-12-16 02:01 出处:网络
I\'m on Mac OSX 10.5.8. I have followed Jacob Kaplan-Moss\'s article on setting up Django with Buildout: http://jacobian.org/writing/django-apps-with-buildout/

I'm on Mac OSX 10.5.8. I have followed Jacob Kaplan-Moss's article on setting up Django with Buildout: http://jacobian.org/writing/django-apps-with-buildout/

Finally, I have got this Buildout to work! ...but I'm now needing PIL and Postgres for a complete isolated Django development area. I've tried to modify my buildout.cfg with tutorials I've read around the internet, but just can't find how to do it without it throwing up all sorts of errors. I feel PIL and Postgres are the next things to complete this little setup, so I can开发者_运维百科 just get on with it... (I'm not an expert at any of this by the way, I come from a PHP background). My current buildout.cfg looks like this:

[buildout]
parts = python django
develop = .
eggs = myproject

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[django]
recipe = djangorecipe
version = 1.1.1
project = myproject
projectegg = myproject
settings = testsettings
test = myproject
eggs = ${buildout:eggs}

Can anyone help me to reliably get PIL and Postgres working with my Buildout? Thank you so much in advance... Everything I've tried so far just throws up all sorts of errors.


In theory, you should just be able to add PIL and psycopg2 to your eggs directive:

eggs = myproject
       PIL
       psycopg2

This works on some systems and in some situations.

However, there are two problems that can prevent it from working everywhere, and especially on OSX:

  1. PIL's packaging is... weird in some way, and that can make installing it from PyPI fail.
  2. Both PIL and psycopg2 are C extensions, which means you'll need to have the correct shared libraries and header files before you can build and install them.

Fixing (1) is easy: just add

find-links = http://dist.plone.org/thirdparty/

To your [buildout] section. The Plone folks maintain an egg-ified PIL that Just Works™ with Buildout.

Fixing (2) is a bit more complicated and situation-depdendant: you'll need to make sure you've got all the various header files that PIL and psycopg2 depend on.

psycopg2

If you've installed PostgreSQL from the PostgeSQL for Mac distribution (which I recommend), then it should have correctly installed the header files for you and psycopg2 will build okay.

If you've installed PostgreSQL from source, then you'll have the header files already; psycopg2 should build easily.

If, however, you've installed PostgreSQL some other way -- fink, ports, homebrew -- then you'll need to be careful and make sure you've got the development files install. In some package systems there's a separate postgresql-dev package with the development headers; others install those automatically.

If you've done this correctly, you should be able to run pg_config and verify that the INCLUDEDIR setting is set and correctly points to the header files (look for a libpq directory in the INCLUDEDIR directory).

PIL

PIL's a lot more tricky because it depends on a lot more libraries. At the very least you'll need to install libjpeg and libpng. If you're on 10.6 they should already be installed for you; if not, the easiest thing is probably to download and install them from source: libpng, libjpeg.


expanding on (2) above

PIL works with additional components that can be installed with below steps.

JPG

wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz 
tar xzf jpegsrc.v8b.tar.gz 
cd jpeg-8b/ 
./configure 
make 
sudo make install 

Freetype

http://sourceforge.net/projects/freetype/files/ 
wget http://downloads.sourceforge.net/project/freetype/freetype2/2.4.4/freetype-2.4.4.tar.bz2 
tar xjf freetype-2.4.4.tar.bz2 
cd free* 
./configure 
make 
sudo make install

LittleCMS 1.19 (NOT 2.0+)

http://downloads.sourceforge.net/project/lcms/lcms/1.19/lcms-1.19.tar.gz 
tar xzf lcms-1.19.tar.gz 
cd lcms*
./configure 
make 
sudo make install 
0

精彩评论

暂无评论...
验证码 换一张
取 消