116 lines
4.8 KiB
Ruby
116 lines
4.8 KiB
Ruby
class Ocrmypdf < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Adds an OCR text layer to scanned PDF files"
|
|
homepage "https://github.com/jbarlow83/OCRmyPDF"
|
|
url "https://files.pythonhosted.org/packages/ef/b2/b9d4d796d485852f583c34d16d20f20be3f5926049e859e1dd1d991205d9/ocrmypdf-7.0.0.tar.gz"
|
|
sha256 "4cd434fd2d71993ed9d66d5363c56707e5f8007c382793ac0024e34778df66ec"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "1d80f46e19d294271caa65389d77230c9ff7eac9adb4394a14ff6bc070dfda87" => :high_sierra
|
|
sha256 "801e7f55e80432cfe9a7078d27154c162400eac16386fbe9d71e595c32ca3946" => :sierra
|
|
sha256 "7a48d7c099d1f2869b39f7be98cd243b0792f3a2b86e2680229b1f574663178f" => :el_capitan
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "exempi"
|
|
depends_on "freetype"
|
|
depends_on "ghostscript"
|
|
depends_on "jbig2enc"
|
|
depends_on "jpeg"
|
|
depends_on "leptonica"
|
|
depends_on "libpng"
|
|
depends_on "pngquant"
|
|
depends_on "python"
|
|
depends_on "qpdf"
|
|
depends_on "tesseract"
|
|
depends_on "unpaper"
|
|
|
|
resource "cffi" do
|
|
url "https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz"
|
|
sha256 "e90f17980e6ab0f3c2f3730e56d1fe9bcba1891eeea58966e89d352492cc74f4"
|
|
end
|
|
|
|
resource "img2pdf" do
|
|
url "https://files.pythonhosted.org/packages/7e/a2/4f06081f674920be757d894b4bab874e6a3b5227e730cb7618430b366e69/img2pdf-0.2.4.tar.gz"
|
|
sha256 "140b70fa3a3bfb54e92947818cee01483a4f1492b5d1d02b0f649257f5ffc9ae"
|
|
end
|
|
|
|
resource "pikepdf" do
|
|
url "https://files.pythonhosted.org/packages/50/03/f5af2251b8c206a7768a315c0487572a25e8225b6c9549d0b142862626c0/pikepdf-0.2.2.tar.gz"
|
|
sha256 "88b01fa8f87db20b345c76e1fa63a5b82c5c4a5e0f3702bdb8a1328fbc25a728"
|
|
end
|
|
|
|
resource "Pillow" do
|
|
url "https://files.pythonhosted.org/packages/d3/c4/b45b9c0d549f482dd072055e2d3ced88f3b977f7b87c7a990228b20e7da1/Pillow-5.2.0.tar.gz"
|
|
sha256 "f8b3d413c5a8f84b12cd4c5df1d8e211777c9852c6be3ee9c094b626644d3eab"
|
|
end
|
|
|
|
resource "pybind11" do
|
|
url "https://files.pythonhosted.org/packages/95/30/788a5c943f1399e05b52148504dffa7a801ea52eb5bb5cac0cc828306278/pybind11-2.2.3.tar.gz"
|
|
sha256 "87ff3ae777d9326349af5272974581270b2a0909b2392dc0cc57eb28ce23bcc3"
|
|
end
|
|
|
|
resource "pycparser" do
|
|
url "https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz"
|
|
sha256 "99a8ca03e29851d96616ad0404b4aad7d9ee16f25c9f9708a11faf2810f7b226"
|
|
end
|
|
|
|
resource "python-xmp-toolkit" do
|
|
url "https://files.pythonhosted.org/packages/5b/0b/4f95bc448e4e30eb0e831df0972c9a4b3efa8f9f76879558e9123215a7b7/python-xmp-toolkit-2.0.1.tar.gz"
|
|
sha256 "f8d912946ff9fd46ed5c7c355aa5d4ea193328b3f200909ef32d9a28a1419a38"
|
|
end
|
|
|
|
resource "pytz" do
|
|
url "https://files.pythonhosted.org/packages/ca/a9/62f96decb1e309d6300ebe7eee9acfd7bccaeedd693794437005b9067b44/pytz-2018.5.tar.gz"
|
|
sha256 "ffb9ef1de172603304d9d2819af6f5ece76f2e85ec10692a524dd876e72bf277"
|
|
end
|
|
|
|
resource "reportlab" do
|
|
url "https://files.pythonhosted.org/packages/87/f9/53b34c58d3735a6df7d5c542bf4de60d699cfa6035e113ca08b3ecdcca3f/reportlab-3.4.0.tar.gz"
|
|
sha256 "5beaf35e59dfd5ebd814fdefd76908292e818c982bd7332b5d347dfd2f01c343"
|
|
end
|
|
|
|
resource "ruffus" do
|
|
url "https://files.pythonhosted.org/packages/ea/32/5048607dd7a9104406789b15fb4078e774121b23190c9e464d4dd1f7ed89/ruffus-2.7.0.tar.gz"
|
|
sha256 "4bd46461d31aa532357019a33d8045f4e57e52f4ee41643b5b3a7372e380cae0"
|
|
end
|
|
|
|
def install
|
|
venv = virtualenv_create(libexec, "python3")
|
|
|
|
resource("Pillow").stage do
|
|
inreplace "setup.py" do |s|
|
|
sdkprefix = MacOS::CLT.installed? ? "" : MacOS.sdk_path
|
|
s.gsub! "openjpeg.h", "probably_not_a_header_called_this_eh.h"
|
|
s.gsub! "ZLIB_ROOT = None", "ZLIB_ROOT = ('#{sdkprefix}/usr/lib', '#{sdkprefix}/usr/include')"
|
|
s.gsub! "JPEG_ROOT = None", "JPEG_ROOT = ('#{Formula["jpeg"].opt_prefix}/lib', '#{Formula["jpeg"].opt_prefix}/include')"
|
|
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.append "CFLAGS", "-I#{MacOS.sdk_path}/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers" unless MacOS::CLT.installed?
|
|
venv.pip_install Pathname.pwd
|
|
end
|
|
|
|
# pybind11 must be installed before pikepdf
|
|
venv.pip_install "pybind11"
|
|
|
|
res = resources.map(&:name).to_set - ["Pillow", "pybind11"]
|
|
res.each do |r|
|
|
venv.pip_install resource(r)
|
|
end
|
|
|
|
venv.pip_install_and_link buildpath
|
|
end
|
|
|
|
test do
|
|
# Since we use Python 3, we require a UTF-8 locale
|
|
ENV["LC_ALL"] = "en_US.UTF-8"
|
|
|
|
system "#{bin}/ocrmypdf", "-f", "-q", "--deskew",
|
|
test_fixtures("test.pdf"), "ocr.pdf"
|
|
assert_predicate testpath/"ocr.pdf", :exist?
|
|
end
|
|
end
|