[Image-SIG] (no subject)

Mark Hammond mhammond@skippinet.com.au
Tue, 7 Jan 2003 12:51:08 +1100


This is a multi-part message in MIME format.

------=_NextPart_000_0128_01C2B64B.7382F580
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I made a few changes to the 1.1.3 setup.py file.  This new version seems to
work "out-of-the-box" for me, including automatically building the
libImaging directory.  It should allow someone to unzip the tar file, and
have setup.py do absolutely everything necessary.

Let me know if this is still any use to the development version, which I
don't have access to.  The PIL pages indicate patches should be sent here,
but I am not subscribed, so please CC me on any replies.

Thanks,

Mark.

------=_NextPart_000_0128_01C2B64B.7382F580
Content-Type: application/octet-stream;
	name="setup.py.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="setup.py.patch"

--- \temp\setup.py	2002-03-15 06:55:04.000000000 +1100=0A=
+++ setup.py	2003-01-07 12:31:06.000000000 +1100=0A=
@@ -22,10 +22,28 @@=0A=
 HOMEPAGE =3D "http://www.pythonware.com/products/pil"
=20
 # on windows, the build script expects to find both library files and
-# include files in the directories below.  tweak as necessary.
-JPEGDIR =3D "../../kits/jpeg-6b"
-ZLIBDIR =3D "../../kits/zlib-1.1.3"
-
+# include files in one of the directories below.  tweak as necessary.
+kit_dirs =3D ["../../kits", ".."]
+# All kit_dirs will be searched for a sub-directory as specified.
+tool_dirs =3D [
+    ("ZLIBDIR", ("zlib-1.1.4","zlib-1.1.3")),
+    ("JPEGDIR", ("jpeg-6b", "jpeg-6a")),
+]
+
+for var_name, look_dirs in tool_dirs:
+    for kit_dir in kit_dirs:
+        found =3D 0
+        for look_dir in look_dirs:
+            look =3D os.path.abspath(os.path.join(kit_dir, look_dir))
+            if os.path.isdir(look):
+                globals()[var_name] =3D look
+                print "set '%s=3D%s'" % (var_name, look)
+                found =3D 1
+                break
+    if not found:
+        print "Can not configure '%s' - please tweak %s" \
+              % (var_name, os.path.basename(sys.argv[0]))
+           =20
 # on windows, the following is used to control how and where to search
 # for Tcl/Tk files.  None enables automatic searching; to override, set
 # this to a directory name
@@ -48,6 +66,27 @@=0A=
 HAVE_LIBTIFF =3D 0
 HAVE_LIBZ =3D 0
=20
+# If on Windows, we make a feeble attempt at shelling out to
+# build the library if it doesn't exist.
+if sys.platform =3D=3D "win32" and \
+   not os.path.isfile(os.path.join("libImaging", "Imaging.lib")):
+    print "Can't find the PIL Imaging library - trying to build it!"
+    # virgin install's need a .h file copied.
+    if not os.path.isfile(os.path.join("libImaging", "ImConfig.h")):
+       shutil.copyfile( os.path.join("libImaging", "ImConfig.h.win"), \
+                        os.path.join("libImaging", "ImConfig.h"))
+    command =3D 'nmake -f makefile.win JPEGINCLUDE=3D"-I%s" =
ZLIBINCLUDE=3D"-I%s"' \
+              % (JPEGDIR, ZLIBDIR)
+    cwd =3D os.getcwd()
+    try:
+        os.chdir("libImaging")
+        rc =3D os.system(command)
+        if rc:
+            print "*** Build of PIL Imaging library failed"
+            sys.exit(rc)
+    finally:
+        os.chdir(cwd)
+
 # parse ImConfig.h to figure out what external libraries we're using
 for line in open(os.path.join("libImaging", "ImConfig.h")).readlines():
     m =3D re.match("#define\s+HAVE_LIB([A-Z]+)", line)
@@ -56,7 +95,7 @@=0A=
         if lib =3D=3D "JPEG":
             HAVE_LIBJPEG =3D 1
             if sys.platform =3D=3D "win32":
-                LIBRARIES.append("jpeg")
+                LIBRARIES.append("libjpeg")
                 INCLUDE_DIRS.append(JPEGDIR)
                 LIBRARY_DIRS.append(JPEGDIR)
             else:

------=_NextPart_000_0128_01C2B64B.7382F580--