问题
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