homebrew-core/Formula/pil.rb
Samuel John f6e80bdea2 Python 2.x and 3.x support
New `depends_on :python` Dependency.
New `depends_on :python3` Dependency.

To avoid having multiple formulae with endings -py2 and -py3,
we will handle support for different pythons (2.x vs. 3.x)
in the same formula.
Further brewed vs. external python will be transparently supported.

The formula also gets a new object `python`, which is false if
no Python is available or the user has disabled it. Otherwise
it is defined and provides several support methods:

python.site_packages # the site-packages in the formula's Cellar
python.global_site_packages
python.binary # the full path to the python binary
python.prefix
python.version
python.version.major
python.version.minor
python.xy # => e.g. "python2.7"
python.incdir # includes of python
python.libdir # the python dylib library
python.pkg_config_path # used internally by brew
python.from_osx?
python.framework?
python.universal?
python.pypy?
python.standard_caveats # Text to set PYTHONPATH for python.from_osx?
python.if3then3 # => "" for 2.x and to "3" for 3.x.

Further, to avoid code duplication, `python` takes an optional
block that is run twice if the formula defines depends_on
:python AND :python3.

python do
  system python, 'setup.py', "--prefix=#{prefix}"
end

Read more in the Homebrew wiki.
2013-06-03 17:29:43 +02:00

66 lines
2.1 KiB
Ruby

require 'formula'
class Pil < Formula
homepage 'http://www.pythonware.com/products/pil/'
url 'http://effbot.org/downloads/Imaging-1.1.7.tar.gz'
sha1 '76c37504251171fda8da8e63ecb8bc42a69a5c81'
depends_on :freetype
depends_on :python
depends_on 'jpeg' => :recommended
depends_on 'little-cms' => :optional
# The patch is to fix a core dump in Bug in PIL's quantize() with 64 bit architectures.
# http://mail.python.org/pipermail/image-sig/2012-June/007047.html
def patches
DATA
end
def install
# Find the arch for the Python we are building against.
# We remove 'ppc' support, so we can pass Intel-optimized CFLAGS.
archs = archs_for_command(python.binary)
archs.remove_ppc!
# Can't build universal on 32-bit hardware. See:
# https://github.com/mxcl/homebrew/issues/5844
archs.delete :x86_64 if Hardware.is_32_bit?
ENV['ARCHFLAGS'] = archs.as_arch_flags
freetype = Formula.factory('freetype')
freetype_prefix = Formula.factory('freetype').installed? ? freetype.prefix : MacOS::X11.prefix
inreplace "setup.py" do |s|
# Tell setup where Freetype2 is on 10.5/10.6
s.gsub! 'add_directory(include_dirs, "/sw/include/freetype2")',
"add_directory(include_dirs, \"#{freetype_prefix}/include\")"
s.gsub! 'add_directory(include_dirs, "/sw/lib/freetype2/include")',
"add_directory(library_dirs, \"#{freetype_prefix}/lib\")"
# Tell setup where our stuff is
s.gsub! 'add_directory(library_dirs, "/sw/lib")',
"add_directory(library_dirs, \"#{HOMEBREW_PREFIX}/lib\")"
s.gsub! 'add_directory(include_dirs, "/sw/include")',
"add_directory(include_dirs, \"#{HOMEBREW_PREFIX}/include\")"
end
python do
system python, "setup.py", "install" ,"--prefix=#{prefix}"
end
end
end
__END__
--- a/libImaging/Quant.c
+++ b/libImaging/Quant.c
@@ -914,7 +914,7 @@
unsigned long bestdist,bestmatch,dist;
unsigned long initialdist;
HashTable h2;
- int pixelVal;
+ unsigned long pixelVal;
h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp);
for (i=0;i<nPixels;i++) {