<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello John,</p>
<p><br>
</p>
<p>It's a recurring issue/question since QGIS does not support pip
dependencies and that PyQGIS plugins are not following the
official Python packaging standards from PEPs and related formats
(typically metadata.txt instead of setup.cfg, pyproject.toml). You
will find some unsuccessful QEPs about this. For example: <a
class="moz-txt-link-freetext"
href="https://github.com/qgis/QGIS-Enhancement-Proposals/issues/202">https://github.com/qgis/QGIS-Enhancement-Proposals/issues/202</a>.</p>
<p><br>
</p>
<p>Shortly, here come 3 workarounds:</p>
<ul>
<li>basic: run pip install in a rough subcommand. Not so elegant
but still efficient.</li>
<li>re-wheeling: implement a minimalist (or complete) 3rd party
packages managers, miming pip through QgsNetwork tooling. Best
example I know until today: ENMap-Box plugin (see attached
screenshot or try it yourself).</li>
<li>YAML addicts: run your pip install during your plugin's
packaging job in CI and include external dependencies in a
subfolder before deploying it to your favorite plugins
repository. Then, manage install loading from your plugin with
try/except ImportError and 'site' module. This is the way I
prefer and use for years now. Main downside: for dependencies
requiring a specific compilation on an operating system, you
need to include various outputs. See <a
href="https://github.com/DINFO-UniFI/RoofClassify">Roof
Classify</a> (GitHub Workflow), <a
href="https://gitlab.com/Oslandia/qgis/thyrsis">Thyrsis</a>
(GitLab CI), <a
href="https://gitlab.com/Oslandia/qgis/QSoccer/">QSoccer</a>
(GitLab CI), <a href="https://gitlab.com/Oslandia/qgis/qduckdb">QDuckDB</a>
(GitLab CI)... If you're interested, let me know. It could
motivate me to write a tutorial detailing this method.<br>
</li>
<li>bravehearts: working on packaging your dependencies into
osgeo4w; but they probably won't be included in default QGIS
packages (.msi)<br>
</li>
</ul>
<p>Just a quick advice: if you do some pip install within your
plugin, during the packaging or during the run, make it under a
custom folder related only to your plugin and use site to load
extra dependencies in the QGIS Python environment to avoid issues.<br>
</p>
<p><br>
</p>
<p>Good luck!</p>
<p>Regards</p>
<p> Julien</p>
<p><br>
</p>
<p></p>
<div class="moz-cite-prefix">Le 19/01/2024 à 19:16, John Lindsay via
QGIS-Developer a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:YQBPR0101MB4242C40E651324966C9587E9C1702@YQBPR0101MB4242.CANPRD01.PROD.OUTLOOK.COM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<p class="elementToProof"
style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Agreed,
when I 'print(sys.executable)' from within the QGIS Python
Console (on my MacBook Pro), I see:</span></p>
<p class="elementToProof"
style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></p>
<p class="elementToProof"
style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">/Applications/QGIS.app/Contents/MacOS/QGIS</span></p>
<p class="elementToProof"
style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></p>
<p class="elementToProof"
style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">But
from my system terminal, I see:<br>
<br>
</span></p>
<p class="elementToProof"
style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Menlo; font-size: 11px; color: rgb(0, 0, 0);">/Library/Frameworks/Python.framework/Versions/3.11/bin/python3</span></p>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
So QGIS, at least on a Mac, does seem to have it's own version
of Python installed. And there is not clear way, again on a Mac
at least, to pip install to the QGIS Python such that a plugin
will be able to see a package. Now, this said, on my Linux
machine, installing my Whitebox Workflows plugin did not run
into an error at all and so I'm left wondering if this is
perhaps, as Greg suggested, a particular binary distribution
issue related to QGIS on MacOS. Could be.</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof"
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
John</div>
<div id="Signature">
<div
style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="divtagdefaultwrapper" dir="ltr"
style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<p style="margin-top: 0px; margin-bottom: 0px;">Prof. John
Lindsay</p>
<p
style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Arial, Helvetica, sans-serif;">
<span style="font-size: 12pt; color: rgb(0, 0, 0);">Dept. of
Geography, Environment & Geomatics,</span></p>
<p
style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Arial, Helvetica, sans-serif;">
The University of Guelph,</p>
<p
style="margin-top: 0px; margin-bottom: 0px; font-family: Calibri, Arial, Helvetica, sans-serif;">
Room 122, Hutt Building,</p>
<p style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">E-mail:
<a class="moz-txt-link-abbreviated" href="mailto:jlindsay@uoguelph.ca">jlindsay@uoguelph.ca</a></span></p>
<p style="margin-top: 0px; margin-bottom: 0px;">Phone: (519)
824-4120 ext. 56074</p>
<p style="margin-top: 0px; margin-bottom: 0px;">Web: <a
href="https://geg.uoguelph.ca/faculty/lindsay-john"
style="margin-top: 0px; margin-bottom: 0px;"
moz-do-not-send="true" class="moz-txt-link-freetext">
https://geg.uoguelph.ca/faculty/lindsay-john</a></p>
<p style="margin-top: 0px; margin-bottom: 0px;">Research page:
<a href="https://jblindsay.github.io/ghrg/index.html"
title="https://jblindsay.github.io/ghrg/index.html"
style="margin-top: 0px; margin-bottom: 0px;"
moz-do-not-send="true" class="moz-txt-link-freetext">
https://jblindsay.github.io/ghrg/index.html</a></p>
<p style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">WhiteboxTools
GIS project:
<a href="https://www.whiteboxgeo.com/"
style="margin-top: 0px; margin-bottom: 0px;"
moz-do-not-send="true" class="moz-txt-link-freetext">
https://www.whiteboxgeo.com/</a></span></p>
<p style="margin-top: 0px; margin-bottom: 0px;"><span
style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Twitter:
<a href="https://twitter.com/whiteboxgeo"
style="margin-top: 0px; margin-bottom: 0px;"
moz-do-not-send="true" class="moz-txt-link-freetext">
https://twitter.com/whiteboxgeo</a></span><br>
</p>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
face="Calibri, sans-serif" color="#000000"><b>From:</b> David
Strip <a class="moz-txt-link-rfc2396E" href="mailto:qgis-dev@stripfamily.net"><qgis-dev@stripfamily.net></a><br>
<b>Sent:</b> Friday, January 19, 2024 1:10 PM<br>
<b>To:</b> Greg Troxel <a class="moz-txt-link-rfc2396E" href="mailto:gdt@lexort.com"><gdt@lexort.com></a>; John Lindsay
<a class="moz-txt-link-rfc2396E" href="mailto:jlindsay@uoguelph.ca"><jlindsay@uoguelph.ca></a><br>
<b>Cc:</b> John Lindsay via QGIS-Developer
<a class="moz-txt-link-rfc2396E" href="mailto:qgis-developer@lists.osgeo.org"><qgis-developer@lists.osgeo.org></a><br>
<b>Subject:</b> Re: [QGIS-Developer] QGIS plugin depends on
pypi package</font>
<div> </div>
</div>
<div>
<div
style="background-color:#FFEB9C; width:100%; border-style:solid; border-color:#9C6500; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:'Calibri'; color:Black; text-align:left">
<span style="font-weight:bold">CAUTION:</span> 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 <a class="moz-txt-link-abbreviated" href="mailto:IThelp@uoguelph.ca">IThelp@uoguelph.ca</a>.</div>
<br>
<div class="x_moz-cite-prefix">On 1/19/2024 10:59 AM, Greg
Troxel via QGIS-Developer wrote:<br>
</div>
<blockquote type="cite">
<pre>When you say "qgis seems to use its own version", I wonder if that is in
the context of particular binary distribution. And if there really is a
full extra copy of libs, or if it's about a per-user site-packages
directory.</pre>
</blockquote>
The OS4Geo binary distribution contains a Python39 directory
which is a full python installation including python.exe, a Lib
directory which in turn contains a site-packages directory. As
least in my case, this is installed system-wide, not per-user<br>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-Developer mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
</body>
</html>