python / python/cpython

venv should include python-config in the virtual environment

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

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

stdlib topic-venv type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

When venv creates a virtual environment it puts the specified python binary from the python distributions bin directory into the virtual environment's bin directory. It does not add the python-config script from the python distribution's bin directory to the virtual environment's bin directory. I, and many others, believe that it should.

From the Debian python-config man page:

python-config helps compiling and linking programs, which embed the Python interpreter, or extension modules that can be loaded dynamically (at run time) into the interpreter.

Any python project that is going to include a custom module written in C is going to want to use python-config to help compile and link that C code. It's going to want to use the python-config for the version of python that the rest of the project is using (from the virtual environment). Currently that is very difficult because python-config is not part of the virtual environment. This defeats the safety and convenience of virtual environments.

There are several different threads of people asking for this in virtualenv, pyvenv, anaconda, uv, etc., and most of those projects say, "well, the built-in venv doesn't put python-config in the virtual environment's bin directory, so we aren't going to do it either." Yet there seems to be no reason why python-config is not put into the virtual environment along with python.

Links to those discussions:

https://github.com/pypa/virtualenv/issues/169

https://github.com/pypa/virtualenv/issues/1808

https://github.com/pyenv/pyenv-virtualenv/issues/459

https://stackoverflow.com/questions/42020937/why-pyvenv-does-not-install-python-config

https://travis-ci.community/t/python-config-is-not-set-up-corresponding-to-build-python-version/10098

https://github.com/ContinuumIO/anaconda-issues/issues/1009

https://github.com/astral-sh/uv/issues/10263

CPython versions tested on:

3.13

Operating systems tested on:

Linux

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

まず venv の実装と Linux 固有のテストを見つけ、次に環境の Python 実行ファイルがどのように選択・インストールされるかを追跡します。環境の bin ディレクトリで対応する python-config が利用可能であることを示すテストカバレッジを追加し、Python 3.13 を使用した Linux での動作を検証します。

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

評価

技術スタック
python
領域
tooling
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

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

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