So without much more effort today, I'm got it running a separate script (bbxmain.py) that is bundled into the .bar file. Again, the heart of things is trivial, just these two lines:
FILE * bbxmain = fopen("app/native/bbxmain.py", "r"); PyRun_SimpleFile(bbxmain, "__main__");
For the record, here's the first script I wrote:
import sys, time with open('/accounts/1000/shared/misc/bbxmain.out', 'a') as f: f.write('-' * 40) f.write(' %s\n' % time.time()) for i, arg in enumerate(sys.argv): f.write('arg %s: %s\n' % (i, arg)) f.write("It's alive!\n") f.write('__name__ is %s\n' % __name__) f.write('myver is %s\n' % sys.myver) if __name__ == '__main__': print('Hello, world!')
And here's the output in that file in shared/misc:
---------------------------------------- 1321663133.906571 arg 0: com.example.study_poc.testDev_e_study_pocc037301d It's alive! __name__ is __main__ myver is BBX Python! v3.2.1 (default, Sep 1 2011, 14:08:17) [GCC 4.4.2] on qnx6
If you know Python and don't recognize sys.myver, don't worry... it's just a string built using an earlier call to PyRun_SimpleString() in my setup code from an older experiment, from sys.version and sys.platform. I've got the same thing displayed as output in the OpenGL screen context:
Join me on #bbx-python on freenode.net if you're interested in following this, add add a comment to this post, or follow @peter9477 on Twitter. Thanks!