是否可以将 C 可执行文件与 Python 绑定?
最近,我工作的公司已经将其代码库现代化为主要使用 Python。上周,我的任务是研究转换我们用来管理某些 USB 设备的实用程序。我很快发现这个程序是高度专业化的,并且可能不可能转换为 Python(老实说我也不想尝试)。我可以访问该程序的源代码。
该程序在 Linux 上运行,当前编译为可执行文件,而不是共享对象 (.so)。
将 Python 绑定到这个程序是可以合理完成的吗?如果是这样,我已经研究过 ctypes、cffi、cython、pybind11 和编写原始 C 绑定,但我不知道最好的方法是什么。如果没有,也没有重大损失——我只需通过子进程调用该程序并解析其输出。
感谢您抽出时间。
Recently, the company I work for has been modernizing their codebases to mostly Python. Last week, I was tasked with looking into converting a utility program we rely on to manage some USB devices. I was quick to discover this program is highly specialized and is likely impossible to covert to Python (nor do I want to attempt it if I'm being honest). I have access to the source code for this program.
This program runs on Linux and currently compiles to an executable, not a shared object (.so).
Is binding Python to this program something that can be reasonably done? If so, I've already looked into ctypes, cffi, cython, pybind11, and writing raw C bindings, but I am lost as to what the best approach would be. If not, there is no major loss--I'll just have to call the program via subprocess and parse its output.
Thank you for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论