Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Felt Newsgroups: comp.lang.python Subject: Re: (Initial) Questions about sysconfig.* Date: Fri, 04 Mar 2016 14:10:12 +0100 Lines: 86 Message-ID: References: <56D94A89.4020609@felt.demon.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de lRlgwAJMvs0JTxxwWjnRKQVkiuQooDFRKdpwLW0IxNIw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'configure': 0.04; 'source.': 0.05; 'continuation': 0.07; 'makefile': 0.07; 'fails.': 0.09; 'patch.': 0.09; 'returns,': 0.09; 'stored': 0.10; 'python': 0.10; 'def': 0.13; 'interpreter': 0.15; "'\\\\'": 0.16; '(more': 0.16; '(rather': 0.16; 'expect)': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'remembered': 0.16; 'sysconfig': 0.16; 'wrote:': 0.16; 'else,': 0.18; '>>>': 0.20; 'first,': 0.20; 'parsing': 0.22; 'subject:Questions': 0.22; 'installation': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent: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; 'text': 0.35; 'false': 0.35; 'something': 0.35; 'reply.': 0.35; 'but': 0.36; 'to:addr:python- list': 0.36; 'thanks': 0.37; 'anything': 0.38; 'someone': 0.38; 'why': 0.39; 'data': 0.39; 'enough': 0.39; 'received:192': 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'skip:u 10': 0.61; 'course': 0.62; 'more': 0.63; 'between': 0.65; 'mar': 0.65; 'p.s.': 0.65; '>>>>>': 0.66; 'reply': 0.68; 'received:nl': 0.72; 'mailer': 0.84; 'otten': 0.84; 'program!': 0.84; 'skip:/ 30': 0.84 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 In-Reply-To: X-Mailman-Approved-At: Fri, 04 Mar 2016 08:10:31 -0500 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:104033 Thanks for the quick reply. My mailer lost it (rather remembered it originiated as a reply to something else, and stored it there) - :) I would reply between the text below - but, mainly thanks for showing the use of 'inspect' - will be extremely handy as I learn enough to make a (local) patch. Michael p.s. the >>> prompts make it look very colorful in my mail program! On 2016-03-04 11:22, Peter Otten wrote: > 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] > > >