foursquare / qgis-plugin

Foursquare Studio plugin for QGIS
https://plugins.qgis.org/plugins/Unfolded/
GNU General Public License v2.0
19 stars 4 forks source link

Set up Sentry (UN-5377) #70

Closed abstractalgo closed 1 year ago

abstractalgo commented 1 year ago

To use Sentry, we need to use sentry-sdk module. However, there's no easy way of distributing QGIS plugin with its additional dependencies. There's absolutely no assurance that the user has pip or any of those packages installed on their machine.

Earlier commits in this PR tried to get a shallow copy of sentry-sdk and just import it with a relative path. However, that module itself depends on multiple other packages as well, so it's not so easy to just get a shallow copy of the module (which is more or less what we did with Unfolded/qgis_plugin_tools module e.g.).

Another way is to make sure that pip is installed by using something like get-pip.py, and then use pip itself to install required dependencies. This is what we do.

When installing sentry-sdk, we pick a specific version because we want to ensure that the rest of the code that depends on it works for sure, so that we don't risk some updated version of sentry-sdk being installed that changes the API and accidentally and silently breaks the plugin.

TODO

Testing

Also, see an example issue or this one.

Notes

Some considerations around installing sentry-sdk and pip:

If the user has these two, this entire thing is a no-op. If the user has pip, but no sentry-sdk package, this will not mess up their modules locally, they will still be able to install other versions etc. If the user doesn't have pip nor sentry-sdk, this again won't inconvenience their packages locally, as they probably weren't using those developer tools either way.

Overall, this does seem like a low-risk way to do things, it's been a sort of recommended way to install additional packages for QGIS plugins, and in good chunk of cases, this probably just becomes a no-op either way.

ilijapuaca commented 1 year ago

I'm not completely sure I understand the need for get-pip, does the end user need to build this plugin themself and we're trying to work around their development environment not having pip installed?

abstractalgo commented 1 year ago

Currently, there's no way to bundle the plugin and deliver it as a standalone. Fortunately enough, we didn't even have such needs so far since we didn't have any extra outside dependencies.

So, in order to be able to have additional dependencies, we need to somehow install them; and to install deps, we need pip. And that's what get-pip is about - providing an installer for pip.

cc @ilijapuaca