<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Julien,</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);">
Thank you for your detailed answer:</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"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">"</span><span style="letter-spacing: normal; font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, "system-ui", Roboto, "Helvetica Neue", sans-serif; font-size: 15px; color: rgb(36, 36, 36); background-color: rgb(255, 255, 255); font-weight: 400;">If
 you're interested, let me know. It could motivate me to write a tutorial detailing this method.</span><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">"</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Yes, I would be very interested in that tutorial if you managed to find the time.</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">Regards,</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"><br>
</span></div>
<div class="elementToProof"><span style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">John</span></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 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: jlindsay@uoguelph.ca</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;">
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;">
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;">
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;">
https://twitter.com/whiteboxgeo</a></span><br>
</p>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> QGIS-Developer <qgis-developer-bounces@lists.osgeo.org> on behalf of Julien Moura via QGIS-Developer <qgis-developer@lists.osgeo.org><br>
<b>Sent:</b> Friday, January 19, 2024 3:49 PM<br>
<b>To:</b> qgis-developer@lists.osgeo.org <qgis-developer@lists.osgeo.org><br>
<b>Subject:</b> Re: [QGIS-Developer] QGIS plugin depends on pypi package</font>
<div> </div>
</div>
<div>
<p></p>
<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 IThelp@uoguelph.ca.</div>
<br>
<p></p>
<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="x_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="x_moz-cite-prefix">Le 19/01/2024 à 19:16, John Lindsay via QGIS-Developer a écrit :<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<p class="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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="x_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" class="x_moz-txt-link-freetext" style="margin-top:0px; margin-bottom:0px">
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" class="x_moz-txt-link-freetext" style="margin-top:0px; margin-bottom:0px">
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/" class="x_moz-txt-link-freetext" style="margin-top:0px; margin-bottom:0px">
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" class="x_moz-txt-link-freetext" style="margin-top:0px; margin-bottom:0px">
https://twitter.com/whiteboxgeo</a></span><br>
</p>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> David Strip
<a class="x_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="x_moz-txt-link-rfc2396E" href="mailto:gdt@lexort.com">
<gdt@lexort.com></a>; John Lindsay <a class="x_moz-txt-link-rfc2396E" href="mailto:jlindsay@uoguelph.ca">
<jlindsay@uoguelph.ca></a><br>
<b>Cc:</b> John Lindsay via QGIS-Developer <a class="x_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="x_moz-txt-link-abbreviated" href="mailto:IThelp@uoguelph.ca">IThelp@uoguelph.ca</a>.</div>
<br>
<div class="x_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="x_moz-mime-attachment-header"></fieldset>
<pre class="x_moz-quote-pre">_______________________________________________
QGIS-Developer mailing list
<a class="x_moz-txt-link-abbreviated" href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a>
List info: <a class="x_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="x_moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-developer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
</div>
</body>
</html>