python3Packages.importmagic: fix build

This commit is contained in:
wxt 2024-11-17 16:28:17 +08:00
parent 0a14706530
commit 6353656e54
No known key found for this signature in database
GPG Key ID: 8281D5EE2D1825A4
2 changed files with 33 additions and 4 deletions

View File

@ -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 ];
};
}

View File

@ -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.