python - Can executables made with py2app include other terminal scripts and run them? -
so have nice python app os x working great. runs external terminal script , include in python app. ideally, i'd able run py2app , have script bundled executable , able include , run in python portion of code. possible?
thanks in advance!
extra edit: script using compiled. can't inside , paste it.
see http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html#option-reference , @ --resources parameter. example:
python setup.py py2app --resources foo
if shell script, valid thing do. binary executable, it's bit more hacky. first, p2app's documentation says "not code!". second, os x documentation says not put executables in resources directory. main reason code signing: default settings "seal" in resources part of main app's signature, separate executables not supposed sealed way, they're supposed signed separately.
however, being said, still work. except won't end +x permissions, after py2app step, you'll have "chmod +x myapp.app/contents/resources/foo" make runnable.
you can use distutils package_data, data_files, and/or manifest stuff add arbitrary files arbitrary relative paths, might better solution, it's more complicated.
either way, in script, should use bundle-related path, can access via pyobjc. given you're using powerpc executable, may need backward compatibility can't rely on that, in case may have make "../resources/foo", otherwise, looks this:
import foundation # ... bundle = foundation.nsbundle.mainbundle() path = bundle.pathforresource_oftype_('foo', none)
you can launch nstask, or subprocess,popen, os.system, etc.
Comments
Post a Comment