alecthomas / alecthomas/importmagic

distutils removed in python 3.12

Ouverte
#67 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
122
Forks
21
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

importmagic 0.1.7 uses distutils.sysconfig to find some library paths and unfortunately distutils was removed in Python 3.12.

This was my stab at replacing it. After glancing at I'm not sure what the difference is between prefix=None and sys.prefix is.

On my system the calculated prefix (from prefix=None) always ends up the same as sys.prefix

```
--- a/importmagic/index.py
+++ b/importmagic/index.py
@@ -8,18 +8,16 @@
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', scheme='deb_system'), 'S'),
+ (sysconfig.get_path('platlib', scheme='deb_system'), '3'),
+ (sysconfig.get_path('stdlib', scheme='posix_local'), 'S'),
+ (sysconfig.get_path('platlib', scheme='posix_local'), '3'),
)), key=lambda l: -len(l[0]))

# Regex matching modules that we never attempt to index.

```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.