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

后端 未结 5 1858
北荒
北荒 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:23

    Here is a command that i use to compare different python configurations. It includes getting the value of the outputs:

    $ python3.6 -c "import sysconfig;print('{}'.format('\n'.join(['{} = {}'.format(v, sysconfig.get_config_var(v)) for v in sorted(sysconfig.get_config_vars(), key=lambda s: s.lower())])))" > /tmp/python36.conf
    
    $ python2.7 -c "import sysconfig;print('{}'.format('\n'.join(['{} = {}'.format(v, sysconfig.get_config_var(v)) for v in sorted(sysconfig.get_config_vars(), key=lambda s: s.lower())])))" > /tmp/python27.conf
    
    $ sdiff /tmp/python36.conf /tmp/python27.conf
    
    $ # This is my own version of colorized side-by-side diff from
    $ # https://github.com/jlinoff/csdiff
    $ csdiff /tmp/python36.conf /tmp/python27.conf
    

提交回复
热议问题