[Qgis-developer] Python unit tests and SIP API version

Nathan Woodrow madmanwoo at gmail.com
Tue Jun 18 15:50:08 PDT 2013


Hey Chris,

Yes I forgot to mention that any standalone pyqgis scripts, like the unit
tests, will need to have the sip version set before PyQt4 is imported.  On
Python < 3 PyQt4 will automatically set its SIP version to 1.  In Python >
3 this will change but for now you will have to set it your self.

What I did think of doing was setting the SIP version in qgis.core so that
if you import them first then everything is set for you.  What are your
thoughts on doing this?

- Nathan


On Wed, Jun 19, 2013 at 5:59 AM, Chris Crook <ccrook at linz.govt.nz> wrote:

> Ok I've found it at
>
> http://stackoverflow.com/questions/6238193/pyqt-new-api-with-python-2
>
> Looks like I need to add
>
> import sip
> API_NAMES = ["QDate", "QDateTime", "QString", "QTextStream", "QTime",
> "QUrl", "QVariant"]
> API_VERSION = 2
> for name in API_NAMES:
>     sip.setapi(name, API_VERSION)
>
> before importing from PyQt4.QtCore.  And also to not try and import
> QString.
>
> Seems to be working..
>
> Chris
>
> > -----Original Message-----
> > From: Chris Crook
> > Sent: Wednesday, 19 June 2013 6:15 a.m.
> > To: qgis-developer at lists.osgeo.org
> > Subject: [Qgis-developer] Python unit tests and SIP API version
> >
> > Hi
> >
> > Currently when I run make the unit tests (unbuntu) the delimited text
> > python tests are running under SIP API version 1, or possibly some sort
> of
> > strange mixture, and seem to be failing.  So if I do
> >
> > from PyQt4.QtCore import QVariant
> > import sip
> >
> > print sip.getapi('QVariant')
> >
> > I get '1'.  I see sip as a setapi function, which I guess I should be
> using to set
> > the API I want.  Anyone know how to use it?
> >
> > Thanks
> > Chris
> >
> > This message contains information, which is confidential and may be
> > subject to legal privilege. If you are not the intended recipient, you
> must
> > not peruse, use, disseminate, distribute or copy this message. If you
> have
> > received this message in error, please notify us immediately (Phone 0800
> > 665 463 or info at linz.govt.nz) and destroy the original message. LINZ
> accepts
> > no responsibility for changes to this email, or for any attachments,
> after its
> > transmission from LINZ. Thank You.
>
>
> This message contains information, which is confidential and may be
> subject to legal privilege. If you are not the intended recipient, you must
> not peruse, use, disseminate, distribute or copy this message. If you have
> received this message in error, please notify us immediately (Phone 0800
> 665 463 or info at linz.govt.nz) and destroy the original message. LINZ
> accepts no responsibility for changes to this email, or for any
> attachments, after its transmission from LINZ. Thank You.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20130619/c4a2e53c/attachment.html>


More information about the Qgis-developer mailing list