跳转到主要内容

查找您环境中隐藏的libpython关联库

项目描述

find_libpython

这是一个来自 gist的pypi项目版本,该gist也出现在PyCall库中。

该库旨在查找当前Python环境中libpython动态库的路径。它应与许多类型的安装一起工作,无论是conda管理的,系统管理的,还是其他类型的安装。它应该在Windows,Mac OS/OS X和任何Linux发行版上运行。

此代码在多个上下文中很有用,包括将Python解释器嵌入到另一个进程中的项目,或Python库构建系统。

用法

find_libpython 既是脚本也是Python包。作为脚本的用法在需要获取用于基于makefile构建系统的libpython路径时很有用。它也可以用于确定用于在用另一种语言编写的进程中嵌入Python解释器的libpython路径。在这种情况下,建议的用法是在没有参数的情况下以子进程调用脚本并解析输出。

> find_libpython
/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0

完整的帮助信息

> find_libpython --help
usage: find_libpython [-h] [-v] [--list-all | --candidate-names | --candidate-paths | --platform-info | --version]

Locate libpython associated with this Python executable.

options:
  -h, --help         show this help message and exit
  -v, --verbose      Print debugging information.
  --list-all         Print list of all paths found.
  --candidate-names  Print list of candidate names of libpython.
  --candidate-paths  Print list of candidate paths of libpython.
  --platform-info    Print information about the platform and exit.
  --version          show program's version number and exit

作为库的用法可能发生在您需要获取在基于Python的构建系统(如distutils)中的库路径时。建议使用find_libpython方法,该方法将返回libpython的路径作为字符串,或者如果找不到,则返回None

>>> from find_libpython import find_libpython
>>> find_libpython()
'/home/kaleb/miniconda3/envs/test/lib/libpython3.8.so.1.0'

项目详情


下载文件

下载适用于您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源代码分发

find_libpython-0.4.0.tar.gz (9.0 kB 查看哈希值)

上传时间 源代码

构建分发

find_libpython-0.4.0-py3-none-any.whl (8.7 kB 查看哈希值)

上传时间 Python 3

由以下提供支持