有没有办法判断 python 是否使用“--with-threads --enable-shared"进行配置和编译?

2022-01-24 00:00:00 python debian

问题描述

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

--with-threads --enable-shared

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

解决方案

--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/bin/python$version 是静态链接的,/usr/lib/python$version.so 也会存在.p>

This is for Python 2.6.6 on Debian Squeeez. I'm trying to find out if the binaries shipped with debian were configured with the flags of:

--with-threads --enable-shared

as if they were not I will need to compile and install from source myself.

解决方案

--with-threads (which is the default) will mean Python supports threading, which will mean import thread will work. An easy way to test this is with python$version -m threading

--enable-shared will mean Python comes with a libpython$version.so file, installed in $prefix/lib (alongside the python$version directory, not inside it.) The easiest thing to do is to look if that file is there -- assuming you want to know because you need to use this libpython shared library. If you actually need to know if the python$version binary uses this shared library, ldd will tell you that. I make that distinction because on Debian, /usr/lib/python$version.so will exist even though /usr/bin/python$version is statically linked.

相关文章