How do you compile a C library with multiple dependencies into a Python package? Cmake?

我怕爱的太早我们不能终老 提交于 2020-01-12 08:10:07

问题


I have a Python package in python3.x I've been writing up which interacts with two C functions in a C library. At the moment, I've been using ctypes whereby I link directly to the shared library *.so, and then use the python script to interact with this.

https://docs.python.org/3/library/ctypes.html#module-ctypes

I'm now confused how to distribute this python package whereby users would install the python package on github or via pip. Somehow, upon installation, the C library would need to be downloaded, unpacked, and compiled.

The issue is, the C library contains several dependencies to other C libraries; I've currently statically linked these libraries, and the entire C library now installs via cmake.

(1) Is it possible to install the C library as it installs now, via cmake? It appears this should be done entirely in setup.py, correct?

(2) I'm confused by the distutils/setuptools issue in this case. Based on this link, https://docs.python.org/3/extending/building.html#building

the correct manner to do this is via distutils, not setuptools. However, setuptools is generally the recommended ways to create/distribute python packages in 2018. Is the documentation above outdated?

来源:https://stackoverflow.com/questions/50709217/how-do-you-compile-a-c-library-with-multiple-dependencies-into-a-python-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!