0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pkg_resources が setuptools から消えた後も古い Python 製 CLI ツールを(簡単に)使いたい

Posted at

結論

pipx を使ってコマンド一発でできます。

pipx install --preinstall "setuptools<81" some-old-tool

uv でもできます。

uv tool install -w "setuptools<81" some-old-tool

背景

pkg_resources を使ったツールを使用すると次のような警告が出ます。

UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.

要するに pkg_resources は 2025/11/30 以降に消えるので対応してねってことです。
具体的には次のような対応が考えられます。

  • コードを書き換えて pkg_resources を使わないようにする
  • 依存する setuptools のバージョンを <81 で指定する

ツールの開発が終了している場合は利用者側で対応するしかないですが、これらは私のような初心者にはなかなか厳しいですし時間もかかります。
そこで自分の責任で setuptools<81 を守ることにして、古い setuptools をインストールした仮想環境を準備することを考えます。
ここで冒頭のコマンドを使うと仮想環境の作成も含めて簡単にやってくれるという訳です。

余談ですが pipxuv を使うと PEP 668 の externally-managed-environment エラーも回避できるのでぜひ使っていきましょう。

関連リンク

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?