[New-bugs-announce] [issue23746] sysconfg.is_python_build() is buggy

Anand B Pillai report at bugs.python.org
Mon Mar 23 10:13:02 CET 2015


New submission from Anand B Pillai:

On Python 3.5.0a1+ built from source,

>>> import sysconfig
>>> sysconfig.is_python_build()
False
>>> sysconfig.is_python_build(True)
False
>>> sysconfig._PROJECT_BASE
'/opt/bin'
>>> import sys
>>> sys._home
>>>

The problem is, when sys._home is None, this function uses _is_python_source_dir(_PROJECT_BASE) . In this case the _PROJECT_BASE is clearly passed wrongly as '/opt/bin'. That is the INSTALL_PREFIX, not _PROJECT_BASE .

Let us do a small hack and set _PROJECT_BASE to the folder where I build this Python version.

# Of course this can't be reproduced but you get the idea.

>>> sysconfig._PROJECT_BASE='/home/anand/code/cpython/'
>>> sysconfig.is_python_build()
True

The documentation says,

"

sysconfig.is_python_build()

    Return True if the current Python installation was built from source.

"

which is clearly in conflict with what it is doing. 

>From a quick look at sysconfig.py it looks like it is calculating _PROJECT_BASE wrongly. 

I can give a patch for this, but first I am more interested in finding out what this function is supposed to do - why have this function if you are not able to get the details of the build environment from the built interpreter ? Clearly it is not doing that here.



The conclusions are part of the attached file in comments.

----------
components: Library (Lib)
messages: 238993
nosy: pythonhacker
priority: normal
severity: normal
status: open
title: sysconfg.is_python_build() is buggy
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23746>
_______________________________________


More information about the New-bugs-announce mailing list