[Image-SIG] PIL 1.1.4 - setup.py fix for FreeBSD

alex alex <nowhere@phobgate.de>
Fri, 23 May 2003 19:12:51 +0200


hi /f,

had 2 little problems compiling pil 1.1.4 on freebsd 4.8, here's a duff of 
setup.py to correct the problems:

(amsel)[/usr/local/tmp/Imaging-1.1.4] diff -u setup.py.orig setup.py
--- setup.py.orig       Mon May 22 18:18:43 2006
+++ setup.py    Mon May 22 18:20:22 2006
@@ -229,6 +229,8 @@
     INCLUDE_DIRS = ["libImaging"]
     LIBRARY_DIRS = []
     LIBRARIES = []
+    EXTRA_COMPILE_ARGS = None
+    EXTRA_LINK_ARGS = None
     have_freetype = 1 # Assume we have it, unless proven otherwise

     # use source distribution, if available
@@ -273,6 +275,11 @@
         LIBRARIES.append("freetype")
         INCLUDE_DIRS.append("/sw/include/freetype2")
         LIBRARY_DIRS.append("/sw/lib")
+    elif os.path.isdir("/usr/local/include/freetype2"):
+        LIBRARIES.append("freetype")
+        INCLUDE_DIRS.append("/usr/local/include")
+        INCLUDE_DIRS.append("/usr/local/include/freetype2")
+        LIBRARY_DIRS.append("/usr/local/lib")
     else:
         have_freetype = 0

(amsel)[/usr/local/tmp/Imaging-1.1.4]

i added the elif block to find freetype in freebsd specific location 
(freebsd likes to install all additional software to /usr/local instead of 
/usr like many linux distributions + extra freetype2 folder in include, 
maybe to prevent version conflicts)
then i got this error:

(amsel)[/usr/local/tmp/Imaging-1.1.4] python setup.py build
Traceback (most recent call last):
  File "setup.py", line 292, in ?
    extra_compile_args=EXTRA_COMPILE_ARGS,
NameError: name 'EXTRA_COMPILE_ARGS' is not defined
(amsel)[/usr/local/tmp/Imaging-1.1.4] vi setup.py

i added the 2 missing lines, then build and install reported no more errors 
and the following test:

(amsel)[/home/gobes] python
Python 2.1.3 (#1, Apr  9 2003, 09:08:19)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "copyright", "credits" or "license" for more information.
>>> import ImageFont
>>> ImageFont.truetype("/home/gobes/arial.ttf", 13)
<ImageFont.FreeTypeFont instance at 0x810ad0c>
>>>

no IOError, seems truetype support is ready to go, hooray!

alex