Fix build with Python 3.13

This commit is contained in:
Karolina Surma 2024-01-11 12:13:39 +01:00
parent 0c95c79420
commit 07d0cff227
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 28f0a1a5ed9d33567353ec930cf4702c2bc86886 Mon Sep 17 00:00:00 2001
From: Karolina Surma <ksurma@redhat.com>
Date: Thu, 11 Jan 2024 10:33:54 +0100
Subject: [PATCH] Fix removed importlib.resources.read_binary in Python 3.13
---
src/installer/scripts.py | 14 ++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/installer/scripts.py b/src/installer/scripts.py
index 7e3c8fc..a70c59f 100644
--- a/src/installer/scripts.py
+++ b/src/installer/scripts.py
@@ -2,9 +2,19 @@
import io
import shlex
+import sys
import zipfile
-from importlib.resources import read_binary
-from typing import TYPE_CHECKING, Mapping, Optional, Tuple
+from types import ModuleType
+from typing import TYPE_CHECKING, Mapping, Optional, Tuple, Union
+
+if sys.version_info >= (3, 9): # pragma: no cover
+ from importlib.resources import files
+
+ def read_binary(package: Union[str, ModuleType], file_path: str) -> bytes:
+ return (files(package) / file_path).read_bytes()
+
+else: # pragma: no cover
+ from importlib.resources import read_binary
from installer import _scripts
--
2.43.0

View File

@ -1,6 +1,6 @@
Name: python-installer
Version: 0.7.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: A library for installing Python wheels
# SPDX
@ -8,6 +8,10 @@ License: MIT
URL: https://github.com/pypa/installer
Source: %{pypi_source installer}
# Fix the build with Python 3.13 - merged upstream
# https://github.com/pypa/installer/commit/b23f89b10cf5
Patch: Fix-removed-importlib.resources.read_binary-in-Pytho.patch
BuildArch: noarch
BuildRequires: python3-devel
@ -55,6 +59,10 @@ Summary: %{summary}
%changelog
* Thu Jan 11 2024 Karolina Surma <ksurma@redhat.com> - 0.7.0-4
- Fix the build with Python 3.13
Fixes: rhbz#2246052
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild