Repository navigation
Replies: 5 comments 3 replies
|
Relative paths are used since the imports key is usually used to import files for the local test definition which should live in the same repository. Our usecase for this is usually a customer and board specific strategy for the target hardware. For global additions to labgrid I would recommend not using the imports key and rather use your own python module installed into the same virtualenv. |
|
@Emantor What is the 'import key'? I had thought that Python encourages absolute imports. I have tended to uses absolute imports in my own Python programs and have not hit any problems with that |
|
The device configuration YAML contains an imports key which can be a list of python files that are imported before target creation. |
|
Oh yes, I am referring to the 'import' statements. In Chromium OS we require absolute imports since it makes it easier to see where the module is coming from and avoids needing to add . and .. plus subdirs (depending on where your module is) with lots of trial and error. I have definitely found this annoying with labgrid. As mentioned I used to use relative imports for the Python tools I wrote (patman, buildman, binman) but switched to absolute to make it easier to share modules across packages. I see a mention of this in the tutorial video: https://www.youtube.com/watch?v=APIA8aUH98Q (at 1:10 mark) There is much discussion about relative vs. absolute...e.g. this one: |
|
Er, really? https://github.com/numpy/numpy/blob/main/numpy/lib/_arraysetops_impl.py#L23 Anyway, thank you for considering it. I will fumble along with my trial-and-error approach to imports :-) |
Uh oh!
There was an error while loading. Please reload this page.
Why does labgrid use relative paths for imports? When using code inside and outside labgrid, it requires transformation.
Would it not be easier to use absolute imports everywhere?
All reactions