[PyQt] How to compile with PyQt5?

Kovid Goyal kovid at kovidgoyal.net
Sun Aug 3 04:05:15 BST 2014


Incidentally, the logic in QSintilla's build system to detect
pyqt_sip_dir is broken on some linux distros. For example, on Arch,
/usr/share/sip contains separate sip bindings for python 2.x and python
3.x. 

ls -d /usr/share/sip/*PyQt*                                                                                                                                                                          
/usr/share/sip/Py2-PyQt5  /usr/share/sip/PyQt4  /usr/share/sip/PyQt5

As best as I can tell, configure.py just does sys.prefix +
'/share/sip/PyQt5' regardless of version.

I suggest that the best way to make this robust is to write this path
in QtCore.PYQT_CONFIGURATION at PyQt install time.

I have calibre currently doing:

def get_sip_dir(q):
    # Every distro has its own bright ideas about where to put the PyQt bindings.
    for x in ('', 'Py2-PyQt5', 'PyQt5', 'sip/PyQt5'):
        base = os.path.join(q, x)
        if os.path.exists(os.path.join(base, 'QtWidgets')):
            return base
    return q
pyqt['pyqt_sip_dir'] = get_sip_dir(sys.prefix if iswindows else os.path.join(sys.prefix, 'share', 'sip'))

Kovid.

On Fri, Jul 25, 2014 at 11:07:49AM +0100, Phil Thompson wrote:
> On 25/07/2014 10:28 am, Kovid Goyal wrote:
> >On Fri, Jul 25, 2014 at 09:47:26AM +0100, Phil Thompson wrote:
> >>On 25/07/2014 4:36 am, Kovid Goyal wrote:
> >>>1600 lines? That's crazy. Here's an extract from calibre's build system.
> >>
> >>To add some perspective to this, the amount of code you have to actually
> >>write for a more representative extension module than QScintilla (eg.
> >>QtDataVisualization) is 80 lines. For that you get a configure.py with a
> >>consistent user interface with other PyQt based extension modules,
> >>support
> >>for cross-compiling to iOS, Android etc etc.
> >
> >Then perhaps people asking about how to build on PyQt 5 should be pointed
> >to one of these more representative modules. I remember that when I was
> >doing the calibre transition to Qt 5 I also came across the advice to
> >look at QScintilla, and rather than trying to adapt that beast, I wrote
> >my own minimal build logic that does what calibre needs.
> 
> QScintilla is the only open source code that uses it.
> 
> >>I might consider moving the boilerplate to a "pyqtbuilder" module where
> >>you
> >>would implement a class representing those 80 lines and pass it to a
> >>Builder
> >>class imported from the module. However that would mean
> >>that, if you were supporting PyQt4 and PyQt5, you would have to handle
> >>which
> >>version of pyqtbuilder to import.
> >
> >Sounds fine to me. I was just trying to help the OP, since from
> >experience, trying to adapt QSintilla's build system is not a task to be
> >taken on lightly. Even just having some officially sanctioned method of
> >gathering information like runtime paths and compiler flags would be
> >helpful. Essentially, something like qmake -query
> 
> I suspect that you looked at it before I did the refactor to the
> easy-to-use, fully-documented version.
> 
> Phil
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,53d231ae16788576112202!
> 
> 

-- 
_____________________________________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_____________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140803/015bccc2/attachment.sig>


More information about the PyQt mailing list