-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --debug
option to briefcase run
#2147
Comments
Thanks for the investigation work on this - this is all extremely thorough! I'm especially impressed by the android debugging work - I had pretty much assumed that wouldn't be possible without major effort, so I'm very much pleasantly surprised you've got that to work. It makes me wonder if the same approach will work on iOS as well.. Broadly, I agree that this (or something similar to it) would be worth pursing. It's not a small task... but it would definitely be a huge value-add. A couple of high level things that stood out to me as questions/issues to be resolved:
|
iOS DebuggingI have now also tested debugging an iOS app in the iOS Simulator and this works without any problems. For the iOS Simulator it is not even necessary to execute an equivalent to PyCharmI also took a look at PyCharm. Remote debugging is only possible with PyCharm Professional, unfortunately PyCharm Community does not support it. But thanks to the 30 day trial I was able to try it out. Basically it works similar to VSCode, except that But if you work with the workaround described in #2152 (remove App as Debug Server (only VSCode):
(Under Android, In principle, I find this approach easier to use, as you can simply start the app and attach the debugger later. You can even restart the debugger. App as Debug Client (VSCode and PyCharm):
(Under Android, This approach is sometimes a bit difficult if you have already started the app but have forgotten to start the debugger in the IDE. Then you have to restart the App. Setting path mappings from appWhat I also found out is that you can also set the path_mappings = [(host_path_1, device_path_1),(host_path_2, device_path_2)]
import pydevd_file_utils
pydevd_file_utils.setup_client_server_paths(path_mappings) This makes setting up the IDE much easier, as the end user does not have to deal with the different paths of Windows/iOS/Android and does not have to have different debug configurations for the different operating systems in the To identify the correct path i currently use this code: path_mappings = []
if sys.platform == "android":
host_app_path = f"{host_workspace}/src"
device_app_path = list(filter(lambda p: True if "AssetFinder/app" in p else False, sys.path))
if len(device_app_path) > 0:
path_mappings.append((host_app_path, device_app_path[0]))
host_requirements_path = f"{host_workspace}/build/{app_name}/android/gradle/app/build/python/pip/debug/common"
device_requirements_path = list(filter(lambda p: True if "AssetFinder/requirements" in p else False, sys.path))
if len(device_requirements_path) > 0:
path_mappings.append((host_requirements_path, device_requirements_path[0]))
elif sys.platform == "win32":
# Normally app & requirements are automatically found. But the app path is pointing to a copy of the source in some temporary folder, so we redirect it to the original source.
host_app_path = f"{host_workspace}/src"
device_app_path = list(filter(lambda p: True if p.endswith("app") else False, sys.path))
if len(device_app_path) > 0:
path_mappings.append((host_app_path, device_app_path[0])) Integration in briefcaseI completely agree with you on your point 4. So it would make sense to configure the debugging via
These two points are pretty obvious and comparable to the However, it becomes more complicated when inserting the debug code. Maybe we could add a |
Thanks for that update - very comprehensive. Regarding launch.json specifically - I agree that is something that Briefcase should be able to generate; the only question is how/where to make the use of that mapping file easy.
I'm not 100% sure whether
If we're going down the path of another "requires" setting, my inclination would be to use this as an opportunity to move to a better embrace of PEP 621, and adopt the use of However, I'm also not convinced we necessarily need that. The set of dependencies needed by VSCode debugging will be known; as will the set of dependencies need by PyCharm debugging. If you've specified As for |
What is the problem or limitation you are having?
It is inconvenient to debug an packaged applications that was created with
briefcase run
. For Windows und Android I showed the nessesary steps in #1393 (comment).Describe the solution you'd like
To simplify the debugging of packaged versions of the application code, we could extend the
briefcase run
command with an additional parameter--debug <debugger-name>
and debugger specific options.In VSCode the debugger is called
debugpy
. PyCharm is using the packagepydevd-pycharm
. I have not tested PyCharm, but the workflow should be pretty similar to VSCode. So it would make sense to specify the<debugger-name>
in the command line.For
--debug debugpy
it would make sense, to add two more parameters:--debug-debugpy-version <debugpy-version>
: Version that should be added to the requirements (optional, if not set use the latest version)--debug-debugpy-port <debugpy-port>
: Specify the Port to use for debugging (under android this port would be forwared by adb)This new command line parameter would:
debugpy
to the requirements (without adding it explicitly to pyproject.toml).debugpy.listen(...)
to the app (without adding it explicitly to the source code)pathMappings
inlaunch.json
, so that the user dont have to search them manuallyThat would simplify the debugging process to only run
briefcase run android --debug debugpy --debug-debugpy-port 5678
and add the VSCode configuration tolaunch.json
.Describe alternatives you've considered
Leave the steps nessesary to debug an packaged application as decribed in #1393 (comment).
Additional context
This command line option could also be useful later for implementing a VSCode/PyCharm extension, as suggested here.
The text was updated successfully, but these errors were encountered: