-
Notifications
You must be signed in to change notification settings - Fork 181
Add possibility to extract all packages with extractPackages
#1424
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
Conversation
|
I tested debugging with VSCode a little further and noticed that there is another problem when debugging with VSCode: Chaquopy apparently only extracts the .py files during the first import and not all of them at startup. This seems to be problematic if you have already set breakpoints in VSCode before starting the debug session. These breakpoints are transferred to the app when you first connect to debugpy. At this point, however, the modules have not yet been imported and therefore not yet extracted. I need to investigate this further and switch this PR to a draft. |
|
I have extended the code so that when using the wildcard |
What happens in this case? Does it give an error, or does it just silently fail to set the breakpoint? And is it the same behavior for Python files which were imported (but not extracted) before setting the breakpoint? |
|
It would be unfortunate if debugpy requires this, but if there's no other way to get it to work, then I guess this is the best solution. Is it still necessary to extract the files even when |
|
Please also add a change note in product/runtime/docs/sphinx/changes. |
It fails to set the breakpoint. You can see it when the debugger starts and you want to set a breakpoint, but the breakpoint is grey and not turning red. An error message is not shown.
Yes, the same behavior.
I investigated further if the extraction is required for debugging. Basically, VSCode also supports debugging modules that are stored in In my test I created the following With an def print_hello_world():
print("Hello World!")And tested it via I noticed that the As I understand chaquopy, the source code of the application I am running with
So I would expect the
But when running it (with So the path does not contain If Chaquopy would be modified so that the |
|
Thanks for the explanation. Yes, this is a complicated area, but I've found it's necessary in order to get good performance. The most portable approach, both for data files and for debuggers, is to not assume that anything exists as an individual file, and use APIs like So our current approach is:
Even though debugpy understands zipimport, it looks like it's not quite flexible enough to handle what our importer does, so let's continue with this wildcard approach. |
|
It's not possible to test more than one All that remains is to add an integration test to the ExtractPackages class of test_gradle_plugin.py. This file has changed quite a bit in the last week, so I suggest you merge from the master branch before you edit it. You'll also need to update the Instructions for running the integration tests are in product/gradle-plugin/README.md, and you might also find it useful to look at how GitHub Actions runs them in .github/workflows/ci.yml. Please also add a change note in product/runtime/docs/sphinx/changes. |
4bbff0e to
b961da7
Compare
|
I added the integration tests and the changelog. So this PR is ready for a new review. |
|
For future reference:
Thanks for the contribution! |
I am currently working on debugging support for Android applications with VSCode and debugpy (beeware/briefcase#2351).
Briefcase is using the remote debugging feature of debugpy for VSCode debugging. For this to work correctly, the Python source code must be available on both, the host PC and the Android device. These are linked via path mappings. However, this requires that the .py files are also available on the Android device. Otherwise, it is not possible to set breakpoints on the host PC in VSCode, which are then transferred to the Android device.
Extracting the .py files is currently possible in chaquopy via extractPackages, but you have to explicitly specify the modules to extract. So it is not possible to debug the whole application. You always have to specify which files you want to debug. This would be quite annoying for users of Briefcase.
Therefore, there should be a way to extract all .py files of all modules. I suggest that
extractPackagesshould interpret the value*that all modules should be unpacked.