alecthomas / alecthomas/importmagic

distutils removed in python 3.12

未关闭
#67 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
122
派生
21
PR 合并指标
30 天内没有已合并 PR

描述

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.

```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。