[QGIS-Developer] Plugin dependency with binaries: 'best' way to guide user to install?

Pedro Camargo c at margo.co
Fri Apr 1 05:07:02 PDT 2022


Take a look at how it is done in the AequilibraE plugin.

I basically ship the plugin without the binaries and create a menu item where the user can choose to download the binaries.

Once downloaded, restarting the plugin allows it to identify the binaries and deactivate that menu item. 

Cheers,
Pedro  ---- On Fri, 01 Apr 2022 05:00:02 +1000  qgis-developer-request at lists.osgeo.org  wrote ----Send QGIS-Developer mailing list submissions to
    qgis-developer at lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.osgeo.org/mailman/listinfo/qgis-developer
or, via email, send a message with subject or body 'help' to
    qgis-developer-request at lists.osgeo.org

You can reach the person managing the list at
    qgis-developer-owner at lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of QGIS-Developer digest..."


Today's Topics:

   1. Plugin dependency with binaries: 'best' way to guide user to
      install? (Aron Gergely)
   2. Unexpected results from GPKG table query using executeSql()
      (Raymond Nijssen)
   3. Re: Unexpected results from GPKG table query using
      executeSql() (Alessandro Pasotti)
   4. Re: Unexpected results from GPKG table query using
      executeSql() (Raymond Nijssen)


----------------------------------------------------------------------

Message: 1
Date: Thu, 31 Mar 2022 14:09:21 +0200
From: Aron Gergely <aron.gergely at rasterra.nl>
To: qgis-dev <qgis-developer at lists.osgeo.org>
Subject: [QGIS-Developer] Plugin dependency with binaries: 'best' way
    to guide user to install?
Message-ID: <5e3173ec-7b7e-64da-47d1-79d39edc1c10 at rasterra.nl>
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi All,

What would be a good practice to handle 3rd party libs which can't be 
shipped together with a plugin?
I am looking for the most user-friendly way and have an idea.
But thought I would bounce it off the collective wisdom here and see if 
there are other/better ways.

If we find a 'best' method I could PR an update to the QGIS docs or 
PyQGIS cookbook, etc to preserve that knowledge.

Bit of context:
I have a plugin that uses a 3rd party python library which has binaries.
I would like to submit this plugin to the official plugin repository.
According to https://plugins.qgis.org/publish/ it's not allowed to ship 
binaries it with the plugin.
In such case the above webpage recommends telling the end user to run 
"pip.main(...)" from the python console to install missing libraries.

I thought that's not user friendly and it's a pip hack (pip.main() is 
meant to be internal).
Also, I want to handle the missing python module in my plugin 
gracefully: check on plugin load if missing, if so, guide user to 
resolve, preferably without having them write or copy any commands.

The idea:
Using python's subprocess module from within the plugin to call the pip 
CLI, which would install the package the usual pip way. Here's why:
- pip project recommends this way as best practice, warns against the 
pip.main()
- user would not need to write or copy-paste commands
- could make this user friendly: wire it in the plugin code to a push 
button and build it into a dialog e.g.;? if lib is missing on plugin load,
 ? show a QMessageBox and let user open a dialog to resolve. In that 
dialog would be the push button to trigger the pip install via subprocess.

How would this play out multi-platform via subprocess, I have no idea of 
yet - thought if the idea survived this thread, I'd go find out ;)

Do you think this subprocess + pip is a good idea?
Would it be allowed for plugins in the official repository to behave as 
such?
Anyone has other user-friendly ways of doing this?

Best regards,
Aron



------------------------------

Message: 2
Date: Thu, 31 Mar 2022 18:09:25 +0200
From: Raymond Nijssen <r.nijssen at terglobo.nl>
To: qgis-developer <qgis-developer at lists.osgeo.org>
Subject: [QGIS-Developer] Unexpected results from GPKG table query
    using executeSql()
Message-ID: <bba11f52-a64a-6502-fbce-dbc986ba9391 at terglobo.nl>
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi devs,

I'm working on a plugin that connects to a custom table (without 
geometry) in a GPKG. When I'm sending queries to it, I keep on getting 
unexpected results. Somehow the id field is missing, sometimes it 
appears twice (!). And this seems to be different between QGIS 3.10 and 
3.25. (I think it changed since 3.22).

Here is a piece of my code:


fn = '/path/to/test.gpkg'
md = QgsProviderRegistry.instance().providerMetadata('ogr')
conn = md.createConnection(fn, {})

q = 'select * from test_table;'
qr = conn.executeSql(q)
print(qr) # No id field in result



Before diving into the QGIS code I'd like to check if this is the way to 
go. Or should i use another way to query that GPKG (SQLite) db?


