I've been building an automated build framework for my UpLib system,
which requires PIL. I've made a couple of changes to the PIL setup.py
which might go into the standard release, and attach a patch.
Basically two changes:
1. It's useful to be able to set TIFF_ROOT, JPEG_ROOT, etc. without
editing the setup.py file. This patch modifies the default values for
those setup variables to be read from the environment, as PIL_TIFF_ROOT,
PIL_JPEG_ROOT, etc. This allows a build script to just set the
environment variables to pass them in to setup.py.
2. When linking _imagingft on msys, the auxiliary libraries (-ljpeg,
-lz, etc.) need to be passed as arguments to the link command. So I've
modified the link code
if feature.freetype:
defs = []
if feature.freetype_version == 20:
defs.append(("USE_FREETYPE_2_0", None))
exts.append(Extension(
"_imagingft", ["_imagingft.c"], libraries=["freetype"],
define_macros=defs
))
to read instead
if feature.freetype:
defs = []
if feature.freetype_version == 20:
defs.append(("USE_FREETYPE_2_0", None))
exts.append(Extension(
"_imagingft", ["_imagingft.c"], libraries=["freetype"] + libs,
define_macros=defs
))
adding back in the necessary libraries. Similarly for _imagingtiff and
_imagingcms.
Should this perhaps be done only for msys, via an "extra" parameter,
such as that used with _imagingcms? Be happy to change it, but it seems
to work fine on OS X and Ubuntu, too, as is.
Bill
*** setup.py 2009-11-15 08:06:10.000000000 -0800
--- setup.py 2010-04-01 14:26:12.000000000 -0700
***************
*** 15,21 ****
def libinclude(root):
# map root to (root/lib, root/include)
! return os.path.join(root, "lib"), os.path.join(root, "include")
# --------------------------------------------------------------------
# Library pointers.
--- 15,24 ----
def libinclude(root):
# map root to (root/lib, root/include)
! if not root:
! return None
! else:
! return os.path.join(root, "lib"), os.path.join(root, "include")
# --------------------------------------------------------------------
# Library pointers.
***************
*** 33,44 ****
#
# TIFF_ROOT = libinclude("/opt/tiff")
! TCL_ROOT = None
! JPEG_ROOT = None
! ZLIB_ROOT = None
! TIFF_ROOT = None
! FREETYPE_ROOT = None
! LCMS_ROOT = None
# FIXME: add mechanism to explicitly *disable* the use of a library
--- 36,47 ----
#
# TIFF_ROOT = libinclude("/opt/tiff")
! TCL_ROOT = libinclude(os.environ.get("PIL_TCL_ROOT"))
! JPEG_ROOT = libinclude(os.environ.get("PIL_JPEG_ROOT"))
! ZLIB_ROOT = libinclude(os.environ.get("PIL_ZLIB_ROOT"))
! TIFF_ROOT = libinclude(os.environ.get("PIL_TIFF_ROOT"))
! FREETYPE_ROOT = libinclude(os.environ.get("PIL_FREETYPE_ROOT"))
! LCMS_ROOT = libinclude(os.environ.get("PIL_LCMS_ROOT"))
# FIXME: add mechanism to explicitly *disable* the use of a library
***************
*** 314,326 ****
if feature.freetype_version == 20:
defs.append(("USE_FREETYPE_2_0", None))
exts.append(Extension(
! "_imagingft", ["_imagingft.c"], libraries=["freetype"],
define_macros=defs
))
if os.path.isfile("_imagingtiff.c") and feature.tiff:
exts.append(Extension(
! "_imagingtiff", ["_imagingtiff.c"], libraries=["tiff"]
))
if os.path.isfile("_imagingcms.c") and feature.lcms:
--- 317,329 ----
if feature.freetype_version == 20:
defs.append(("USE_FREETYPE_2_0", None))
exts.append(Extension(
! "_imagingft", ["_imagingft.c"], libraries=["freetype"] + libs,
define_macros=defs
))
if os.path.isfile("_imagingtiff.c") and feature.tiff:
exts.append(Extension(
! "_imagingtiff", ["_imagingtiff.c"], libraries=["tiff"] + libs
))
if os.path.isfile("_imagingcms.c") and feature.lcms:
***************
*** 328,334 ****
if sys.platform == "win32":
extra.extend(["user32", "gdi32"])
exts.append(Extension(
! "_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + extra
))
if sys.platform == "darwin":
--- 331,337 ----
if sys.platform == "win32":
extra.extend(["user32", "gdi32"])
exts.append(Extension(
! "_imagingcms", ["_imagingcms.c"], libraries=["lcms"] + libs + extra
))
if sys.platform == "darwin":
_______________________________________________
Image-SIG maillist - [email protected]
http://mail.python.org/mailman/listinfo/image-sig