Skip to content

Commit ef62069

Browse files
authored
Merge pull request #287761 from jtojnar/python313-installer-fix
python313.pkgs.installer: Fix build
2 parents c02e683 + ac83abc commit ef62069

File tree

3 files changed

+63
-2
lines changed

3 files changed

+63
-2
lines changed

pkgs/development/python-modules/bootstrap/installer/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
stdenv.mkDerivation {
99
pname = "${python.libPrefix}-bootstrap-${installer.pname}";
10-
inherit (installer) version src meta;
10+
inherit (installer) version src patches meta;
1111

1212
buildPhase = ''
1313
runHook preBuild

pkgs/development/python-modules/installer/default.nix

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{ lib
22
, buildPythonPackage
3-
, pythonOlder
3+
, pythonAtLeast
44
, fetchFromGitHub
55
, pytestCheckHook
66
, flit-core
@@ -20,6 +20,12 @@ buildPythonPackage rec {
2020
hash = "sha256-thHghU+1Alpay5r9Dc3v7ATRFfYKV8l9qR0nbGOOX/A=";
2121
};
2222

23+
patches = lib.optionals (pythonAtLeast "3.13") [
24+
# Fix compatibility with Python 3.13
25+
# https://github.com/pypa/installer/pull/201
26+
./python313-compat.patch
27+
];
28+
2329
nativeBuildInputs = [ flit-core ];
2430

2531
# We need to disable tests because this package is part of the bootstrap chain
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
From b23f89b10cf5d179bd6b0bad195ee36f43a5fb9e Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?=
3+
<16805946+edgarrmondragon@users.noreply.github.com>
4+
Date: Tue, 19 Dec 2023 06:09:41 -0600
5+
Subject: [PATCH] Fix removed `importlib.resources.read_binary` in Python 3.13
6+
(#201)
7+
8+
diff --git a/noxfile.py b/noxfile.py
9+
index a690c59..6a69cce 100644
10+
--- a/noxfile.py
11+
+++ b/noxfile.py
12+
@@ -22,7 +22,7 @@ def lint(session):
13+
session.run("pre-commit", "run", "--all-files", *args)
14+
15+
16+
-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"])
17+
+@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"])
18+
def test(session):
19+
session.install(".")
20+
session.install("-r", "tests/requirements.txt")
21+
@@ -42,7 +42,7 @@ def test(session):
22+
)
23+
24+
25+
-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"])
26+
+@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"])
27+
def doctest(session):
28+
session.install(".")
29+
session.install("-r", "docs/requirements.txt")
30+
diff --git a/src/installer/scripts.py b/src/installer/scripts.py
31+
index d18060b..c9f96b4 100644
32+
--- a/src/installer/scripts.py
33+
+++ b/src/installer/scripts.py
34+
@@ -3,9 +3,19 @@
35+
import io
36+
import os
37+
import shlex
38+
+import sys
39+
import zipfile
40+
-from importlib.resources import read_binary
41+
-from typing import TYPE_CHECKING, Mapping, Optional, Tuple
42+
+from types import ModuleType
43+
+from typing import TYPE_CHECKING, Mapping, Optional, Tuple, Union
44+
+
45+
+if sys.version_info >= (3, 9): # pragma: no cover
46+
+ from importlib.resources import files
47+
+
48+
+ def read_binary(package: Union[str, ModuleType], file_path: str) -> bytes:
49+
+ return (files(package) / file_path).read_bytes()
50+
+
51+
+else: # pragma: no cover
52+
+ from importlib.resources import read_binary
53+
54+
from installer import _scripts
55+

0 commit comments

Comments
 (0)