kivy / kivy/python-for-android
can't run python4andorid in debugger in vscode because shprint does not seem to work well in debugpy
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 2k
- Avg merge
- 12h 20m
- Merged PRs (30d)
- 9
Description
The debgger used in vscode, debugpy, seems to not be able to run bulldozer because of code in python-for-android. When running a build sh.basename is called in the python3 recipe. The code is a more complex version of this code:
```python
from pythonforandroid.logger import shprint
import sh
print(shprint(sh.basename, '/a/Python-3.11.5.tgz'))
```
When running without the debugger this works fine, but with the debugger I get:
```
cd /home/guy/workspace/hand_tracker ; /usr/bin/env /home/guy/vpy/bin/python /home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher 59539 -- /tmp/reproduce.py
[INFO]: -> running basename /a/Python-3.11.5.tgz
Traceback (most recent call last):
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 422, in _on_run
cmd.send(self.sock)
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command.py", line 111, in send
sock.sendall(("Content-Length: %s\r\n\r\n" % len(as_bytes)).encode("ascii"))
OSError: [Errno 9] Bad file descriptor
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53, in run
self._on_run()
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 432, in _on_run
self.py_db.dispose_and_kill_all_pydevd_threads()
File "/home/guy/.vscode-oss/extensions/ms-python.debugpy-2025.6.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2558, in dispose_and_kill_all_pydevd_threads
self._client_socket.close()
File "/usr/lib/python3.11/socket.py", line 503, in close
self._real_close()
File "/usr/lib/python3.11/socket.py", line 497, in _real_close
_ss.close(self)
OSError: [Errno 9] Bad file descriptor
6.71s - pydevd: Sending message related to process being replaced timed-out after 5 seconds
Python-3.11.5.tgz
```
Plain sh works fine.
Contributor guide
Research direction
Start with the minimal reproduction using shprint, sh.basename, and the /a/Python-3.11.5.tgz path, then compare plain execution with the VS Code debugpy command shown. Trace the python3 recipe path where sh.basename is called. Done means the build can run under debugpy without the bad-file-descriptor failure while plain sh continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100