Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Peter Otten <__peter__@web.de> Newsgroups: comp.lang.python Subject: Re: (Initial) Questions about sysconfig.* Date: Fri, 04 Mar 2016 11:22:22 +0100 Organization: None Lines: 76 Message-ID: References: <56D94A89.4020609@felt.demon.nl> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: news.uni-berlin.de dEmfuG/kGUVDebPeAp86SwhFgSbjg+iWP04J8Ol8FvoQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'configure': 0.04; 'source.': 0.05; 'continuation': 0.07; 'makefile': 0.07; 'fails.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'returns,': 0.09; 'python': 0.10; 'def': 0.13; 'interpreter': 0.15; "'\\\\'": 0.16; '(more': 0.16; 'expect)': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'sysconfig': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'first,': 0.20; 'parsing': 0.22; 'subject:Questions': 0.22; 'installation': 0.23; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'linux': 0.26; 'skip:_ 20': 0.26; 'question': 0.27; "skip:' 10": 0.28; 'skip:( 20': 0.28; 'looks': 0.29; 'inspect': 0.29; 'invoke': 0.29; 'skip:/ 40': 0.29; 'says': 0.32; 'subject:) ': 0.32; 'source': 0.33; 'skip:_ 30': 0.33; 'michael': 0.33; 'version:': 0.33; 'file': 0.34; 'false': 0.35; 'but': 0.36; 'to:addr:python- list': 0.36; 'received:org': 0.37; 'anything': 0.38; 'someone': 0.38; 'why': 0.39; 'data': 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'received:de': 0.40; 'skip:u 10': 0.61; 'course': 0.62; 'more': 0.63; 'mar': 0.65; 'skip:/ 30': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: p57bd8c61.dip0.t-ipconnect.de User-Agent: KNode/4.13.3 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:104022 Michael Felt wrote: > First, a simple one: > > sysconfig.is_python_build() > > Return True if the current Python installation was built from source. > >>>> sysconfig.is_python_build() > False > > Now, not earth shattering, but I did build this from source - so can > someone help me with understanding why Python says no? Looking into the source of a self-compilee Python version: $ python3.6 Python 3.6.0a0 (default:c092148a1b55+, Mar 1 2016, 15:26:05) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sysconfig, inspect >>> print(inspect.getsource(sysconfig.is_python_build)) def is_python_build(check_home=False): if check_home and _sys_home: return _is_python_source_dir(_sys_home) return _is_python_source_dir(_PROJECT_BASE) >>> print(inspect.getsource(sysconfig._is_python_source_dir)) def _is_python_source_dir(d): for fn in ("Setup.dist", "Setup.local"): if os.path.isfile(os.path.join(d, "Modules", fn)): return True return False >>> sysconfig._PROJECT_BASE '/usr/local/bin' So this effectively looks for the file /usr/local/bin/Modules/Setup.dist or /usr/local/bin/Modules/Setup.local which of course fails. You have to invoke the interpreter in the directory where it was built: $ /wherever/you/unpacked/and/compiled/python Python 3.6.0a0 (default:c092148a1b55+, Mar 1 2016, 15:26:05) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sysconfig >>> sysconfig.is_python_build() True > And a last question (more about the configure phase I expect) > > ...() returns, among other things: > > 'LIBRARY_OBJS': '\\', > 'MODULE_OBJS': '\\', > 'PARSER_HEADERS': '\\', > 'PGENSRCS': '\\ \\', > 'PYTHON_OBJS': '\\', > 'QUICKTESTOPTS': '-l -x test_subprocess test_io test_lib2to3 \\', > > 'SHLIB_EXT': '".so"', > > Why are any of these using '\\' for anything on 'posix'? Is that data actually used anywhere? I suspect this is a parsing mishap and these are actually line continuation indicators. In the Makefile I find (e. g.) PYTHON_OBJS= \ Python/_warnings.o \ Python/Python-ast.o \ Python/asdl.o \ [snip]