Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#7273 closed defect (fixed)

PIL spkg uses libraries it must not use

Reported by: GeorgSWeber Owned by: mabshoff
Priority: blocker Milestone: sage-4.2.1
Component: packages: standard Keywords:
Cc: Merged in: sage-4.2.1.rc0
Authors: Tim Dumol Reviewers: William Stein
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by timdumol)

New spkg's available at these url's:

#7345 --

#7344 --

In binary build mode, the updated PIL library optionally depends on libtiff, libpng, and libjpeg with the path explicitly set to the local lib path. TCL/TK support is disabled.

From the pil-1.1.6.spkg's "":

# --------------------------------------------------------------------
# Library pointers.
# Use None to look for the libraries in well-known library locations.
# Use a string to specify a single directory, for both the library and
# the include files.  Use a tuple to specify separate directories:
# (libpath, includepath).  Examples:
# JPEG_ROOT = "/home/libraries/jpeg-6b"
# TIFF_ROOT = "/opt/tiff/lib", "/opt/tiff/include"
# If you have "lib" and "include" directories under a common parent,
# you can use the "libinclude" helper:
# TIFF_ROOT = libinclude("/opt/tiff")


# FIXME: add mechanism to explicitly *disable* the use of a library

# --------------------------------------------------------------------

and any of these libraries the setup thinks it finds will be set as


and the like in "building '_imaging' extension".

This means that if a Sage binary is built on a computer with having some of these libraries, then this binary will *not* work (might not even start) on a computer not having at least these libraries available.

