#navi_header|Python| Pythonインタープリタがコンパイルされた時の、コンパイルオプションを確認するメモ。 Python 2.6: import distutils.sysconfig print distutils.sysconfig.get_config_vars() Python 2.7以降: import sysconfig print sysconfig.get_config_vars() 参考: - compilation - How to get a list of options that Python was compiled with? - Stack Overflow -- http://stackoverflow.com/questions/10192758/how-to-get-a-list-of-options-that-python-was-compiled-with - sysconfig – Interpreter Compile-time Configuration - Python Module of the Week -- http://pymotw.com/2/sysconfig/ "get_config_vars()"の戻り値はdictionaryなので、そのままget()で取り出したりkeysでfor文に回せます。 また、"get_config_vars(key名)"で直接オプション名を指定して値を取り出せます。 インタプリタがコンパイルされた時のコンパイルオプションに関連しそうなkey名: CONFIG_ARGS : "./configure" スクリプトのオプション CFLAGS, OPT : コンパイラのオプションぽい。 PY_CFLAGS : 謎。 例1: CentOS 6.3ベースの python-2.6.6-51.el6.x86_64: #pre||> $ python Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import distutils.sysconfig >>> distutils.sysconfig.get_config_vars('CONFIG_ARGS') ["'--build=x86_64-redhat-linux-gnu' ... ||< 例2: CentOS 6.3に自前でインストールしたPython 2.7 #pre||> $ workon py27t1 (py27t1)[...]$ python Python 2.7.6 (default, Jan 18 2014, 20:36:47) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sysconfig >>> sysconfig.get_config_vars('CONFIG_ARGS') ["'--prefix=/work/pythonbuilds/2.7.6' '--enable-ipv6' '--enable-unicode=ucs4' '--enable-shared'"] ||< #navi_footer|Python|