python-development-shell.rst 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. .. SPDX-License-Identifier: CC-BY-SA-2.0-UK
  2. Using a Python Development Shell
  3. ********************************
  4. Similar to working within a development shell as described in the
  5. previous section, you can also spawn and work within an interactive
  6. Python development shell. When debugging certain commands or even when
  7. just editing packages, ``pydevshell`` can be a useful tool. When you
  8. invoke the ``pydevshell`` task, all tasks up to and including
  9. :ref:`ref-tasks-patch` are run for the
  10. specified target. Then a new terminal is opened. Additionally, key
  11. Python objects and code are available in the same way they are to
  12. BitBake tasks, in particular, the data store 'd'. So, commands such as
  13. the following are useful when exploring the data store and running
  14. functions::
  15. pydevshell> d.getVar("STAGING_DIR")
  16. '/media/build1/poky/build/tmp/sysroots'
  17. pydevshell> d.getVar("STAGING_DIR", False)
  18. '${TMPDIR}/sysroots'
  19. pydevshell> d.setVar("FOO", "bar")
  20. pydevshell> d.getVar("FOO")
  21. 'bar'
  22. pydevshell> d.delVar("FOO")
  23. pydevshell> d.getVar("FOO")
  24. pydevshell> bb.build.exec_func("do_unpack", d)
  25. pydevshell>
  26. See the ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:functions you can call from within python`"
  27. section in the BitBake User Manual for details about available functions.
  28. The commands execute just as if the OpenEmbedded build
  29. system were executing them. Consequently, working this way can be
  30. helpful when debugging a build or preparing software to be used with the
  31. OpenEmbedded build system.
  32. Here is an example that uses ``pydevshell`` on a target named
  33. ``matchbox-desktop``::
  34. $ bitbake matchbox-desktop -c pydevshell
  35. This command spawns a terminal and places you in an interactive Python
  36. interpreter within the OpenEmbedded build environment. The
  37. :term:`OE_TERMINAL` variable
  38. controls what type of shell is opened.
  39. When you are finished using ``pydevshell``, you can exit the shell
  40. either by using Ctrl+d or closing the terminal window.