Bug 9166 - Need to document the do_devpyshell task that is in the devshell.bbclass
Summary: Need to document the do_devpyshell task that is in the devshell.bbclass
Status: RESOLVED FIXED
Alias: None
Product: Reference
Classification: Documentation
Component: handbook (show other bugs)
Version: 2.1
Hardware: All Multiple
: Medium enhancement
Target Milestone: 2.3 M2
Assignee: Scott Rifenbark
QA Contact:
URL:
Whiteboard: 08 Nov 2016: RESOLVED
Depends on:
Blocks:
 
Reported: 2016-02-24 23:08 UTC by Scott Rifenbark
Modified: 2016-11-08 18:05 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Done (doc changes complete)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Rifenbark 2016-02-24 23:08:51 UTC
We need to document this task in the "Tasks" section of the YP Reference Manual.  Richard Purdie is probably the person I need to get information from about the task.
Comment 1 Scott Rifenbark 2016-02-24 23:10:46 UTC
Setting this to "future" and adding Richard Purdie and Paul Eggleton to the CC list.
Comment 2 Saul Wold 2016-02-25 15:45:41 UTC
Richard to supply needed info
Comment 3 Scott Rifenbark 2016-06-03 19:24:17 UTC
So I have been looking through devshell.bbclass (http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/devshell.bbclass) and in particular the devpyshell function.  This is my take on the function:

1. Sets it up so that there is no buffering or echo going on in the psuedo tty.
2. Forks a new process and if something goes wrong it bails at that point.
3. If the new process is forked okay, then all the stdin, stdout, etc stuff
   is set up.
4. Looks like some prompt strings are established
5. I am guessing that lines 105 through 141 is where the devshell is waiting 
   for input?  And, if there is a keyboard interrupt or there was a 
   SystemExit signal passed, they are handled.  

Since the purpose of devshell.bbclass is to add the do_devshell task (according to our docs), is it safe to say that the do_devpyshell task is what sets up the development shell and then does the job of catching input and all that?

I don't know... I don't read this code like you engineers.  So some extra clarification here would help me out. 

Thanks, 
Scott
Comment 4 Richard Purdie 2016-09-22 10:52:35 UTC
Scott: I think it doesn't matter so much what the code does but more what the user can do with this. A "do_devpyshell" task is created that is similar to do_devshell but instead of bash, it drops you to an interactive python interpreter, in the same way that just running "python" at a shell prompt does.

In the devpyshell, key python objects and code are available in the same way they are to bitbake tasks, in particular, the data store 'd'. You can therefore do things like:

"bitbake bash -c devpyshell" and then in the shell window that opens:

pydevshell> d.getVar("STAGING_DIR", True)
'/media/build1/poky/build/tmp/sysroots'
pydevshell> d.getVar("STAGING_DIR", False)
'${TMPDIR}/sysroots'
pydevshell> d.setVar("FOO", "bar")
pydevshell> d.getVar("FOO", True)
'bar'
pydevshell> d.delVar("FOO")
pydevshell> d.getVar("FOO", True)
pydevshell> bb.build.exec_func("do_unpack", d)
pydevshell>

This would allow the user to inspect and work with the data store or execute functions.

So firstly, we document the existence of the task, secondly we give the user some examples of why this is useful and how it can be used.

Does that give you enough to put something basic in the manual about this?
Comment 5 Scott Rifenbark 2016-09-22 23:00:35 UTC
Hi Richard, 

I can start with this.  It looks like we need a couple new sections in the YP doc set: one for a reference of the do_devpyshell task, and one in the dev-manual that talks about this interactive Python interpreter and what the user can do there. 

So, I have a new section here - http://www.yoctoproject.org/docs/2.2/dev-manual/dev-manual.html#platdev-appdev-devpyshell called "Using a Development Python Shell".  I started with the section just prior to it for using a development shell.  I have no idea how much of that stuff is the same for the Python version.  I am hoping you can review it and guide me.  

The other reference is here - http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#ref-tasks-devpyshell.  It is brief and basically sends the reader off to the new section in the dev-manual. 

Thanks, 
Scott
Comment 6 Richard Purdie 2016-09-23 16:31:03 UTC
"and you are placed in ${S}, the source directory" - that bit doesn't apply, nor does "In the new terminal, all the OpenEmbedded build-related environment variables are still defined so you can use commands such as configure and make". "For spawned terminals, the following occurs: " and the points underneath it are also not relevant, in fact you can just remove the rest of the section and notes and end it with "When you are finished using devpyshell, exit the shell using Ctrl+d or close the terminal window. ".

Otherwise looks good and at least means its documented in the manual. We can add more info if/as/when people have the time.
Comment 7 Scott Rifenbark 2016-09-26 15:44:35 UTC
Thanks for the feedback Richard.  See http://www.yoctoproject.org/docs/2.2/dev-manual/dev-manual.html#platdev-appdev-devpyshell for the new section with the changes.  Let me know if there is anything further. 

Scott
Comment 8 Scott Rifenbark 2016-10-25 20:15:47 UTC
Moving to 2.3 M2
Comment 9 Scott Rifenbark 2016-11-08 18:05:17 UTC
We did get a review and no further issues... so setting to RESOLVED and putting the doc flag to "done."

Scott