python3Packages.importmagic: 0.1.7 -> 0.2.0; several improvements (#502009)

This commit is contained in:
dotlambda
2026-03-22 02:05:53 +00:00
committed by GitHub
2 changed files with 14 additions and 40 deletions
@@ -1,27 +1,24 @@
{
lib,
buildPythonPackage,
fetchPypi,
six,
fetchFromGitHub,
hatchling,
pytestCheckHook,
}:
buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
pname = "importmagic";
version = "0.1.7";
format = "setuptools";
version = "0.2.0";
pyproject = true;
src = fetchPypi {
inherit pname version;
hash = "sha256-P3dXpbdMmikeIOEgI7s79xvC+jrfsVoIVwZIq4Pq+Ng=";
src = fetchFromGitHub {
owner = "alecthomas";
repo = "importmagic";
tag = finalAttrs.version;
hash = "sha256-776HbSRl5hIrSyIyIF7jnNAJF41QzdjXe0vDaKwlCnc=";
};
patches = [
# https://github.com/alecthomas/importmagic/issues/67
./python-312.patch
];
propagatedBuildInputs = [ six ];
build-system = [ hatchling ];
nativeCheckInputs = [ pytestCheckHook ];
@@ -30,7 +27,8 @@ buildPythonPackage rec {
meta = {
description = "Python Import Magic - automagically add, remove and manage imports";
homepage = "https://github.com/alecthomas/importmagic";
license = lib.licenses.bsd0;
changelog = "https://github.com/alecthomas/importmagic/releases/tag/${finalAttrs.src.tag}";
license = lib.licenses.bsd2;
maintainers = with lib.maintainers; [ onny ];
};
}
})
@@ -1,24 +0,0 @@
--- 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.