【おち】
ん!これは、、、このデバッグ方法は、QGISにインストール上のプラグインで実行するらしい。
ということ、おおざっぱな私としては、VSCODでインストールプラグインを直接編集して、プラグインリローダを利用して、デバッグで十分なのではという疑問が。。。
最後まで読まずに、自分の環境に併せて、設定していったが、結果、今回は実際に動くか試さなかった。。。
が!今後のために残しておこう!残念。
最初に、結論を読んでおけばよかった。💦
【環境】
Windows 11
QGIS 3.42
C:\github\yr-qgis-launcher に 「yr-qgis-launcher」をインストール
今回は QGIS 3.42 ポータブル版
最初の環境構築(VSCodeのインストール)
VSCodeのインストール
https://azure.microsoft.com/ja-jp/products/visual-studio-code/
VSCodeでのデバック準備
ptvsdのインストール
・ OSGeo4Wのshellを起動する
C:\github\yr-qgis-launcher\QGIS3.42.0\qgis でcmdを起動する
・pipをインストールする
python -m ensurepip --default-pip
・VSCodeでのデバック用にptvsdをインストール
python -m pip install ptvsd
python.exe -m pip install --upgrade pip
QGISにDebug用プラグイン「debugvs」をインストールする
プラグインの管理とインストールを起動
メニューバー→プラグイン→プラグインの管理とインストール
VSCode側のデバック設定を作成
launch.jsonを作成する
.vscode/launch.json
launch.jsonにリモートデバック用の設定を記載する
例)C:\github\yr-qgis-easyinstantprint のプラグイン
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${C:\github\yr-qgis-easyinstantprint}",
"remoteRoot": "${C:\github\yr-qgis-easyinstantprint}"
}
],
"justMyCode": false
}
]
}
localRoot
C:\github\yr-qgis-easyinstantprint
remoteRoot「直接コードを編集するため、localRootと同じ」
C:\github\yr-qgis-easyinstantprint
justMyCode
他のコード内までデバックを行ないたい場合、falseにする
デバックを実行する
・QGISを起動する
・debugvsのEnable Debug for Visual Studioを実行する
・VSCodeでPython: Remote Attach「launch.jsonで設定」でデバックを実行する
・VSCode上でブレイクポイントを設定し、QGISでプラグインを実行する