[QGIS-Developer] QGIS plugin depends on pypi package

Greg Troxel gdt at lexort.com
Fri Jan 19 09:59:46 PST 2024


John Lindsay <jlindsay at uoguelph.ca> writes:

> 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.

I think it would be good to really understand this, and for it to be
documented as part of "how to write plugins".  In pkgsrc, where I am the
maintainer for the qgis package, it is definitely built against the
system python.  However, pip is its own package, and qgis does not
depend on pip.

The real issue is that pip does not play well with the packaging system
world, as pip is itself a package manager and doesn't seem to expect the
packaging system to reserve a namespace under pip for installs.   As a
result of this, I have a practice of deciding to take one of two paths:

  use the packaging system.  Install packages for anything needed.
  Package them if need be.

  create a venv and run pip in that.

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.

> 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.

Which place does it install to?  The system site-packages?

> And the process for manually pip installing within QGIS does not seem
> that straight-forward to me (at least on MacOS).

It sounds like the qpip tool that you were just pointed to likely has
resolved a lot of these things.  I would suggest that trying to really
understand the details of what goes where, what the paths are, and the
boundary between system install, per-user, venv, would help a lot in
ending up with a sound approach.



More information about the QGIS-Developer mailing list