forked from codedreality/homebrew-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpillow.rb
75 lines (64 loc) · 3.48 KB
/
pillow.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
class Pillow < Formula
homepage "https://github.com/python-imaging/Pillow"
url "https://github.com/python-pillow/Pillow/archive/3.2.0.tar.gz"
sha256 "eb4b9c2956e38f89d588a0d0af0e27a03f1e1d2be705a828bbd12cfba0b020fa"
head "https://github.com/python-imaging/Pillow.git"
bottle do
cellar :any
sha256 "11e19d84469393946936b84d52476480b088a641c03b54ac203349dc06cd34b9" => :el_capitan
sha256 "8738b60b1bc1c946d584c595f349426406ef8c59f083fc92b454bfb05c234fd5" => :yosemite
sha256 "3e7c1c8e11c5b56b0aeae3c85def5f924e7f2429be2d0dd38200724bd0eb986c" => :mavericks
end
# waiting on upstream resolution of JPEG2000 issues
# https://github.com/python-pillow/Pillow/issues/767
# option "with-openjpeg", "Enable JPEG2000 support"
option "without-python", "Build without python2 support"
depends_on :python3 => :optional
depends_on "freetype"
depends_on "jpeg"
depends_on "libtiff" => :recommended
depends_on "little-cms2" => :recommended
depends_on "webp" => :recommended
# depends_on "homebrew/versions/openjpeg21" if build.with? "openjpeg"
resource "nose" do
url "https://pypi.python.org/packages/source/n/nose/nose-1.3.3.tar.gz"
sha256 "b40c2ff268beb85356ada25f626ca0dabc89705f31051649772cf00fc9510326"
end
def install
inreplace "setup.py" do |s|
# Don't automatically detect Tcl or Tk in /Library
# Fixes https://github.com/Homebrew/homebrew-python/issues/190
s.gsub! '"/Library/Frameworks",', ""
sdkprefix = MacOS::CLT.installed? ? "" : MacOS.sdk_path
s.gsub! "ZLIB_ROOT = None", "ZLIB_ROOT = ('#{sdkprefix}/usr/lib', '#{sdkprefix}/usr/include')"
s.gsub! "LCMS_ROOT = None", "LCMS_ROOT = ('#{Formula["little-cms2"].opt_prefix}/lib', '#{Formula["little-cms2"].opt_prefix}/include')" if build.with? "little-cms2"
s.gsub! "JPEG_ROOT = None", "JPEG_ROOT = ('#{Formula["jpeg"].opt_prefix}/lib', '#{Formula["jpeg"].opt_prefix}/include')"
# s.gsub! "JPEG2K_ROOT = None", "JPEG2K_ROOT = ('#{Formula["openjpeg21"].opt_prefix}/lib', '#{Formula["openjpeg21"].opt_prefix}/include')" if build.with? "openjpeg"
s.gsub! "TIFF_ROOT = None", "TIFF_ROOT = ('#{Formula["libtiff"].opt_prefix}/lib', '#{Formula["libtiff"].opt_prefix}/include')" if build.with? "libtiff"
s.gsub! "FREETYPE_ROOT = None", "FREETYPE_ROOT = ('#{Formula["freetype"].opt_prefix}/lib', '#{Formula["freetype"].opt_prefix}/include')"
end
# avoid triggering "helpful" distutils code that doesn't recognize Xcode 7 .tbd stubs
ENV.delete "SDKROOT"
ENV.append "CFLAGS", "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" unless MacOS::CLT.installed?
Language::Python.each_python(build) do |python, version|
resource("nose").stage do
system python, *Language::Python.setup_install_args(libexec)
nose_path = libexec/"lib/python#{version}/site-packages"
dest_path = lib/"python#{version}/site-packages"
mkdir_p dest_path
(dest_path/"homebrew-pillow-nose.pth").atomic_write(nose_path.to_s + "\n")
ENV.append_path "PYTHONPATH", nose_path
end
# don't accidentally discover openjpeg since it isn't working
system python, "setup.py", "build_ext", "--disable-jpeg2000" # if build.without? "openjpeg"
system python, *Language::Python.setup_install_args(prefix)
end
prefix.install "Tests"
end
test do
cp_r prefix/"Tests", testpath
Language::Python.each_python(build) do |python, _version|
system "#{python} -m nose Tests/test_*"
end
end
end