From ec90fcdc8ffb6b4b34fb8d71f14f4bbdce2ae575 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Wed, 29 Nov 2023 08:22:46 -0500 Subject: [PATCH] Fix Python 3.13 compatibility (close RHBZ#2252070) --- 24.patch | 36 ++++++++++++++++++++++++++++++++++++ python-cffsubr.spec | 6 +++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 24.patch diff --git a/24.patch b/24.patch new file mode 100644 index 0000000..442c405 --- /dev/null +++ b/24.patch @@ -0,0 +1,36 @@ +From 822a00d2001fa4de06ca854c3047b8687d6c1a32 Mon Sep 17 00:00:00 2001 +From: "Benjamin A. Beasley" +Date: Wed, 29 Nov 2023 08:14:32 -0500 +Subject: [PATCH] Handle importlib.resources.path removal in Python 3.13 + +--- + src/cffsubr/__init__.py | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/src/cffsubr/__init__.py b/src/cffsubr/__init__.py +index 4428dcd..1d4eef2 100644 +--- a/src/cffsubr/__init__.py ++++ b/src/cffsubr/__init__.py +@@ -8,10 +8,19 @@ + import sys + + try: +- from importlib.resources import path ++ # Python >= 3.9 ++ from importlib.resources import as_file, files + except ImportError: +- # use backport for python < 3.7 +- from importlib_resources import path ++ try: ++ # python >= 3.7, deprecated in python 3.11, removed in 3.13 ++ from importlib.resources import path ++ except ImportError: ++ # use backport for python < 3.7 ++ from importlib_resources import path ++else: ++ # https://docs.python.org/3.11/library/importlib.resources.html#importlib.resources.as_file ++ def path(package, resource): ++ return as_file(files(package).joinpath(resource)) + + from fontTools import ttLib + diff --git a/python-cffsubr.spec b/python-cffsubr.spec index 4b4c1d4..9b3e2da 100644 --- a/python-cffsubr.spec +++ b/python-cffsubr.spec @@ -17,6 +17,10 @@ Source0: %{pypi_source %{srcname}} # Written for Fedora in groff_man(7) format based on the output of “cffsubr --help” Source1: %{srcname}.1 +# Handle importlib.resources.path removal in Python 3.13 +# https://github.com/adobe-type-tools/cffsubr/pull/24 +Patch: https://github.com/adobe-type-tools/cffsubr/pull/24.patch + BuildArch: noarch BuildRequires: python3-devel @@ -43,7 +47,7 @@ Requires: %{txbin} Standalone CFF subroutinizer based on the AFDKO tx tool. %prep -%autosetup -n %{srcname}-%{version} +%autosetup -n %{srcname}-%{version} -p1 # Patch out setuptools-git-ls-files dependency sed -r -i '/setuptools-git-ls-files/d' setup.py pyproject.toml