From 6353656e546c811969fc09444cfe7ab09b82642f Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Sun, 17 Nov 2024 16:28:17 +0800 Subject: [PATCH] python3Packages.importmagic: fix build --- .../python-modules/importmagic/default.nix | 13 ++++++---- .../importmagic/python-312.patch | 24 +++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 pkgs/development/python-modules/importmagic/python-312.patch diff --git a/pkgs/development/python-modules/importmagic/default.nix b/pkgs/development/python-modules/importmagic/default.nix index a2d32b55808d..0d3ad9f770d7 100644 --- a/pkgs/development/python-modules/importmagic/default.nix +++ b/pkgs/development/python-modules/importmagic/default.nix @@ -13,19 +13,24 @@ buildPythonPackage rec { src = fetchPypi { inherit pname version; - sha256 = "3f7757a5b74c9a291e20e12023bb3bf71bc2fa3adfb15a08570648ab83eaf8d8"; + hash = "sha256-P3dXpbdMmikeIOEgI7s79xvC+jrfsVoIVwZIq4Pq+Ng="; }; + patches = [ + # https://github.com/alecthomas/importmagic/issues/67 + ./python-312.patch + ]; + propagatedBuildInputs = [ six ]; nativeCheckInputs = [ pytestCheckHook ]; pythonImportsCheck = [ "importmagic" ]; - meta = with lib; { + meta = { description = "Python Import Magic - automagically add, remove and manage imports"; homepage = "https://github.com/alecthomas/importmagic"; - license = licenses.bsd0; - maintainers = with maintainers; [ onny ]; + license = lib.licenses.bsd0; + maintainers = with lib.maintainers; [ onny ]; }; } diff --git a/pkgs/development/python-modules/importmagic/python-312.patch b/pkgs/development/python-modules/importmagic/python-312.patch new file mode 100644 index 000000000000..4985809056f4 --- /dev/null +++ b/pkgs/development/python-modules/importmagic/python-312.patch @@ -0,0 +1,24 @@ +--- a/importmagic/index.py ++++ b/importmagic/index.py +@@ -8,18 +8,14 @@ + import logging + import re + from contextlib import contextmanager +-from distutils import sysconfig ++import sysconfig + + from importmagic.util import parse_ast + + + LIB_LOCATIONS = sorted(set(( +- (sysconfig.get_python_lib(standard_lib=True), 'S'), +- (sysconfig.get_python_lib(plat_specific=True), '3'), +- (sysconfig.get_python_lib(standard_lib=True, prefix=sys.prefix), 'S'), +- (sysconfig.get_python_lib(plat_specific=True, prefix=sys.prefix), '3'), +- (sysconfig.get_python_lib(standard_lib=True, prefix='/usr/local'), 'S'), +- (sysconfig.get_python_lib(plat_specific=True, prefix='/usr/local'), '3'), ++ (sysconfig.get_path('stdlib'), 'S'), ++ (sysconfig.get_path('platlib'), '3'), + )), key=lambda l: -len(l[0])) + + # Regex matching modules that we never attempt to index.