Skip to content

venv should include python-config in the virtual environment #135147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
krupan opened this issue Jun 4, 2025 · 1 comment
Open

venv should include python-config in the virtual environment #135147

krupan opened this issue Jun 4, 2025 · 1 comment
Labels
topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error

Comments

@krupan
Copy link

krupan commented Jun 4, 2025

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:

pypa/virtualenv#169

pypa/virtualenv#1808

pyenv/pyenv-virtualenv#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

ContinuumIO/anaconda-issues#1009

astral-sh/uv#10263

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@krupan krupan added the type-bug An unexpected behavior, bug, or error label Jun 4, 2025
@ZeroIntensity ZeroIntensity added the topic-venv Related to the venv module label Jun 4, 2025
@emmatyping
Copy link
Member

See also python-ideas discussion linked from one of the virtualenv threads:
https://mail.python.org/archives/list/python-ideas@python.org/thread/QTCPOM5YBOKCWWNPDP7Z4QL2K6OWGSHL/

I think there is an open question about what python-config should output for several flags when under a venv if it does get added there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-venv Related to the venv module type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants