-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
[Feature] Support submodules #1602
Comments
Can you share you |
|
This is currently the only officially supported way.
If this doesn't require firmware changes, I think we could consider supporting this in Pybricksdev. I don't know if we can do full packages, but submodules might work. |
A possible workaround might be parsing all the python files and moving them to the project root and then obviously changing the imports in a script before running pybricksdev run, however it would be quite nice if pybricksdev would support this natively. Looking forward to what you figure out! |
Support for this might have been removed in: pybricks/pybricksdev@ff32826 |
Just hacking around with Pybricksdev a bit to put some of pybricks/pybricksdev@ff32826 back in, it appears that the firmware still works for the following use case (see folder structure on the left). pybricks/pybricksdev@ff32826 was probably done for good reason (as it does make the code cleaner), but maybe there's a way to achieve the same with the |
Seems like this would just work without any modifications required if this bug in python got fixed. python/cpython#84530 It's probably going to take forever until that is fixed though. Would you be able to provide me with a patch with what exactly you changed in pybricksdev to make it work? |
Recapping, there are two "bugs" here, one in the CPython standard library and one is a firmware limitation. And both have workarounds.
|
When compiling multi-file projects that contain a namespace pacakge (folder without __init__.py), we hit Python bug python/cpython#84530. This adds a try/except block to catch the error and raise a more helpful error message. Issue: pybricks/support#1602
I'm affected by this bug too. It would be really nice to be able to have submodules so I could structure code better. I don't fully get what's wrong. |
When compiling multi-file projects that contain a namespace pacakge (folder without __init__.py), we hit Python bug python/cpython#84530. This adds a try/except block to catch the error and raise a more helpful error message. Issue: pybricks/support#1602
Describe the bug
Custom python modules (folders) don't get compiled onto the hub. Everything works fine when I put every python file that gets imported by any other python file into the project root. However, when I try to import a file that's within a directory, this error occurs:
When I add an init.py file to the directory, it successfully uploads the file to the hub but fails importing it:
However, when I remove the actual_module file and put the functions into the init.py file and remove the actual_module part from the import statement, everything works fine (except for my IDE not picking up the function)
To reproduce
Steps to reproduce the behavior:
Expected behavior
It compiles every single file successfully, and it runs without any issues.
Screenshots
I hope my explanation of this issue was sufficient, and thanks in advance!
The text was updated successfully, but these errors were encountered: