From 9681c0e05a4308c8c889fd0fcb56997a1ff38d05 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 10 Jul 2018 21:37:38 -0700 Subject: [PATCH] Eliminate Homebrew autobrewing The Homebrew-core does such a good job of keeping things up to date there is little to point to a private infrastructure. --- .travis.yml | 19 --------- .travis/autobrew.py | 93 --------------------------------------------- .travis/osx_brew.sh | 23 ----------- 3 files changed, 135 deletions(-) delete mode 100644 .travis/autobrew.py delete mode 100644 .travis/osx_brew.sh diff --git a/.travis.yml b/.travis.yml index eeba191a..b66b7ffd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,10 +27,6 @@ addons: - tesseract-ocr-eng - tesseract-ocr-fra -env: - global: - - secure: "hsf6MT+n2x3OiDM2fQyJZdV0/PWYmv81LdVqC6cfnHBE/8N3DloJRqQ7WfO14TxhiK9PEC7MpyCj0lSabUHEO7gSH6Vks6I1asoSkt8S9/bSMlhT4hei+pwVpeGEiU5xHVATNjY+D919VC3IFvc3XmjT74h/2SLhaZ+jhEmDggM=" # HOMEBREW_OCRMYPDF_TOKEN - matrix: include: - os: linux @@ -94,18 +90,3 @@ deploy: tags: true condition: $TRAVIS_PYTHON_VERSION == "3.6" && $TRAVIS_OS_NAME == "linux" skip_upload_docs: true - - # null deploy for osx - # we really just want to run after_deploy *after* pypi upload is done, but - # after_deploy on runs if a given box deployed -- provider: script - script: /usr/bin/true - on: - branch: master - tags: true - condition: $TRAVIS_OS_NAME == "osx" - -after_deploy: | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - bash .travis/osx_brew.sh - fi diff --git a/.travis/autobrew.py b/.travis/autobrew.py deleted file mode 100644 index 35b7c3fa..00000000 --- a/.travis/autobrew.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 -# © 2017-18 James R. Barlow: github.com/jbarlow83 - -from string import Template -from subprocess import run, PIPE -import re - -recipe_template = Template(""" -class Ocrmypdf < Formula - include Language::Python::Virtualenv - - desc "Adds an OCR text layer to scanned PDF files" - homepage "https://github.com/jbarlow83/OCRmyPDF" - ${ocrmypdf_url} - ${ocrmypdf_sha256} - - depends_on "pkg-config" => :build - depends_on "mupdf-tools" => :build # statically links libmupdf.a - depends_on "freetype" - depends_on "ghostscript" - depends_on "jpeg" - depends_on "libpng" - depends_on "python" - depends_on "qpdf" - depends_on "tesseract" - depends_on "unpaper" - -${resources} - 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 - - res = resources.map(&:name).to_set - ["Pillow"] - - 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 -""") - -def main(): - p = run(['poet', '--single', 'ocrmypdf'], - encoding='utf-8', stdout=PIPE, check=True) - - ocrmypdf_lines = p.stdout.splitlines() - ocrmypdf_url = ocrmypdf_lines[1].strip() - ocrmypdf_sha256 = ocrmypdf_lines[2].strip() - - ocrmypdf_version = re.search( - r'ocrmypdf-(.+)\.tar.*', ocrmypdf_url).group(1) - print(f"Autobrewing {ocrmypdf_version}") - - p = run(['poet', '--resources', 'ocrmypdf'], - encoding='utf-8', stdout=PIPE, check=True) - - poet_resources = p.stdout - - # Remove the duplicate "ocrmypdf" resource block - all_resources = poet_resources.split('resource') - kept_resources = [block for block in all_resources if 'ocrmypdf' not in block] - resources = 'resource'.join(kept_resources) - - with open('ocrmypdf.rb', 'w') as out: - out.write(recipe_template.substitute(**locals())) - - -if __name__ == '__main__': - main() diff --git a/.travis/osx_brew.sh b/.travis/osx_brew.sh deleted file mode 100644 index 540af33e..00000000 --- a/.travis/osx_brew.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# © 2017 James R. Barlow: github.com/jbarlow83 -set -uo pipefail -set -x - -pip3 install homebrew-pypi-poet -python3 .travis/autobrew.py -cat ocrmypdf.rb - -# brew audit crashes Travis -#brew audit ocrmypdf.rb - -# Important: disable debug output so token is hidden -set +x -git clone https://$HOMEBREW_OCRMYPDF_TOKEN@github.com/jbarlow83/homebrew-ocrmypdf.git -set -x - -pushd homebrew-ocrmypdf -cp ../ocrmypdf.rb Formula/ocrmypdf.rb -git add Formula/ocrmypdf.rb -git commit -m "homebrew-ocrmypdf: automatic release $TRAVIS_BUILD_NUMBER $TRAVIS_TAG" -git push origin master -popd