Script subprocesses cannot be debugged
まだ誰も着手していません。
評価
調査の方向性
src/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py から始め、特に is_python と patch_args を確認し、それらの呼び出し元を調べてください。subprocess.run を使用して shebang スクリプトを直接起動する launcher で問題を再現し、サブプロセスの引数にパッチを適用したときに shebang スクリプト内のブレークポイントに到達することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Currently, if a python script is executed directly as a subprocess by using a shebang, it isn't debugged.
This is clear from the code which is currently only checking the executable name for python and family.
Looking at pydevd logs, it exits with "Process is not python, returning." as expected from the code.
Not simple, but IIUC fixing this means that it should open the file, check for a shebang, and replace the executable with the shebang line + script location. I'm uncertain if only patch_args needs to be updated with such logic or every caller of is_python.
Note I don't create the script myself but use project.scripts, and uv_build compiles the script wrapper when running uv sync. A manually shebanged file would naturally have the same issue though is easier for the user to replace with a python invocation - with a project.scripts, there is some awkwardness with it being in the .venv/bin directory, not cwd (I am using a multi-project workspace). As a workaround, I will probably still resolve the absolute path of the script and prepend python.
Environment data
Skipping since it's obvious from the code
Actual behavior
debugpy does not patch the subprocess args for a python script, causing debug to fail
Expected behavior
A python script subprocess can be debugged
Steps to reproduce:
- Create a python script with a shebang
- Create another script that invokes the script directly with
subprocess.run, withoutpython - Debug the launcher script with a breakpoint in the shebang script
My shebang script for a django project created by uv looks like
manage
#!/Users/anuraag/git/workspace/.venv/bin/python3
# -*- coding: utf-8 -*-
import sys
from sysadmin.manage import main
if __name__ == "__main__":
if sys.argv[0].endswith("-script.pyw"):
sys.argv[0] = sys.argv[0][:-11]
elif sys.argv[0].endswith(".exe"):
sys.argv[0] = sys.argv[0][:-4]
sys.exit(main())
- 主要言語
- Python
- スター
- 2.5k
- フォーク
- 205
- 平均マージ
- 1日 5時間
- マージ済み PR(30日)
- 4
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/debugpy のほかの issue
-
pydevd_comm.py start_client() does not set TCP_NODELAY on the connections it opens対応中かも @nightcityblade が 52 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Document "rules"-option対応中かも @nightcityblade が 41 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
wx.EventLoop() deprecation warning対応中かも @nightcityblade が 39 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
debugpy.configure(python=) is not properly documented対応中かも @nightcityblade が 50 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
-
Adapter bootstrap fails with ConnectionRefusedError on WSL2 VirtioProxy or hostAddressLoopback対応中かも @nightcityblade が 6 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
microsoft/debugpy の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
Vector35/community-plugins#376 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
py-econometrics/pyfixest#1883 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
ietf-tools/rfc2html#81 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
mysql/mysql-operator#60 ·
-
Python: Bug: split_plaintext_paragraph / split_markdown_paragraph can return a chunk larger than max_tokens対応中かも @xThreeh が今日担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
microsoft/semantic-kernel#14566 ·
メンテナーはふだん 4 日以内に返信