about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorMartin Weinelt <mweinelt@users.noreply.github.com>2024-02-10 18:52:42 +0100
committerGitHub <noreply@github.com>2024-02-10 18:52:42 +0100
commitef6206934d5726ed9315ac78879f5ba2a6b55785 (patch)
tree4cc77f808dbbe043e935cc39895fe48b53d6b23a /pkgs
parentc02e68343596f7e5f50876f0bb9ac025cffb07a4 (diff)
parentac83abceb50aa89f5af7c5882663fdafe8250a23 (diff)
downloadnixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.tar
nixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.tar.gz
nixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.tar.bz2
nixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.tar.lz
nixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.tar.xz
nixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.tar.zst
nixlib-ef6206934d5726ed9315ac78879f5ba2a6b55785.zip
Merge pull request #287761 from jtojnar/python313-installer-fix
python313.pkgs.installer: Fix build
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/python-modules/bootstrap/installer/default.nix2
-rw-r--r--pkgs/development/python-modules/installer/default.nix8
-rw-r--r--pkgs/development/python-modules/installer/python313-compat.patch55
3 files changed, 63 insertions, 2 deletions
diff --git a/pkgs/development/python-modules/bootstrap/installer/default.nix b/pkgs/development/python-modules/bootstrap/installer/default.nix
index b569e7fa6dc8..a3944ba39500 100644
--- a/pkgs/development/python-modules/bootstrap/installer/default.nix
+++ b/pkgs/development/python-modules/bootstrap/installer/default.nix
@@ -7,7 +7,7 @@
 
 stdenv.mkDerivation {
   pname = "${python.libPrefix}-bootstrap-${installer.pname}";
-  inherit (installer) version src meta;
+  inherit (installer) version src patches meta;
 
   buildPhase = ''
     runHook preBuild
diff --git a/pkgs/development/python-modules/installer/default.nix b/pkgs/development/python-modules/installer/default.nix
index d4f1e33ca606..c26dae01c237 100644
--- a/pkgs/development/python-modules/installer/default.nix
+++ b/pkgs/development/python-modules/installer/default.nix
@@ -1,6 +1,6 @@
 { lib
 , buildPythonPackage
-, pythonOlder
+, pythonAtLeast
 , fetchFromGitHub
 , pytestCheckHook
 , flit-core
@@ -20,6 +20,12 @@ buildPythonPackage rec {
     hash = "sha256-thHghU+1Alpay5r9Dc3v7ATRFfYKV8l9qR0nbGOOX/A=";
   };
 
+  patches = lib.optionals (pythonAtLeast "3.13") [
+    # Fix compatibility with Python 3.13
+    # https://github.com/pypa/installer/pull/201
+    ./python313-compat.patch
+  ];
+
   nativeBuildInputs = [ flit-core ];
 
   # We need to disable tests because this package is part of the bootstrap chain
diff --git a/pkgs/development/python-modules/installer/python313-compat.patch b/pkgs/development/python-modules/installer/python313-compat.patch
new file mode 100644
index 000000000000..423a550510eb
--- /dev/null
+++ b/pkgs/development/python-modules/installer/python313-compat.patch
@@ -0,0 +1,55 @@
+From b23f89b10cf5d179bd6b0bad195ee36f43a5fb9e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?=
+ <16805946+edgarrmondragon@users.noreply.github.com>
+Date: Tue, 19 Dec 2023 06:09:41 -0600
+Subject: [PATCH] Fix removed `importlib.resources.read_binary` in Python 3.13
+ (#201)
+
+diff --git a/noxfile.py b/noxfile.py
+index a690c59..6a69cce 100644
+--- a/noxfile.py
++++ b/noxfile.py
+@@ -22,7 +22,7 @@ def lint(session):
+     session.run("pre-commit", "run", "--all-files", *args)
+ 
+ 
+-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"])
++@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"])
+ def test(session):
+     session.install(".")
+     session.install("-r", "tests/requirements.txt")
+@@ -42,7 +42,7 @@ def test(session):
+     )
+ 
+ 
+-@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3"])
++@nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3"])
+ def doctest(session):
+     session.install(".")
+     session.install("-r", "docs/requirements.txt")
+diff --git a/src/installer/scripts.py b/src/installer/scripts.py
+index d18060b..c9f96b4 100644
+--- a/src/installer/scripts.py
++++ b/src/installer/scripts.py
+@@ -3,9 +3,19 @@
+ import io
+ import os
+ 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
+