Hello Greg,

Thank you for your reply.

"Overall, I'd rather see plugins fail with a message and leave installation as 
a manual decision than have plugins run pip install."

I would be fine with asking users to manually install the dependency after 
installing the plugin however, the problem is that QGIS seems to use its own 
version of Python, rather than the system Python. Opening a terminal and 
running 'pip install whitebox-workflows' is going to install the package in a 
place that my QGIS plugin is unable to run. And the process for manually pip 
installing within QGIS does not seem that straight-forward to me (at least on 
MacOS). This would be a big ask for my potential users. If Whitebox Worfklows 
were pure Python code, then the simplest solution would be just to package that 
code along with my plugin. However, this isn't the case. WbW is actually a 
native Rust-based library that I have used PyO3 to base a Python extension on. 
And so, that native library needs to be compiled for the user's OS and that 
means pip-based installation is the best option. Based on your answer though, 
I'm wondering if this frontend is even possible given what I have in mind. It's 
unfortunate if it can't work because the plugin has many hundred very useful 
tools for geospatial data processing that would be great to access from QGIS 
for users that are perhaps less interested in Python scripting. Anyhow, thanks 
very much for taking the time to reply.

Regards,

John



Prof. John Lindsay

Dept. of Geography, Environment & Geomatics,

The University of Guelph,

Room 122, Hutt Building,

E-mail: jlind...@uoguelph.ca

Phone: (519) 824-4120 ext. 56074

Web: https://geg.uoguelph.ca/faculty/lindsay-john

Research page: https://jblindsay.github.io/ghrg/index.html

WhiteboxTools GIS project: https://www.whiteboxgeo.com/

Twitter: https://twitter.com/whiteboxgeo

________________________________
From: QGIS-Developer <qgis-developer-boun...@lists.osgeo.org> on behalf of Greg 
Troxel via QGIS-Developer <qgis-developer@lists.osgeo.org>
Sent: Friday, January 19, 2024 12:13 PM
To: John Lindsay via QGIS-Developer <qgis-developer@lists.osgeo.org>
Subject: Re: [QGIS-Developer] QGIS plugin depends on pypi package

CAUTION: This email originated from outside of the University of Guelph. Do not 
click links or open attachments unless you recognize the sender and know the 
content is safe. If in doubt, forward suspicious emails to ith...@uoguelph.ca.


John Lindsay via QGIS-Developer <qgis-developer@lists.osgeo.org> writes:

> Besides, a better solution would be for the plugin to install this
> package via pip when it is itself first installed and launched. I
> tried to accomplish this with the following code:
>
> https://github.com/jblindsay/whitebox_workflows_for_qgis/blob/4e463262f6cfd1987afa2f3f7e0e79656eb8d27e/whitebox_workflows_for_qgis_provider.py#L56
>
> This code, which runs whenever the plugin is launched, first checks to
> see if whitebox_workflows can be imported and if not, it runs pip from
> the Python script to install it. Unfortunately, some users have
> reported issues with this not working correctly:

(Writing from the UNIX perspective.)

Perhaps biased by my packaing background, I view any code that downloads
other code at runtime (without an explicit user request) as a security
bug.   This is especially true if it isn't getting sources pinned to a
version and validated by checksum.

That said, there's a lot of interesting questions about how to deal with
dependencies of plugins.   For qgis itself, dependencies are properly
dealt with by a packaging system and that seems ok.

For plugins, I could see treating them as python modules and packaging
them, but qgis wants to have its own package management system.

qgis is usually installed, via packaging, globally (/usr or /usr/pkg, or
similar).  The immediate question is where plugins go.  I'd expect them
to be in the user's file area vs system, unless installing them in some
administrator role.  The next question is, if they depend on something,
what prefixes and install methods are expected for those things, both
regular packages (programs and shlibs) and python modules.  Which is
partly/mostly about what the search paths are in the plugin execution
environment.

Overall, I'd rather see plugins fail with a message and leave
installation as a manual decision than have plugins run pip install.
But I get it that most people probably don't see it that way.
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

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

Reply via email to