Even more fun (again taken from PIL's

        elif sys.platform == "darwin":
            # attempt to make sure we pick freetype2 over other versions
            add_directory(include_dirs, "/sw/include/freetype2")
            add_directory(include_dirs, "/sw/lib/freetype2/include")
            # fink installation directories
            add_directory(library_dirs, "/sw/lib")
            add_directory(include_dirs, "/sw/include")
            # darwin ports installation directories
            add_directory(library_dirs, "/opt/local/lib")
            add_directory(include_dirs, "/opt/local/include")

Last, but not least, pil-1.1.6 as contained in Sage-4.2.alpha1 breaks the Sage build, at least on my computer. It somehow thinks it could find "libjpeg" and its includes, but then cannot:

running build_ext
--- using frameworks at /System/Library/Frameworks
building '_imaging' extension
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-
prototypes -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/
Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/
Headers -I/Users/Shared/sage/sage-4.2.alpha1/local/include/freetype2 -
IlibImaging -I/opt/local/include -I/Users/Shared/sage/sage-4.2.alpha1/
local/include -I/usr/local/include -I/usr/include -I/Users/Shared/sage/
sage-4.2.alpha1/local/include/python2.6 -c decode.c -o build/
In file included from decode.c:653:
libImaging/Jpeg.h:11:21: error: jpeglib.h: No such file or directory
In file included from decode.c:653:
libImaging/Jpeg.h:17: error: field 'pub' has incomplete type
libImaging/Jpeg.h:26: error: field 'pub' has incomplete type
libImaging/Jpeg.h:49: error: field 'cinfo' has incomplete type
libImaging/Jpeg.h:62: error: field 'pub' has incomplete type
libImaging/Jpeg.h:90: error: field 'cinfo' has incomplete type
error: command 'gcc' failed with exit status 1

The full install.log is at

But the problem with the binaries *will* occur on any platform, not only Darwin.

So we either have to also include a jpeg.spkg, a tiff.spkg, and so on in Sage (and make sure PIL uses these !!!), or cripple PIL to not use any of these libraries (even if they *were* present).

The former is problematic, as far as I remember e.g. the tiff license is not GPL compatible (apart from the technical aspects), but I might be mistaken. Crippling might render PIL pretty useless, however.

Attachments (1)

trac_7273-sage-bdist.spkg (891 bytes) - added by timdumol 13 years ago.
sage-bdist -- Rebuild PIL in binary build mode.

Download all attachments as: .zip

Change History (15)

comment:1 Changed 13 years ago by was

Crippling might render PIL pretty useless, however.

PIL will still be able to work with PNG, which we do include.


That said, I'm OK with not including PIL in sage-4.2. Whoever really wants PIL in Sage should fix the above issues for a future Sage release.

comment:2 Changed 13 years ago by timdumol

I have made a libjpeg (I needed it for PIL) -- it is available here:

comment:3 Changed 13 years ago by timdumol

As for the TIFF library, it seems to be BSD licensed:, which is GPL compatible, as far as I know. Are there any other libraries needed for inclusion?

I'll gladly make an spkg for libtiff as well, if needed.

comment:4 Changed 13 years ago by timdumol

  • Description modified (diff)
  • Status changed from new to needs_review

Here's a libtiff package: Updated PIL package here: The updated package has explicid dependencies on Sage's libtiff, libpng and libjpeg, and disables TCL/TK.

I'm guessing libtiff and libjpeg have to be voted in?

comment:5 Changed 13 years ago by timdumol

  • Authors set to Tim Dumol
  • Description modified (diff)

Changed PIL package as per William's suggestion at libjpeg and libtiff packages are up at #7344 and #7345 respectively. Patch to automatically rebuild PIL in binary build mode attached.

Changed 13 years ago by timdumol

sage-bdist -- Rebuild PIL in binary build mode.

comment:6 Changed 13 years ago by timdumol

  • Description modified (diff)

comment:7 Changed 13 years ago by was

  • Milestone changed from sage-4.3 to sage-4.2.1

comment:8 Changed 13 years ago by was

It has a patch with this name "trac_7273-sage-bdist.spkg". Huh? I have no idea what that means. I'm totally confused by this "with patch; needs review" ticket.

comment:9 Changed 13 years ago by GeorgSWeber

A reviewer (and, on positive review, an integrator) is IMHO supposed to do the following:

  • apply the patch with the strange name to "$SAGE_ROOT/local/bin/", i.e. the sage_scripts spkg's repository, in order to apply certain changes to the shell-script "sage-bdist" (one can view the contents of this patch from/inside trac just as usual).

And check that everything works fine, i.e. especially in the case of building a Sage binary distribution, neither jpeg nor tiff (even though they migth be present at the host computer where the bdist takes place and/or where the Sage version was built) are added as libraries that the then newly built PIL depends on.

comment:10 Changed 13 years ago by was

  • Status changed from needs_review to positive_review

Sorry, there was some miscommunication. I do not like the design of trac_7273-sage-bdist.spkg, in that I strongly disagree with "sage -bdist" literally rebuilding parts of that Sage install. I would much prefer the following, which would fit well with my workflow:

(1) introduce a SAGE_BINARY_BUILD flag

(2) whenever I'm going to build sage binaries, I set that flag in my build script before ever starting any of the builds.

My understanding is that in fact your pil-1.1.6.p2.spkg in fact fully accomplishes (1) and (2) above already, and that if I simply ignore the patch trac_7273-sage-bdist.spkg then I get everything I want already?

Also, should libtiff and libjpeg be posted to the optional spkg repo? Is there a ticket for that? To do that, I would want a commitment that 2 people are going to maintain them, at least for the next year (say).

OK, I've looked at the PIL spkg and I think it looks very good.

So I'm +1 for putting this new spkg in, and I'm -1 to trac_7273-sage-bdist.spkg.

comment:11 Changed 13 years ago by was

I'm guessing libtiff and libjpeg have to be voted in?

For standard yes, but for optional, the main thing is to get somebody to referee the packages and commit to maintaining them.

comment:12 Changed 13 years ago by mhansen

  • Merged in set to sage-4.2.1.rc0
  • Resolution set to fixed
  • Reviewers set to William Stein
  • Status changed from positive_review to closed

I've merge just the spkg in 4.2.1.rc0.

comment:13 Changed 13 years ago by timdumol

Just to confirm, yes, GeorgSWeber's description was right. The tickets for libtiff and libjpeg are #7345 and #7344. I'm not sure who else can maintain them, though.

comment:14 Changed 12 years ago by kcrisman

  • Report Upstream set to N/A

See also here.

Note: See TracTickets for help on using tickets.