Kind regards,
Raymond


------------------------------

Message: 3
Date: Thu, 31 Mar 2022 18:15:00 +0200
From: Alessandro Pasotti <apasotti at gmail.com>
To: Raymond Nijssen <r.nijssen at terglobo.nl>
Cc: qgis-developer <qgis-developer at lists.osgeo.org>
Subject: Re: [QGIS-Developer] Unexpected results from GPKG table query
    using executeSql()
Message-ID:
    <CAL5Q670rrD--ZvEVDTtCWEqU1vZgUe7Nh+e58MLMDMQNPF9h1w at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi Raymond,

your code looks good.

Can you provide a test file?

There are some test in core here:
https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py


On Thu, Mar 31, 2022 at 6:09 PM Raymond Nijssen via QGIS-Developer <
qgis-developer at lists.osgeo.org> wrote:

> Hi devs,
>
> I'm working on a plugin that connects to a custom table (without
> geometry) in a GPKG. When I'm sending queries to it, I keep on getting
> unexpected results. Somehow the id field is missing, sometimes it
> appears twice (!). And this seems to be different between QGIS 3.10 and
> 3.25. (I think it changed since 3.22).
>
> Here is a piece of my code:
>
>
> fn = '/path/to/test.gpkg'
> md = QgsProviderRegistry.instance().providerMetadata('ogr')
> conn = md.createConnection(fn, {})
>
> q = 'select * from test_table;'
> qr = conn.executeSql(q)
> print(qr) # No id field in result
>
>
>
> Before diving into the QGIS code I'd like to check if this is the way to
> go. Or should i use another way to query that GPKG (SQLite) db?
>
>
> Kind regards,
> Raymond
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>


-- 
Alessandro Pasotti
QCooperative:  www.qcooperative.net
ItOpen:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220331/ad1ec7b7/attachment-0001.html>

------------------------------

Message: 4
Date: Thu, 31 Mar 2022 18:52:48 +0200
From: Raymond Nijssen <r.nijssen at terglobo.nl>
To: Alessandro Pasotti <apasotti at gmail.com>
Cc: qgis-developer <qgis-developer at lists.osgeo.org>
Subject: Re: [QGIS-Developer] Unexpected results from GPKG table query
    using executeSql()
Message-ID: <87330c53-a8a5-6e07-dd6e-006fcdd7710f at terglobo.nl>
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi Alessandro,

Thanks for your reply. Will share data and a test script with you privately.

Raymond


On 31-03-2022 18:15, Alessandro Pasotti wrote:
> Hi Raymond,
> 
> your code looks good.
> 
> Can you provide a test file?
> 
> There are some test in core here: 
> https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py 
> <https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgsproviderconnection_ogr_gpkg.py>
> 
> 
> On Thu, Mar 31, 2022 at 6:09 PM Raymond Nijssen via QGIS-Developer 
> <qgis-developer at lists.osgeo.org <mailto:qgis-developer at lists.osgeo.org>> 
> wrote:
> 
>     Hi devs,
> 
>     I'm working on a plugin that connects to a custom table (without
>     geometry) in a GPKG. When I'm sending queries to it, I keep on getting
>     unexpected results. Somehow the id field is missing, sometimes it
>     appears twice (!). And this seems to be different between QGIS 3.10 and
>     3.25. (I think it changed since 3.22).
> 
>     Here is a piece of my code:
> 
> 
>     fn = '/path/to/test.gpkg'
>     md = QgsProviderRegistry.instance().providerMetadata('ogr')
>     conn = md.createConnection(fn, {})
> 
>     q = 'select * from test_table;'
>     qr = conn.executeSql(q)
>     print(qr) # No id field in result
> 
> 
> 
>     Before diving into the QGIS code I'd like to check if this is the
>     way to
>     go. Or should i use another way to query that GPKG (SQLite) db?
> 
> 
>     Kind regards,
>     Raymond
>     _______________________________________________
>     QGIS-Developer mailing list
>     QGIS-Developer at lists.osgeo.org <mailto:QGIS-Developer at lists.osgeo.org>
>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>     <https://lists.osgeo.org/mailman/listinfo/qgis-developer>
> 
> 
> 
> -- 
> Alessandro Pasotti
> QCooperative: www.qcooperative.net <https://www.qcooperative.net>
> ItOpen: www.itopen.it <http://www.itopen.it>


------------------------------

Subject: Digest Footer

_______________________________________________
QGIS-Developer mailing list
QGIS-Developer at lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


------------------------------

End of QGIS-Developer Digest, Vol 197, Issue 39
***********************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220401/7809c541/attachment.html>


More information about the QGIS-Developer mailing list