Python封装:将Boost库作为依赖项 [英] Python packaging: Boost library as dependency

查看:58
本文介绍了Python封装:将Boost库作为依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设有人想打包依赖于C ++ boost库的Python(Cython)库.

Assume that someone wants to package a Python (Cython) library that depends on the C++ boost library.

配置 setup.py 的最佳方法是什么,以便正确告知用户需要安装boost库(即 apt-get install libboost-dev)在Ubuntu等其他操作系统中)?还是将boost库包含在python包分发中是更好的做法?

What is the best way to configure the setup.py so that the user is properly informed that it is required to install the boost library (i.e., apt-get install libboost-dev in Ubuntu, etc in other OSes)? Or is it a better practice to include the boost library in the python package distribution?

推荐答案

这个问题最好问为

分发Python扩展的最佳方法是什么,包括外部库依赖项.

What is the best way to distribute a Python extension including an external library dependency.

使用二进制车轮包装更好.

This is better dealt with binary wheel packages.

用户不需要了解有关 setup.py 的任何信息,该代码用于构建和安装源代码.用户只需要下载并安装二进制车轮软件包即可.

User does not need to know anything about setup.py, which is used for building and installing source code. User just needs to download and install a binary wheel package.

仅包含头文件并不能解决需要库与之建立和链接的问题.它还提出了版本不兼容的问题.

Including just the header files does not solve the problem of needing the library to build with and link to. It also opens up issues with version incompatibilities.

所以 setup.py 不需要任何特别之处,它只需要知道在哪里可以找到标头,如果包含了库,标头将成为项目的子目录.要链接的库.

So setup.py need not have anything special about any of this, it just needs to know where to find headers which will be a sub-dir in your project if the library is included and which libraries to link with.

文档中应包含有关如何从源代码进行构建的说明,为此,不仅需要增强功能(Python头文件,适当的编译器等).

The documentation should include instructions on how to build from source, for which more than just boost is needed (python header files, appropriate compilers etc).

auditwheel 之类的工具,然后将外部库依赖项捆绑到二进制文件轮中,因此请结束-用户无需安装库即可使用您的软件包.

Tools like auditwheel then take care of bundling external library dependencies into the binary wheel, so end-users need not have the library installed to use your package.

另请参阅许多Linux ,以分发二进制Python扩展和

See also manylinux for distributing binary Python extensions and this demo project.

这篇关于Python封装:将Boost库作为依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