Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to require PyQt from setuptools setup.py?

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')
like image 761
Macke Avatar asked Jan 07 '11 17:01

Macke


2 Answers

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.

like image 95
Lennart Regebro Avatar answered Sep 29 '22 12:09

Lennart Regebro


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.

like image 32
mdeff Avatar answered Sep 29 '22 12:09

mdeff