python / python/cpython

venv should include python-config in the virtual environment

未关闭
#135,147 2 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先定位 venv 实现及其 Linux 专用测试,然后追踪环境的 Python 可执行文件是如何被选择和安装的。添加测试覆盖,证明相应的 python-config 在环境的 bin 目录中可用,并在 Python 3.13 下验证 Linux 上的行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

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