forked from codedreality/homebrew-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pillow.rb
71 lines (61 loc) · 3.32 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
class Pillow < Formula
homepage "https://github.com/python-imaging/Pillow"
url "https://github.com/python-pillow/Pillow/archive/3.3.0.tar.gz"
sha256 "ae2fbb500c81100f7e374545d008019e6f90918386f620625c3b3b98faf88414"
head "https://github.com/python-imaging/Pillow.git"
bottle do
cellar :any
sha256 "55632af55d7807a0155741afa47fa55df03ab90a7e2205f416a0c3ba67c26346" => :el_capitan
sha256 "ca74fb008d6afc4096bf5a7bde183102ad5811b7437d68e85e03595fddb87a0d" => :yosemite
sha256 "3a13cfb52b885d5d5e7cb9f0c9b49d7d91cd661f3f0aafbe0e823709190cb65d" => :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|
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