Search code examples
pythonpyqtsetuptoolsdistutils

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')

Solution

  • 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.