Homebrew / homebrew-core

🍻 Default formulae for the missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
13.75k stars 12.44k forks source link

OCRmyPDF Formula uses Python 3.12 causing it to not work anymore #152153

Closed maurice-schleussinger closed 1 year ago

maurice-schleussinger commented 1 year ago

brew gist-logs <formula> link OR brew config AND brew doctor output

➜  ~ brew config            
HOMEBREW_VERSION: 4.1.17
ORIGIN: https://github.com/Homebrew/brew
HEAD: 35746e0a6ba6c3c5cfe56d99f79d9ec9f52ee15f
Last commit: 30 hours ago
Core tap JSON: 23 Oct 15:23 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_blizzard_avalanche
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 14.0-arm64
CLT: 15.0.0.0.1.1694021235
Xcode: N/A
Rosetta 2: false

➜  ~ brew doctor
Your system is ready to brew.

Verification

What were you trying to do (and why)?

Install and use OCRmyPDF (Formula) on macOS Sonoma (Apple Silicon).

What happened (include all command output)?

brew install OCRmyPDF runs without issue, but the command cannot be used:

➜  ~ ocrmypdf --help
ModuleNotFoundError: No module named '_cffi_backend'
thread '<unnamed>' panicked at 'Python API call failed', /Users/brew/Library/Caches/Homebrew/cargo_cache/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.18.3/src/err/mod.rs:790:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/opt/homebrew/bin/ocrmypdf", line 5, in <module>
    from ocrmypdf.__main__ import run
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/ocrmypdf/__init__.py", line 10, in <module>
    from ocrmypdf import helpers, hocrtransform, pdfa, pdfinfo
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/ocrmypdf/pdfinfo/__init__.py", line 9, in <module>
    from ocrmypdf.pdfinfo.info import Colorspace, Encoding, PageInfo, PdfInfo
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/ocrmypdf/pdfinfo/info.py", line 26, in <module>
    from pdfminer.layout import LTPage, LTTextBox
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/pdfminer/layout.py", line 20, in <module>
    from .pdfinterp import Color
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/pdfminer/pdfinterp.py", line 12, in <module>
    from .pdfdevice import PDFDevice
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/pdfminer/pdfdevice.py", line 17, in <module>
    from .pdfpage import PDFPage
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/pdfminer/pdfpage.py", line 7, in <module>
    from .pdfdocument import PDFDocument, PDFTextExtractionNotAllowed, PDFNoPageLabels
  File "/opt/homebrew/Cellar/ocrmypdf/15.3.0/libexec/lib/python3.12/site-packages/pdfminer/pdfdocument.py", line 23, in <module>
    from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
  File "/opt/homebrew/opt/python-cryptography/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 11, in <module>
    from cryptography.hazmat.primitives.ciphers.base import (
  File "/opt/homebrew/opt/python-cryptography/lib/python3.12/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 10, in <module>
    from cryptography.exceptions import (
  File "/opt/homebrew/opt/python-cryptography/lib/python3.12/site-packages/cryptography/exceptions.py", line 9, in <module>
    from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
pyo3_runtime.PanicException: Python API call failed

This is due to the cryptography library not (fully?) working with Python 3.12. It should work with Python 3.11, so changing this line in the formula should be sufficient for now.

What did you expect to happen?

Run the command without issue.

Step-by-step reproduction instructions (by running brew commands)

brew install OCRmyPDF
ocrmypdf --help
Bo98 commented 1 year ago

Hmm that's odd. What's the output of brew info cffi?

maurice-schleussinger commented 1 year ago

Hmm that's odd. What's the output of brew info cffi?

➜  ~ brew info cffi       
==> cffi: stable 1.16.0 (bottled)
C Foreign Function Interface for Python
https://cffi.readthedocs.io/en/latest/
/opt/homebrew/Cellar/cffi/1.16.0 (37 files, 583.3KB) *
  Poured from bottle using the formulae.brew.sh API on 2023-10-13 at 12:39:49
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c/cffi.rb
License: MIT
==> Dependencies
Build: python@3.10 ✘, python@3.11 ✔, python@3.12 ✔
Required: pycparser ✘, python-setuptools ✔
==> Analytics
install: 72,909 (30 days), 116,554 (90 days), 241,071 (365 days)
install-on-request: 14,609 (30 days), 14,937 (90 days), 15,704 (365 days)
build-error: 14 (30 days)
cho-m commented 1 year ago
/opt/homebrew/Cellar/cffi/1.16.0 (37 files, 583.3KB) *
  Poured from bottle using the formulae.brew.sh API on 2023-10-13 at 12:39:49

Strange. You didn't get latest revision bump #150944.

Other users have also reported not getting revision bumps in #150336 so I wonder if JSON API has a bug.

branchvincent commented 1 year ago

Another instance at https://github.com/Homebrew/homebrew-core/issues/152280#issuecomment-1778467254 with six and #149418

maurice-schleussinger commented 1 year ago

I ran brew update today and it included cffi and python-cryptography:

➜  ~ brew update   
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
azion-cli           haiti               snyk-cli            three-body
==> New Casks
batchoutput-pdf
==> Outdated Formulae
black                      node                       pyyaml
cffi                       pycparser                  ruff
harfbuzz                   python-cryptography
mypy                       python-packaging
==> Outdated Casks
focus

You have 10 outdated formulae and 1 outdated cask installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

OCRmyPDF now works without issue. So this particular issue is resolved.