Skip to content
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

ci: possible multiple different versions of python-devicetree #2

Open
dottspina opened this issue Feb 26, 2024 · 0 comments
Open

ci: possible multiple different versions of python-devicetree #2

dottspina opened this issue Feb 26, 2024 · 0 comments

Comments

@dottspina
Copy link
Owner

dottspina commented Feb 26, 2024

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.

Thanks.

@dottspina dottspina changed the title Possible multiple different versions of python-devicetree ci: possible multiple different versions of python-devicetree Mar 13, 2024
dottspina added a commit that referenced this issue Apr 12, 2024
The PropertySec.path API in the python-devicetree library
wrongly tells all properties originate from the top-level
binding file, which causes the cat command to show
misleading and confusing paths (see issue #5).

We've proposed a patch upstream, but its review clearly is
not a priority (the underlying issue has no consequence on
Zephyr use of the library).

Applying this patch here:
- does actually fix the cat command, and does not otherwise break DTSh
- can't break Zephyr in any way (will still use its own unpatched
  version of the python-devicetree library, see issue #2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant