I am mainly following
AsgerPetersen's gist and MS's visualstudio python-tutorial and qgis developer_cookbook
-
install this extension pack
-
install ptvsd using the QGIS python3 bin:
cd /Applications/QGIS.app/Contents/MacOS/bin
./python3 -m pip install ptvsd
-
do not install firstaid qqis plugin (or uninstall - see comment below)
-
install lmotta/debug_vs_plugin
-
fork and/or clone a plugin repo and open the repo in vs code
cd "~/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins"
git clone [email protected]:onezoomin/VolumeCalculation.git && cd VolumeCalculation && code .
-
If the repo doesn't already have one, add a debug profile and adapt
6b. Choose the qgis bin folder as Python Interpreter/Applications/QGIS.app/Contents/MacOS/bin
-
Try to set a breakpoint somewhere predictable, eg: on the about button
7b. go to qgis and start the vsdebugger
7c. start debugging session from vs code
7d. use the plugin in qgis in a way that will hit your breakpoint
eg: click the volume calc button and then click about in the dialog
windows centric, but conceptually relevant:
https://gispofinland.medium.com/cooking-with-gispo-qgis-plugin-development-in-vs-code-19f95efb1977