How to get the list of options that Python was compiled with?

后端 未结 5 1852
北荒
北荒 2020-12-07 09:43

You can compile Python in various ways. I\'d like to find out with which options my Python was compiled.

Concrete use-case: was my Python compiled with readline? I k

5条回答
  •  庸人自扰
    2020-12-07 10:08

    To build on mirk's answer, to find the configure flags that were actually used during the build, the value you're looking for is CONFIG_ARGS.

    For example, this is the output for an Ubuntu-compiled Python:

    >>> print distutils.sysconfig.get_config_var('CONFIG_ARGS')
    '--enable-shared' '--prefix=/usr' '--enable-ipv6'
    '--enable-unicode=ucs4' '--with-dbmliborder=bdb:gdbm'
    '--with-system-expat' '--with-system-ffi' '--with-fpe ctl'
    'CC=x86_64-linux-gnu-gcc' 'CFLAGS=-D_FORTIFY_SOURCE=2 -g
    -fstack-protector --param=ssp-buffer-size=4 -Wformat
    -Werror=format-security ' 'LDFLAGS=-Wl,-Bs ymbolic-functions
    -Wl,-z,relro'
    

提交回复
热议问题