是否可以从 setuptools setup.py 中获取 PyQt?

发布于 2024-10-11 02:17:52 字数 1073 浏览 6 评论 0 原文

我正在构建一个使用 PyQt 的小型应用程序,并且认为最好在 setup.py 中声明该依赖项。

然而,根据这个博客(第一次在谷歌上搜索pyqt setuptools)说它不能完成,最后一段此处也不会尝试这样做。

有想法吗?也许我应该切换到位于 PySide /" rel="noreferrer">PyPi?

更新:

setup.py 中明显的 install_requires = [ 'pyqt >= 0.7' ] 给了我:

D:\3rd\BuildBotIcon\my-buildboticon\python>setup.py test
running test
install_dir .
Checking .pth file support in .
C:\Python26-32\pythonw.exe -E -c pass
Searching for pyqt>=4.7
Reading http://pypi.python.org/simple/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/download
No local packages or download links found for pyqt>=4.7
error: Could not find suitable distribution for Requirement.parse('pyqt>=4.7')

I'm building a small app that uses PyQt and tought it'd be nice to declare that dependency in setup.py.

However, according to this blog (first hit on google for pyqt setuptools) says it can't be done, and the last paragraph here doens't try to do it either.

Ideas? Perhaps I should switch to PySide which is on PyPi?

Update:

The obvious install_requires = [ 'pyqt >= 0.7' ] in setup.py gives me:

D:\3rd\BuildBotIcon\my-buildboticon\python>setup.py test
running test
install_dir .
Checking .pth file support in .
C:\Python26-32\pythonw.exe -E -c pass
Searching for pyqt>=4.7
Reading http://pypi.python.org/simple/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/
Reading http://www.riverbankcomputing.com/software/pyqt/download
No local packages or download links found for pyqt>=4.7
error: Could not find suitable distribution for Requirement.parse('pyqt>=4.7')

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

む无字情书 2024-10-18 02:17:52

是的,PyQT 包没有使用 distutils / setup.py 进行安装,因此无法使用 easy_install 或 pip 安装。您需要手动下载并安装它。

这也意味着您不应该将其放入您的 requires 元数据中,因为 easy_install 和 pip 会尝试安装它并失败。

我不知道PySide好不好,但它也没有setup.py,而且也拒绝使用easy_install/pip安装,所以不是一个好的选择。 :)

另一种选择是使用 distutils 重新打包 PyQt,但这可能需要大量工作。

Right, the PyQT packages are not using distutils / setup.py for it's installation, so they can't be installed with easy_install or pip. You need to download and install it manually.

That also means you should not put it in your requires metadata, as easy_install and pip then will try to install it and fail.

I don't know if PySide is any good, but is also has not setup.py, and also refuse to install with easy_install/pip, so not a good option. :)

Another option is to repackage PyQt with distutils, but that may be a lot of work.

流云如水 2024-10-18 02:17:52

虽然由于现在可用的轮子(如@mfitzp建议),您可以pip install pyqt5,但不能通过install_requiressetup.py要求它>。原因是 setuptools 不知道如何安装 pip 知道如何安装的轮子,而 PyQT5 只能作为 PyPI 上的轮子使用(没有源代码分发,即没有 tar.gz 文件)。请参阅此电子邮件以及错误报告了解详细信息。

While you can pip install pyqt5 thanks to the now available wheels (as suggested by @mfitzp), it cannot be required from setup.py via install_requires. The reason is that setuptools doesn't know how to install wheels which pip knows how to, and PyQT5 is only available as wheels on PyPI (there is no source distribution, i.e. no tar.gz file). See this email and that bug report for details.

各自安好 2024-10-18 02:17:52

虽然接受的答案最初是正确的 Python Wheels 现在提供了一种安装 C 扩展包(例如 PyQt5)的方法,而无需编译从源头。

PyPi 目前在 Python3 上为多个平台提供了 PyQt5 的 .whl 文件,包括 MacOS X、Linux(任何)、Win32 和 Win64。例如,这是在 Mac 上的 Python3 上 pip 安装 PyQt5 时的输出:

mfitzp@MacBook-Air ~ $ pip3 install pyqt5
Collecting pyqt5
  Downloading PyQt5-5.6-cp35-cp35m-macosx_10_6_intel.whl (73.2MB)
    100% |████████████████████████████████| 73.2MB 2.5kB/s 
Collecting sip (from pyqt5)
  Downloading sip-4.18-cp35-cp35m-macosx_10_6_intel.whl (46kB)
    100% |████████████████████████████████| 49kB 1.8MB/s 
Installing collected packages: sip, pyqt5
Successfully installed pyqt5-5.6 sip-4.18

如果您的目标是 Python3+PyQt5,那么在 setup.py 中将 PyQt5 指定为正常依赖项应该没有问题。

While the accepted answer was originally correct Python Wheels now provide a means to install C extension packages such as PyQt5 without the need for compilation from source.

PyPi currently has .whl files for PyQt5 on Python3 for multiple platforms, including MacOS X, Linux (any), Win32 and Win64. For example, this is the output when pip-installing PyQt5 on Python3 on a Mac:

mfitzp@MacBook-Air ~ $ pip3 install pyqt5
Collecting pyqt5
  Downloading PyQt5-5.6-cp35-cp35m-macosx_10_6_intel.whl (73.2MB)
    100% |████████████████████████████████| 73.2MB 2.5kB/s 
Collecting sip (from pyqt5)
  Downloading sip-4.18-cp35-cp35m-macosx_10_6_intel.whl (46kB)
    100% |████████████████████████████████| 49kB 1.8MB/s 
Installing collected packages: sip, pyqt5
Successfully installed pyqt5-5.6 sip-4.18

If you are targeting Python3+PyQt5 then you should have no problem specifying PyQt5 as a normal dependency in setup.py.

給妳壹絲溫柔 2024-10-18 02:17:52

Setuptools >= 38.2.0 现在知道如何安装轮子。< /strong> 因此,简单的答案是安装最新版本的 setuptools,并要求您的开明用户群也这样做。要在安装时强制使用 setuptools >= 38.2.0,请参阅其他地方的相关答案

自从 setuptools 38.2.0 发布一年多以来,这个问题之前的所有答案都已经过时、公然错误,而且用处不大。

Setuptools >= 38.2.0 now knows how to install wheels. The trivial answer, therefore, is to install a recent version of setuptools and require that your enlightened userbase does so as well. To enforce usage of setuptools >= 38.2.0 at installation time, see this relevant answer elsewhere.

Since setuptools 38.2.0 was released over a year ago, all prior answers to this question are horrifyingly obsolete, blatantly wrong, and less than useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文