python3Packages.importmagic: fix build (#356666)

This commit is contained in:
Jonas Heinrich 2024-11-18 13:29:48 +01:00 committed by GitHub
commit f93401eeed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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.