This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: venv assumes header files in sys._home + '/Include'
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, sbt, vinay.sajip, vstinner
Priority: normal Keywords: patch

Created on 2012-07-16 11:30 by sbt, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
distutils-sysconfig.patch sbt, 2012-07-16 12:55 review
distutils-sysconfig.patch sbt, 2012-07-16 15:17 review
Pull Requests
URL Status Linked Edit
PR 1515 merged python-dev, 2017-05-09 12:42
PR 1625 merged vstinner, 2017-05-17 00:25
PR 1626 merged vstinner, 2017-05-17 00:26
Messages (8)
msg165589 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-07-16 11:30
For Unix I follow the practice suggested in README of running configure from a subdir of the main python directory, eg

    mkdir release
    cd release
    ../configure
    make

But if I create a venv then I cannot use it to compile C extensions because the include dirs are wrong, eg

    running build
    running build_ext
    building 'demo' extension
    gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/user/Repos/cpython/release/Include -I/home/user/Repos/cpython/release -c demo.c -o build/temp.linux-i686-3.3/demo.o
    demo.c:1:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

The problem seems to be that distutils.sysconfig.get_python_inc() assumes that if sys._home is set (as it is in a virtual env) then the standard header files can be found in sys._home + '/Include'.

But for my venv this is wrong, since sys._home is "/home/user/Repos/cpython/release" and "/home/user/Repos/cpython/release/Include" is empty.  Instead get_python_inc() should return "/home/user/Repos/cpython/Include".

BTW, a seperate issue seems to be that ${venv}/include is not added to the list of include dirs used when compiling.
msg165598 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-07-16 12:55
The attached patch seems to fix the problem.
msg165624 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-07-16 15:17
Updated patch.  Old one broke test_distutils...
msg165642 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-07-16 17:25
New changeset 998c8a8f2aea by Vinay Sajip in branch 'default':
Closes #15366: Corrected computation of include location for source builds. Thanks to Richard Oudkerk for the bug report and patch.
http://hg.python.org/cpython/rev/998c8a8f2aea
msg293301 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-09 11:23
I reverted the commit in 2.7, 3.5, 3.6 and master (3.7) branches to fix bpo-30273, but I'm unable to reproduce this bug so it seems like venv and virtualend have been updated in the meanwhile to add ${venv}/include to the include directories.

See for example the commit ab6b962ef241be97536573d7490ce1cfc74fde18.
msg293322 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-09 15:24
New changeset dbdea629e2e0e4bd8845aa55041e0a0ca4172cf3 by Victor Stinner (Jeremy Kloth) in branch 'master':
bpo-30273: update distutils.sysconfig for venv's created from Python (#1515)
https://github.com/python/cpython/commit/dbdea629e2e0e4bd8845aa55041e0a0ca4172cf3
msg293833 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-17 00:58
New changeset 460945f22acd288e660b432b288d9d81655572bf by Victor Stinner in branch '3.6':
bpo-30273: update distutils.sysconfig for venv's created from Python (#1515) (#1625)
https://github.com/python/cpython/commit/460945f22acd288e660b432b288d9d81655572bf
msg293835 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-17 00:59
New changeset f01c0ec9fe571e8afd50d2f5180db3c0d7b613af by Victor Stinner in branch '3.5':
bpo-30273: update distutils.sysconfig for venv's created from Python (#1515) (#1626)
https://github.com/python/cpython/commit/f01c0ec9fe571e8afd50d2f5180db3c0d7b613af
History
Date User Action Args
2022-04-11 14:57:32adminsetgithub: 59571
2017-05-17 00:59:26vstinnersetmessages: + msg293835
2017-05-17 00:58:05vstinnersetmessages: + msg293833
2017-05-17 00:26:07vstinnersetpull_requests: + pull_request1717
2017-05-17 00:25:28vstinnersetpull_requests: + pull_request1715
2017-05-09 15:24:15vstinnersetmessages: + msg293322
2017-05-09 12:42:33python-devsetpull_requests: + pull_request1615
2017-05-09 11:23:56vstinnersetnosy: + vstinner
messages: + msg293301
2012-07-16 17:25:07python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg165642

resolution: fixed
stage: needs patch -> resolved
2012-07-16 15:17:18sbtsetfiles: + distutils-sysconfig.patch

messages: + msg165624
2012-07-16 12:55:26sbtsetfiles: + distutils-sysconfig.patch
keywords: + patch
messages: + msg165598
2012-07-16 11:30:11sbtcreate