When distributed independently of Zephyr, DTSh has to re-package snapshots of the python-devicetree library, which is normally part of Zephyr's devicetree tooling (5e803eb).
Zephyr users will then end up with two instances of this library:
the one that comes with Zephyr, on which it will rely at build-time
the one installed with DTSh
This is almost harmless because Zephyr's tools that depend on the Python devicetree package will still prefer the version at zephyr/scripts/dts/python-devicetree/src, thanks to sys.path manipulations:
# This relies on this file being zephyr/scripts/foo/bar.py.
# If you move this file, you'll break it, so be careful.
THIS_ZEPHYR = Path(__file__).parent.parent.parent
ZEPHYR_BASE = Path(os.environ.get('ZEPHYR_BASE', THIS_ZEPHYR))
# FIXME we need a nicer way to handle imports from scripts and cmake than this.
ZEPHYR_SCRIPTS = ZEPHYR_BASE / 'scripts'
ZEPHYR_CMAKE = ZEPHYR_BASE / 'cmake'
# Runners depend on edtlib. Make sure the copy in the tree is
# available to them before trying to import any.
sys.path.insert(0, str(ZEPHYR_SCRIPTS / 'dts' / 'python-devicetree' / 'src'))
Relying on how Zephyr imports the library sounds a but ugly, though. And will break one day or another.
AFAICT, we can't properly address this issue when installing DTSh from PyPY (this would require that both Zephyr and DTSh depend on and install independently released versions of python-devicetree).
Note: DTSh could implement some ugly sys.path manipulation to also prefer the devicetree library that comes with Zephyr (e.g. when ZEPHYR_BASE is set), but then it's likely that it won't import the version of the library it's been developed and tested with. This is not a proper fix.
When distributed independently of Zephyr, DTSh has to re-package snapshots of the python-devicetree library, which is normally part of Zephyr's devicetree tooling (5e803eb).
Zephyr users will then end up with two instances of this library:
This is almost harmless because Zephyr's tools that depend on the Python
devicetree
package will still prefer the version atzephyr/scripts/dts/python-devicetree/src
, thanks tosys.path
manipulations:Relying on how Zephyr imports the library sounds a but ugly, though. And will break one day or another.
AFAICT, we can't properly address this issue when installing DTSh from PyPY (this would require that both Zephyr and DTSh depend on and install independently released versions of python-devicetree).
Note: DTSh could implement some ugly
sys.path
manipulation to also prefer thedevicetree
library that comes with Zephyr (e.g. whenZEPHYR_BASE
is set), but then it's likely that it won't import the version of the library it's been developed and tested with. This is not a proper fix.Thanks.