forked from codedreality/homebrew-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pillow.rb
71 lines (61 loc) · 3.25 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
desc "Python Imaging Library fork"
homepage "https://github.com/python-imaging/Pillow"
url "https://github.com/python-pillow/Pillow/archive/3.4.2.tar.gz"
sha256 "0ee762ab924e004b7e69643b44e82cf65e0fa1f16862e11bd821950dbbc5f3d3"
head "https://github.com/python-imaging/Pillow.git"
bottle do
cellar :any
sha256 "c6f99602def8463818a29f320ba3ce9df72eb167ec09c75b5169cc864e315ad2" => :sierra
sha256 "42b7f922dd62848f3039fe1e9c0729c7432bf9a6bfcbc0cee59484a557dae19c" => :el_capitan
sha256 "4df8f0e2fc60da1815f5d8c6a32246f405b19100adbe0845437954bea828c299" => :yosemite
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 "openjpeg" => :optional
resource "nose" do
url "https://files.pythonhosted.org/packages/58/a5/0dc93c3ec33f4e281849523a5a913fa1eea9a3068acfa754d44d88107a44/nose-1.3.7.tar.gz"
sha256 "f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"
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["openjpeg"].opt_prefix}/lib', '#{Formula["openjpeg"].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
system python, "setup.py", "build_ext"
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