distutils removed in python 3.12

オープン
#67 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

importmagic/index.py から始めて、LIB_LOCATIONS がどのように構築されるかを読み、サポート対象の Python バージョン全体で、sysconfig の標準ライブラリパスと削除された distutils.sysconfig の動作を比較します。importmagic が distutils に依存しなくなり、Python 3.12 を含め、想定される標準ライブラリの場所とプラットフォーム固有のライブラリの場所を引き続き検出できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
122
フォーク
21
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

alecthomas/importmagic のほかの issue

alecthomas/importmagic の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。