Author: Matti Picus <matti.pi...@gmail.com> Branch: pypy-config Changeset: r87943:8095ff3ffdfb Date: 2016-10-25 20:43 +0300 http://bitbucket.org/pypy/pypy/changeset/8095ff3ffdfb/
Log: add a pypy-config based on Misc/python-config.in from CPython diff --git a/pypy-config b/pypy-config new file mode 100755 --- /dev/null +++ b/pypy-config @@ -0,0 +1,73 @@ +#!/bin/sh + +if [ -x ./pypy -a ! -d ./pypy ] ; then + interp=./pypy +else if [ -x ./pypy-c ] ; then + interp=./pypy-c + else + echo no pypy nor pypy-c found + exit 1 + fi +fi +$interp - << DOC +import sys +import os +import getopt + +sys.argv = ['$interp'] + '$@'.split() +print sys.argv + +from distutils import sysconfig + +valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', + 'ldflags', 'help'] + +def exit_with_usage(code=1): + print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0], + '|'.join('--'+opt for opt in valid_opts)) + sys.exit(code) + +try: + opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) +except getopt.error: + exit_with_usage() + +if not opts: + exit_with_usage() + +pyver = sysconfig.get_config_var('VERSION') +getvar = sysconfig.get_config_var + +opt_flags = [flag for (flag, val) in opts] + +if '--help' in opt_flags: + exit_with_usage(code=0) + +for opt in opt_flags: + if opt == '--prefix': + print sysconfig.PREFIX + + elif opt == '--exec-prefix': + print sysconfig.EXEC_PREFIX + + elif opt in ('--includes', '--cflags'): + flags = ['-I' + sysconfig.get_python_inc(), + '-I' + sysconfig.get_python_inc(plat_specific=True)] + if opt == '--cflags': + print 'getvar(\'CFLAGS\') is', getvar('CFLAGS') + flags.extend(getvar('CFLAGS').split()) + print ' '.join(flags) + + elif opt in ('--libs', '--ldflags'): + libs = ['-lpython' + pyver] + libs += getvar('LIBS').split() + libs += getvar('SYSLIBS').split() + # add the prefix/lib/pythonX.Y/config dir, but only if there is no + # shared library in prefix/lib/. + if opt == '--ldflags': + if not getvar('Py_ENABLE_SHARED'): + libs.insert(0, '-L' + getvar('LIBPL')) + if not getvar('PYTHONFRAMEWORK'): + libs.extend(getvar('LINKFORSHARED').split()) + print ' '.join(libs) +DOC _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit