Open freakboy3742 opened 1 year ago
Notes on PyCharm:
PyCharm has built in options for adding the content root (the "project" directory. . . usually) and the sources root to the path as part of its run function. Oddly, I cannot seem to disable the content root if I'm using the sources root. This might be a bug in pycharm.
The setting the working directory to the user's home is simple there's a field for it.
This also runs in the debugger without issue.
Testing configuration:
This was actually easier, I started with the default test runner configuration for pytest, and filled in the relevant fields. Here, the content root and sources root are actually separate check boxes and seem to work more reliably.
Anleitung für das Debugging einer BeeWare-Anwendung in Visual Studio Code:
Vorbereitung des Projekts:
Konfiguration der Debugging-Einstellungen:
launch.json
-Datei oder bearbeite die vorhandene mit der folgenden Konfiguration:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true
}
]
}
Start des Debuggings:
briefcase dev
ein, um deine BeeWare-Anwendung zu starten.Debugging:
Beenden des Debuggings:
Hi:)
I tried to use the solution for debugging briefcase dev
in Visual Code on a Windows 10 System.
My briefcase version is: 0.3.18
Visual Studio Code version is: 1.89.1
I tried to use this launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true
}
]
}
I run briefcase dev
in the integrated Terminal.
I run the Debugger with the name Python Debugger: Attach using Process Id
I am asked to select the process. The briefcase.exe is shown as expected.
After selecting it there are shown three items under CALL STACK:
The problem is:
- None of my breakpoints is working
Can anybody validate if this solution actually works and give feedback?
@eltoro0815 If you're on Windows, the issue is almost certainly the threading approach used by Windows apps. A Toga windows app immediately starts a subthread which is where the app actually runs. I have no idea if VSCode needs special handling to catch breakpoints in that subthread, but given that we're using the Windows threading API to start that thread, not the Python API, it wouldn't surprise me if VSCode isn't able to "see" the child thread.
What is the problem or limitation you are having?
briefcase dev
is the documented way to run a Briefcase app; however, the only way to debug an app withbriefcase dev
is to set abreakpoint()
and use pdb. This is less than ideal, as modern IDEs provide built-in debuggers and test runners.Describe the solution you'd like
Add documentation how to configure VSCode, PyCharm, and other common IDEs so that their native "run" and "test" mechanisms reproduce what
briefcase dev
does.The tl;dr is that you need to:
sources
to the PYTHONPATHfrom the PYTHONPATH (it's usually the first entry in
sys.path`)python -m myapp
)To run in test mode, you also need to add all the directories mentioned in
test_sources
, plus change the runtime module totests.myapp
.Specifics can be found by reverse engineering
src/briefcase/commands/dev.py
.We should document the specific instructions for configuring common IDEs (at present, I'd say that means VSCode and PyCharm); but we should also document the generic requirements so that any other IDE user knows what is needed.
Describe alternatives you've considered
Continue to encourage
briefcase dev
andbreakpoint()
.Additional context
Documenting manual configuration is a stop-gap measure. Longer term, it would be desirable to capture these instructions as a Briefcase plugin for VSCode and PyCharm.