138 lines
6.1 KiB
Ruby
138 lines
6.1 KiB
Ruby
class Ocrmypdf < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Adds an OCR text layer to scanned PDF files"
|
|
homepage "https://ocrmypdf.readthedocs.io/en/latest/"
|
|
url "https://files.pythonhosted.org/packages/c1/d3/42aced6295de36a7a1018d73bd5bea8849dcbae7254b1039f2e381bfe631/ocrmypdf-14.0.2.tar.gz"
|
|
sha256 "68521c088b6b2fb1a77d6e72468e1484d68f0e948aa4d507f5db14449b70c5f1"
|
|
license "MPL-2.0"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_ventura: "a19b6bfcdfba520ad72c010bd16ef123bfc504aeac1c44d690682a7db9b82632"
|
|
sha256 cellar: :any, arm64_monterey: "3ae02a495d4f6d703e143735da077016d9e6905e5aed9f9bdc63b0261ac32103"
|
|
sha256 cellar: :any, arm64_big_sur: "7f628f6cafea762f94785cf43be021994ba1f2492bfb6d1bef31ff5c153abaf6"
|
|
sha256 cellar: :any, ventura: "ef54d6b160cc4628af031779a9b4cb1a0d84ab613f76424b9426c1d84b0c3660"
|
|
sha256 cellar: :any, monterey: "fc51ecde8be0860570cc8ed320418247214cc36d775fc8eee6477ff0ef81d0d1"
|
|
sha256 cellar: :any, big_sur: "3c26362a05029150074dc7b839dea36ddd656712bbcd97abf5522f5f1b7a9f95"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "74b86d933c3895f8ff2ccb70873c9f309685ba4745b2549bac97f5a0b6f3d0e4"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "rust" => :build
|
|
depends_on "freetype"
|
|
depends_on "ghostscript"
|
|
depends_on "jbig2enc"
|
|
depends_on "libpng"
|
|
depends_on "pillow"
|
|
depends_on "pngquant"
|
|
depends_on "pybind11"
|
|
depends_on "python@3.11"
|
|
depends_on "qpdf"
|
|
depends_on "tesseract"
|
|
depends_on "unpaper"
|
|
|
|
uses_from_macos "libffi", since: :catalina
|
|
uses_from_macos "libxml2"
|
|
uses_from_macos "libxslt"
|
|
|
|
fails_with gcc: "5"
|
|
|
|
resource "cffi" do
|
|
url "https://files.pythonhosted.org/packages/2b/a8/050ab4f0c3d4c1b8aaa805f70e26e84d0e27004907c5b8ecc1d31815f92a/cffi-1.15.1.tar.gz"
|
|
sha256 "d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9"
|
|
end
|
|
|
|
resource "charset-normalizer" do
|
|
url "https://files.pythonhosted.org/packages/96/d7/1675d9089a1f4677df5eb29c3f8b064aa1e70c1251a0a8a127803158942d/charset-normalizer-3.0.1.tar.gz"
|
|
sha256 "ebea339af930f8ca5d7a699b921106c6e29c617fe9606fa7baa043c1cdae326f"
|
|
end
|
|
|
|
resource "coloredlogs" do
|
|
url "https://files.pythonhosted.org/packages/cc/c7/eed8f27100517e8c0e6b923d5f0845d0cb99763da6fdee00478f91db7325/coloredlogs-15.0.1.tar.gz"
|
|
sha256 "7c991aa71a4577af2f82600d8f8f3a89f936baeaf9b50a9c197da014e5bf16b0"
|
|
end
|
|
|
|
resource "cryptography" do
|
|
url "https://files.pythonhosted.org/packages/12/e3/c46c274cf466b24e5d44df5d5cd31a31ff23e57f074a2bb30931a8c9b01a/cryptography-39.0.0.tar.gz"
|
|
sha256 "f964c7dcf7802d133e8dbd1565914fa0194f9d683d82411989889ecd701e8adf"
|
|
end
|
|
|
|
resource "deprecation" do
|
|
url "https://files.pythonhosted.org/packages/5a/d3/8ae2869247df154b64c1884d7346d412fed0c49df84db635aab2d1c40e62/deprecation-2.1.0.tar.gz"
|
|
sha256 "72b3bde64e5d778694b0cf68178aed03d15e15477116add3fb773e581f9518ff"
|
|
end
|
|
|
|
resource "humanfriendly" do
|
|
url "https://files.pythonhosted.org/packages/cc/3f/2c29224acb2e2df4d2046e4c73ee2662023c58ff5b113c4c1adac0886c43/humanfriendly-10.0.tar.gz"
|
|
sha256 "6b0b831ce8f15f7300721aa49829fc4e83921a9a301cc7f606be6686a2288ddc"
|
|
end
|
|
|
|
resource "img2pdf" do
|
|
url "https://files.pythonhosted.org/packages/95/b5/f933f482a811fb9a7b3707f60e28f2925fed84726e5a6283ba07fdd54f49/img2pdf-0.4.4.tar.gz"
|
|
sha256 "8ec898a9646523fd3862b154f3f47cd52609c24cc3e2dc1fb5f0168f0cbe793c"
|
|
end
|
|
|
|
resource "lxml" do
|
|
url "https://files.pythonhosted.org/packages/06/5a/e11cad7b79f2cf3dd2ff8f81fa8ca667e7591d3d8451768589996b65dec1/lxml-4.9.2.tar.gz"
|
|
sha256 "2455cfaeb7ac70338b3257f41e21f0724f4b5b0c0e7702da67ee6c3640835b67"
|
|
end
|
|
|
|
resource "packaging" do
|
|
url "https://files.pythonhosted.org/packages/6b/f7/c240d7654ddd2d2f3f328d8468d4f1f876865f6b9038b146bec0a6737c65/packaging-22.0.tar.gz"
|
|
sha256 "2198ec20bd4c017b8f9717e00f0c8714076fc2fd93816750ab48e2c41de2cfd3"
|
|
end
|
|
|
|
resource "pdfminer.six" do
|
|
url "https://files.pythonhosted.org/packages/ac/6e/89c532d108e362cbaf76fdb972e7a5e85723c225f08e1646fb86878d4f7f/pdfminer.six-20221105.tar.gz"
|
|
sha256 "8448ab7b939d18b64820478ecac5394f482d7a79f5f7eaa7703c6c959c175e1d"
|
|
end
|
|
|
|
resource "pikepdf" do
|
|
url "https://files.pythonhosted.org/packages/22/58/744d5e3229a234e9a5a92572e817fab5ae08b4d74420eb7deb0f78599054/pikepdf-6.2.7.tar.gz"
|
|
sha256 "7f1402410feb461bb179adb382ee43d20aea26feb126a299731aa62989e299ca"
|
|
end
|
|
|
|
resource "pluggy" do
|
|
url "https://files.pythonhosted.org/packages/a1/16/db2d7de3474b6e37cbb9c008965ee63835bba517e22cdb8c35b5116b5ce1/pluggy-1.0.0.tar.gz"
|
|
sha256 "4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"
|
|
end
|
|
|
|
resource "pycparser" do
|
|
url "https://files.pythonhosted.org/packages/5e/0b/95d387f5f4433cb0f53ff7ad859bd2c6051051cebbb564f139a999ab46de/pycparser-2.21.tar.gz"
|
|
sha256 "e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"
|
|
end
|
|
|
|
resource "reportlab" do
|
|
url "https://files.pythonhosted.org/packages/b8/ac/10d68a650b321bd8c4d8cbefd9994e7727d57b381c9bdb0a013273011e62/reportlab-3.6.12.tar.gz"
|
|
sha256 "b13cebf4e397bba14542bcd023338b6ff2c151a3a12aabca89eecbf972cb361a"
|
|
end
|
|
|
|
resource "tqdm" do
|
|
url "https://files.pythonhosted.org/packages/c1/c2/d8a40e5363fb01806870e444fc1d066282743292ff32a9da54af51ce36a2/tqdm-4.64.1.tar.gz"
|
|
sha256 "5f4f682a004951c1b450bc753c710e9280c5746ce6ffedee253ddbcbf54cf1e4"
|
|
end
|
|
|
|
def install
|
|
venv = virtualenv_create(libexec, "python3.11")
|
|
resource("reportlab").stage do
|
|
(Pathname.pwd/"local-setup.cfg").write <<~EOS
|
|
[FREETYPE_PATHS]
|
|
lib=#{Formula["freetype"].opt_lib}
|
|
inc=#{Formula["freetype"].opt_include}
|
|
EOS
|
|
venv.pip_install Pathname.pwd
|
|
end
|
|
venv.pip_install resources.reject { |r| r.name == "reportlab" }
|
|
venv.pip_install_and_link buildpath
|
|
|
|
bash_completion.install "misc/completion/ocrmypdf.bash" => "ocrmypdf"
|
|
fish_completion.install "misc/completion/ocrmypdf.fish"
|
|
end
|
|
|
|
test do
|
|
system "#{bin}/ocrmypdf", "-f", "-q", "--deskew",
|
|
test_fixtures("test.pdf"), "ocr.pdf"
|
|
assert_predicate testpath/"ocr.pdf", :exist?
|
|
end
|
|
end
|