annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/config-3.8-x86_64-linux-gnu/python-config.py @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
rev   line source
jpayne@68 1 #!/usr/bin/env python3.8
jpayne@68 2 # -*- python -*-
jpayne@68 3
jpayne@68 4 # Keep this script in sync with python-config.sh.in
jpayne@68 5
jpayne@68 6 import getopt
jpayne@68 7 import os
jpayne@68 8 import sys
jpayne@68 9 import sysconfig
jpayne@68 10
jpayne@68 11 valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
jpayne@68 12 'ldflags', 'extension-suffix', 'help', 'abiflags', 'configdir',
jpayne@68 13 'embed']
jpayne@68 14
jpayne@68 15 def exit_with_usage(code=1):
jpayne@68 16 print("Usage: {0} [{1}]".format(
jpayne@68 17 sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr)
jpayne@68 18 sys.exit(code)
jpayne@68 19
jpayne@68 20 try:
jpayne@68 21 opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
jpayne@68 22 except getopt.error:
jpayne@68 23 exit_with_usage()
jpayne@68 24
jpayne@68 25 if not opts:
jpayne@68 26 exit_with_usage()
jpayne@68 27
jpayne@68 28 pyver = sysconfig.get_config_var('VERSION')
jpayne@68 29 getvar = sysconfig.get_config_var
jpayne@68 30
jpayne@68 31 opt_flags = [flag for (flag, val) in opts]
jpayne@68 32
jpayne@68 33 if '--help' in opt_flags:
jpayne@68 34 exit_with_usage(code=0)
jpayne@68 35
jpayne@68 36 for opt in opt_flags:
jpayne@68 37 if opt == '--prefix':
jpayne@68 38 print(sysconfig.get_config_var('prefix'))
jpayne@68 39
jpayne@68 40 elif opt == '--exec-prefix':
jpayne@68 41 print(sysconfig.get_config_var('exec_prefix'))
jpayne@68 42
jpayne@68 43 elif opt in ('--includes', '--cflags'):
jpayne@68 44 flags = ['-I' + sysconfig.get_path('include'),
jpayne@68 45 '-I' + sysconfig.get_path('platinclude')]
jpayne@68 46 if opt == '--cflags':
jpayne@68 47 flags.extend(getvar('CFLAGS').split())
jpayne@68 48 print(' '.join(flags))
jpayne@68 49
jpayne@68 50 elif opt in ('--libs', '--ldflags'):
jpayne@68 51 libs = []
jpayne@68 52 if '--embed' in opt_flags:
jpayne@68 53 libs.append('-lpython' + pyver + sys.abiflags)
jpayne@68 54 else:
jpayne@68 55 libpython = getvar('LIBPYTHON')
jpayne@68 56 if libpython:
jpayne@68 57 libs.append(libpython)
jpayne@68 58 libs.extend(getvar('LIBS').split() + getvar('SYSLIBS').split())
jpayne@68 59
jpayne@68 60 # add the prefix/lib/pythonX.Y/config dir, but only if there is no
jpayne@68 61 # shared library in prefix/lib/.
jpayne@68 62 if opt == '--ldflags':
jpayne@68 63 if not getvar('Py_ENABLE_SHARED'):
jpayne@68 64 libs.insert(0, '-L' + getvar('LIBPL'))
jpayne@68 65 print(' '.join(libs))
jpayne@68 66
jpayne@68 67 elif opt == '--extension-suffix':
jpayne@68 68 print(sysconfig.get_config_var('EXT_SUFFIX'))
jpayne@68 69
jpayne@68 70 elif opt == '--abiflags':
jpayne@68 71 print(sys.abiflags)
jpayne@68 72
jpayne@68 73 elif opt == '--configdir':
jpayne@68 74 print(sysconfig.get_config_var('LIBPL'))