[QGIS-Developer] Is there a recommended way to include external Python packages

Gerald Kogler geraldo at servus.at
Thu Jul 21 14:12:13 PDT 2022


Thanks for your recommendations, with that in mind I'll go for the 
option 2, shipping the 3rd party package with the plugin.

Till now I did that including the whl-file, but after looking at your 
plugins I see the advantage of your code of adding the directory which 
contains the library to sys.path and then doing an import (see 
https://github.com/NationalSecurityAgency/qgis-datetimetools-plugin/blob/master/__init__.py) 



On 21/7/22 19:33, C Hamilton wrote:
> Generally speaking it is not recommended, but I have done it with 
> several of my plugins (KML Tools, Date/Time Tools). If your python 
> package is OS dependent (not pure python) then you don't want to include 
> it with your plugin. My Density Analysis plugin can use the optional H3 
> library (which I think might be worthwhile for QGIS to include as a part 
> of its libraries), but it is machine dependent so I did not include it. 
> It is not ideal to have users pip install the library, but you have to 
> weigh the costs vs. the benefits of using some library.
> 
> Good luck!
> 
> On Thu, Jul 21, 2022 at 1:19 PM Gerald Kogler via QGIS-Developer 
> <qgis-developer at lists.osgeo.org <mailto:qgis-developer at lists.osgeo.org>> 
> wrote:
> 
>     I'm actually developing a QGIS plugin which depends on pysftp
>     package to
>     upload files to a server. For now I thought on asking users to install
>     it manually, but it would be great to automatize the installation
>     process.
> 
>     So the options I see would be:
>     1. Install external package using pip from inside the plugin.
>     2. Include and ship external package with the plugin.
>     3. Ask user to install it manually using pip install.
> 
>     Is there a recommended way to handle this situation?
>     _______________________________________________
>     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>
> 



More information about the QGIS-Developer mailing list