【问题标题】:Is there a way to tell if python was configured and compiled with "--with-threads --enable-shared"?有没有办法判断 python 是否使用“--with-threads --enable-shared”配置和编译?
【发布时间】:2023-03-19 11:26:01
【问题描述】:

这适用于 Debian Squeeez 上的 Python 2.6.6。我试图找出 debian 附带的二进制文件是否配置了以下标志:

--with-threads --enable-shared

好像它们不是我需要自己从源代码编译和安装。

【问题讨论】:

标签: python debian


【解决方案1】:

--with-threads(这是默认值)意味着 Python 支持线程,这意味着 import thread 可以工作。一个简单的测试方法是使用python$version -m threading

--enable-shared 意味着 Python 带有一个 libpython$version.so 文件,安装在 $prefix/lib 中(在 python$version 目录旁边,而不是在其中。)最简单的方法是查看该文件是否存在——假设您想知道,因为您需要使用这个 libpython 共享库。如果你真的需要知道python$version binary 是否使用这个共享库,ldd 会告诉你。我做出这样的区分是因为在 Debian 上,/usr/lib/python$version.so 将存在,即使 /usr/bin/python$version 是静态链接的。

【讨论】:

  • import thread 有效,您的意思是它不会抛出 ImportError,您可以在 Python 代码中对其进行测试。
猜你喜欢
  • 1970-01-01
  • 2011-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-24
相关资源
最近更新 更多