问题标签 [python-bindings]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1625 浏览

python-3.x - 可以将 Clutter 与 Python 3 一起使用吗?

Clutter 是否有 Python 3 绑定?如果是这样,我怎样才能得到它们并使用它们?

0 投票
1 回答
1049 浏览

apache-zookeeper - Apache ZooKeeper 的 Python 绑定

有人能告诉我在哪里可以找到 Apache ZooKeeper 的“最新”Python 绑定吗?

0 投票
3 回答
398 浏览

python - 为什么要为 C 等其他语言的现有代码开发 Python 绑定?

为其他语言的现有代码开发 Python 绑定的动机是什么?我看到许多程序员为他们现有的 C 代码开发 Python 绑定。为什么?它有什么帮助?

0 投票
6 回答
8499 浏览

c++ - 生成python绑定,使用什么方法/程序

我正在考虑在我的程序中使用 python (CPython) 来允许在我的环境中编写用户脚本,并允许我使用 pyside,c++ 的 qt 绑定来为我的应用程序创建 GUI。这些可以有效地与 GUI python 代码稍后可以编译掉以提高速度(如果可能的话)的想法分开。

我对 python 非常陌生,我真的在寻找最有效的方法来生成可靠的绑定,并且需要维护的附加代码绝对最少,因为绑定可能会随着项目的发展而经常变化。我需要它以便 python 类扩展具有虚拟的 c++ 类。

我已经研究过 PyBindGen,它经常卡在我的库中的东西上,以至于它实际上没有用。

您在这方面推荐的任何帮助/建议/链接/工作流程都会非常有帮助。

0 投票
1 回答
619 浏览

python - 保护鼻子免受 Python 解释器崩溃

我们有一堆调用 Python C/C++ 绑定的测试。我们用鼻子运行这些测试:

有时,我们的绑定发生了错误,导致 Python 解释器崩溃,例如,在测试号 3 上:

问题:从这种情况中恢复的最佳方法是什么?理想情况下,我宁愿鼻子自己处理这些崩溃,但我知道这是不可能实现的。我想到的下一个解决方案是记下测试并重新启动鼻子,现在跳过糟糕的测试。在我的示例中,这意味着执行测试 1、2、4 和 5,但执行测试 3。有没有办法用鼻子以编程方式实现这一点?还有其他更好的想法吗?

0 投票
3 回答
492 浏览

python - 线程化 python 和 C 绑定同步

我正在为我的一个实时 C 库实现 Python 绑定。我读过 Python 中的线程不是真正的线程,它们并没有真正并行运行(因为全局解释器锁)。不过,我将不得不考虑以下情况。

想象一下下面的 C 函数:

此函数等待互斥体,但通过使用stop, 可以取消。在最简单的情况下,能够优雅地停止使用它的线程,无论互斥锁的其他用户发生什么(例如,如果他们在持有锁时死亡)。

我的问题是弄清楚如何为这个函数编写一个 Python 包装器。通过解析参数(带PyArg_ParseTuple)我可以检索互斥锁,没问题。但是,可以发送给函数的东西的类型似乎是字符串、数字和对象。前两个显然不能代替 a bool *,我怀疑为它编写一个包装器bool *是个好主意。

我的问题是,我怎样才能获得一个参数,它是对变量的引用(与其他 python 线程共享),而不仅仅是它的副本?

这是我缺少的部分的功能(用于类似的用法mutex.stoppable_lock(stop)):

我不知道什么BOOL_STAR"?"应该是什么。

0 投票
1 回答
4887 浏览

python - 使用 python 和 wkhtmltopdf HTML 到 PDF

我刚刚找到wkhtmltopdf,一个使用 webkit 的惊人的 html 转换器。我已经在我的开发机器上尝试过它,它很简单而且效果很好。

这如何最好地与基于 django 的站点集成?

我找到了python bindings,但他们假定对如何安装我没有的东西有一定程度的理解。例如

  • 安装这些 python 绑定后,我该如何使用它们?我可以拨打哪些电话?

  • 生成的 pdf 是否必须保存到 hd 或者我可以用什么东西把它从视图中流出来?

例如:

0 投票
1 回答
1806 浏览

python - Python equivalent of DCT image hash function used in pHash module

I have an existing python program that accepts an image URL and does manipulations on the image loaded. I tried passing the image data to the pHash module in C++ and then get the image hash. I've tried using python extension library to pass the image from python to the C program, but without success. The speed of the whole process is a priority. It includes getting the hash value of query image, finding the similar images from a huge collection of images system. So, instead of passing huge image data, then converting to a CImg image object, I feel that it would be better and easier to just calculate the hash in python code, and pass the hash value to the pHash module for finding out the similar images. So, I am looking forward to get the DCT image hash in Python.

Does anyone has any idea how to get the same hash value in python? I don't want to re invent the wheel. I tried to google and find the equivalent function in python, but no success. Here is the image hash function: ( source: pHash module)

I would really appreciate your help. Thanks a lot

0 投票
1 回答
1018 浏览

python - 如何将基于 Python PyQt 的程序转换为 Linux 中的可移植包?

我已经设法使用 PyInstaller 从基于 PyQt 的 Python 应用程序制作了一个工作可执行文件(适用于 Windows),但它也适用于 Linux 吗?在 linux 机器 (LUbuntu) 上,当我运行 .py 脚本时,我遇到了关于缺少 PyQt 绑定的错误,由于无法连接服务器,我什至无法通过 apt-get 下载它们。以某种方式将丢失的库打包到我的程序文件中会更方便,以使其更具可移植性,但我该怎么做呢?

0 投票
1 回答
588 浏览

python - “编写 python 绑定”与“直接使用命令行”

我有一个关于 python 绑定的问题。

我有一个命令行,它公开了一些功能,并且代码被重构以通过共享库提供功能。我想知道“为共享库编写 python 绑定”与“直接调用命令行”相比,我得到的真正优势是什么。

我认为一个明显的优势是性能,共享库将链接到同一个进程,并且可以在同一个进程中调用该功能。它将避免通过命令行生成新进程。

我可以从为这种情况编写 python 绑定中获得任何其他优势吗?

谢谢。