87 lines
2.8 KiB
Ruby
87 lines
2.8 KiB
Ruby
class Pillow < Formula
|
|
desc "Friendly PIL fork (Python Imaging Library)"
|
|
homepage "https://python-pillow.org"
|
|
url "https://files.pythonhosted.org/packages/8c/92/2975b464d9926dc667020ed1abfa6276e68c3571dcb77e43347e15ee9eed/Pillow-9.2.0.tar.gz"
|
|
sha256 "75e636fd3e0fb872693f23ccb8a5ff2cd578801251f3a4f6854c6a5d437d3c04"
|
|
license "HPND"
|
|
revision 1
|
|
head "https://github.com/python-pillow/Pillow.git", branch: "master"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "9a3eb1845a35dafbd990d12cc12cd9e0e6de41098ac67617b53a744772896942"
|
|
sha256 cellar: :any, arm64_big_sur: "d13473d06a1e7fd317d1b8be831e318ebf00c7b49798363110acdaf3ba5f5fb3"
|
|
sha256 cellar: :any, monterey: "0c327a8af9a584b658199789a366a11e222f04fe82794047fcbb4dad3684547b"
|
|
sha256 cellar: :any, big_sur: "bbe1d3a93c30fe441d98ac5d2666b4f9acf5d8f6bbc0fbd750f329c77e0e7940"
|
|
sha256 cellar: :any, catalina: "4c4319607c799298f960486a27eb275939671ba92dab58866e29d3af089184c5"
|
|
sha256 x86_64_linux: "7a47d6a91bc57a3d38adbb92bc3987b36d5c1bd5c47ca9e04e4a15e2b3b64640"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "python@3.10" => [:build, :test]
|
|
depends_on "python@3.8" => [:build, :test]
|
|
depends_on "python@3.9" => [:build, :test]
|
|
depends_on "jpeg-turbo"
|
|
depends_on "libimagequant"
|
|
depends_on "libraqm"
|
|
depends_on "libtiff"
|
|
depends_on "libxcb"
|
|
depends_on "little-cms2"
|
|
depends_on "openjpeg"
|
|
depends_on "tcl-tk"
|
|
depends_on "webp"
|
|
|
|
uses_from_macos "zlib"
|
|
|
|
def pythons
|
|
deps.map(&:to_formula)
|
|
.select { |f| f.name.match?(/^python@\d\.\d+$/) }
|
|
.map { |f| f.opt_libexec/"bin/python" }
|
|
end
|
|
|
|
def install
|
|
build_ext_args = %w[
|
|
--enable-tiff
|
|
--enable-freetype
|
|
--enable-lcms
|
|
--enable-webp
|
|
--enable-xcb
|
|
]
|
|
|
|
install_args = %w[
|
|
--single-version-externally-managed
|
|
--record=installed.txt
|
|
]
|
|
|
|
ENV["MAX_CONCURRENCY"] = ENV.make_jobs.to_s
|
|
deps.each do |dep|
|
|
next if dep.build? || dep.test?
|
|
|
|
ENV.prepend "CPPFLAGS", "-I#{dep.to_formula.opt_include}"
|
|
ENV.prepend "LDFLAGS", "-L#{dep.to_formula.opt_lib}"
|
|
end
|
|
|
|
# Useful in case of build failures.
|
|
inreplace "setup.py", "DEBUG = False", "DEBUG = True"
|
|
|
|
pythons.each do |python|
|
|
prefix_site_packages = prefix/Language::Python.site_packages(python)
|
|
system python, "setup.py",
|
|
"build_ext", *build_ext_args,
|
|
"install", *install_args,
|
|
"--install-lib=#{prefix_site_packages}"
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.py").write <<~EOS
|
|
from PIL import Image
|
|
im = Image.open("#{test_fixtures("test.jpg")}")
|
|
print(im.format, im.size, im.mode)
|
|
EOS
|
|
|
|
pythons.each do |python|
|
|
assert_equal "JPEG (1, 1) RGB", shell_output("#{python} test.py").chomp
|
|
end
|
|
end
|
|
end
|