From 4044280ddfaf8a220852adbc234e982724e048ae Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Fri, 11 Oct 2024 09:43:36 -0700 Subject: [PATCH 1/2] ranger: migrate to `python@3.13` --- Formula/r/ranger.rb | 59 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/Formula/r/ranger.rb b/Formula/r/ranger.rb index 5089a7d627e0b..60aa9acbeea83 100644 --- a/Formula/r/ranger.rb +++ b/Formula/r/ranger.rb @@ -3,12 +3,19 @@ class Ranger < Formula desc "File browser" homepage "https://ranger.github.io" - url "https://ranger.github.io/ranger-1.9.3.tar.gz" - sha256 "ce088a04c91c25263a9675dc5c43514b7ec1b38c8ea43d9a9d00923ff6cdd251" license "GPL-3.0-or-later" revision 2 head "https://github.com/ranger/ranger.git", branch: "master" + stable do + url "https://ranger.github.io/ranger-1.9.3.tar.gz" + sha256 "ce088a04c91c25263a9675dc5c43514b7ec1b38c8ea43d9a9d00923ff6cdd251" + + # Drop `imghdr` for python 3.13 + # Backport of https://github.com/ranger/ranger/commit/9c0d3ba3495bac80142fad518e29b9061be94cc6 + patch :DATA + end + bottle do rebuild 3 sha256 cellar: :any_skip_relocation, arm64_sequoia: "d658a012014c41c2ff480390de60f9b7d14de34e7f207bd22646a44944ba4ef3" @@ -21,7 +28,7 @@ class Ranger < Formula sha256 cellar: :any_skip_relocation, x86_64_linux: "f1c019d60c241b2080cd53ad4fc8e24bb8c14df3345d09a4f202a798d51a1a8e" end - depends_on "python@3.12" + depends_on "python@3.13" def install virtualenv_install_with_resources @@ -34,7 +41,51 @@ def install (testpath/"test.py").write code assert_equal code, shell_output("#{bin}/rifle -w cat test.py") - ENV.prepend_path "PATH", Formula["python@3.12"].opt_libexec/"bin" + ENV.prepend_path "PATH", Formula["python@3.13"].opt_libexec/"bin" assert_equal "Hello World!\n", shell_output("#{bin}/rifle -p 2 test.py") end end + +__END__ +diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py +index ffaa4c0..a7e027e 100644 +--- a/ranger/ext/img_display.py ++++ b/ranger/ext/img_display.py +@@ -15,7 +15,6 @@ import base64 + import curses + import errno + import fcntl +-import imghdr + import os + import struct + import sys +@@ -341,12 +340,28 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware): + with open(path, 'rb') as fobj: + return base64.b64encode(fobj.read()).decode('utf-8') + ++ @staticmethod ++ def imghdr_what(path): ++ """Replacement for the deprecated imghdr module""" ++ with open(path, "rb") as img_file: ++ header = img_file.read(32) ++ if header[6:10] in (b'JFIF', b'Exif'): ++ return 'jpeg' ++ elif header[:4] == b'\xff\xd8\xff\xdb': ++ return 'jpeg' ++ elif header.startswith(b'\211PNG\r\n\032\n'): ++ return 'png' ++ if header[:6] in (b'GIF87a', b'GIF89a'): ++ return 'gif' ++ else: ++ return None ++ + @staticmethod + def _get_image_dimensions(path): + """Determine image size using imghdr""" + file_handle = open(path, 'rb') + file_header = file_handle.read(24) +- image_type = imghdr.what(path) ++ image_type = ITerm2ImageDisplayer.imghdr_what(path) + if len(file_header) != 24: + file_handle.close() + return 0, 0 From 1c374bb213af89caaec02c80236eefe22c155faf Mon Sep 17 00:00:00 2001 From: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> Date: Wed, 16 Oct 2024 23:38:09 +0000 Subject: [PATCH 2/2] ranger: update 1.9.3_2 bottle. --- Formula/r/ranger.rb | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Formula/r/ranger.rb b/Formula/r/ranger.rb index 60aa9acbeea83..3b5649cd1d8ff 100644 --- a/Formula/r/ranger.rb +++ b/Formula/r/ranger.rb @@ -17,15 +17,13 @@ class Ranger < Formula end bottle do - rebuild 3 - sha256 cellar: :any_skip_relocation, arm64_sequoia: "d658a012014c41c2ff480390de60f9b7d14de34e7f207bd22646a44944ba4ef3" - sha256 cellar: :any_skip_relocation, arm64_sonoma: "f6e82a85ac9ec491664b30f4023e2c96be0485eec8fc34bae355500bd6e87024" - sha256 cellar: :any_skip_relocation, arm64_ventura: "a7df758964227f9f43b50b30e80eb8c2c54f0f0926806b4912de077631e59644" - sha256 cellar: :any_skip_relocation, arm64_monterey: "f6a5f3323c38e5b7cd70ddaee2a29fb1d2f9a68ac690a2aea8eda06baea2c8f6" - sha256 cellar: :any_skip_relocation, sonoma: "3efb7ed3317ce5187e6cab149b54504f15a7cf32e0a7f156dbde05867f966a3d" - sha256 cellar: :any_skip_relocation, ventura: "86a9399e36ac5cba36a307a951f5ae5f7cce3ac697eaa06c73674f565bfb4253" - sha256 cellar: :any_skip_relocation, monterey: "e26848ccdb553fb6914c4165c5985b6d0c25c7df2df21a61d176608a14d923c3" - sha256 cellar: :any_skip_relocation, x86_64_linux: "f1c019d60c241b2080cd53ad4fc8e24bb8c14df3345d09a4f202a798d51a1a8e" + rebuild 4 + sha256 cellar: :any_skip_relocation, arm64_sequoia: "29f94668e81c45db4b87f46d183450c306196f58315d34c948090d87552d81a0" + sha256 cellar: :any_skip_relocation, arm64_sonoma: "29f94668e81c45db4b87f46d183450c306196f58315d34c948090d87552d81a0" + sha256 cellar: :any_skip_relocation, arm64_ventura: "29f94668e81c45db4b87f46d183450c306196f58315d34c948090d87552d81a0" + sha256 cellar: :any_skip_relocation, sonoma: "c4a0c957609a0dbc3c20f6bb0e420d1166bb65de6c205acca14ee85c880b68da" + sha256 cellar: :any_skip_relocation, ventura: "c4a0c957609a0dbc3c20f6bb0e420d1166bb65de6c205acca14ee85c880b68da" + sha256 cellar: :any_skip_relocation, x86_64_linux: "29f94668e81c45db4b87f46d183450c306196f58315d34c948090d87552d81a0" end depends_on "python@3.13"