In a py2app/Mac Application Bundle, is there a way to spawn another instance of same app from within the app, by passing different command line arguments?
or given a mac app bundle, how can I run it from command line and pass some arguments too?
Edit1:forking is a limited option, which may not work with 3rd party executables bundle with app+I need to run this on mac and windows.
Edit2: Question is how to run a a bundled python script using subprocess module
Details:
I am using py2app to generate a app bundle for my appilcation. My application has two parts
- MainApp: which is the UI
- BackgroundApp: a background process, which does the real job
Both MainApp and BackgroundApp have been implemented as python script and actually they are the same python script with different commandline e.g.
python myapp.py
python myapp.py --backgroundprocess
So when I run python myapp.py
it automatically starts background process based on program path, but as I have now bundled my app as py2app I am not sure what executable I should be calling and passing --backgroundprocess
option?
What I have tried
$ open MyApp.app/
this opens the app but I can't pass the arguments to it, as they will be arguments for open command and will not be passed to my app$ MyApp.app/Contents/MacOS/MyApp --backgroundprocess
opens the app but not the backgroun process as it seems arguments are not being passed to app
also it throws error
Traceback (most recent call last):
File "/Users/agyey/projects/myapp/release4.26/py2exe/dist/MyApp.app/Contents/Resources/run.py", line 4, in <module>
from renderprocess import RenderEngineApp
File "renderprocess/RenderEngineApp.pyc", line 6, in <module>
File "wx/__init__.pyc", line 45, in <module>
File "wx/_core.pyc", line 4, in <module>
File "wx/_core_.pyc", line 18, in <module>
File "wx/_core_.pyc", line 11, in __load
ImportError: dlopen(/Users/agyey/projects/myapp/release4.26/py2exe/dist/MyApp.app/Contents/Resources/lib/python2.5/lib-dynload/wx/_core_.so, 2): Library not loaded: @executable_path/../Frameworks/libwx_macud-2.8.0.dylib
Referenced from: /Users/agyey/projects/myapp/release4.26/py2exe/dist/MyApp.app/Contents/Resources/lib/python2.5/lib-dynload/wx/_core_.so
Reason: Incompatible library version: _core_.so requires version 7.0.0 or later, but libwx_macud-2.8.0.dylib provides version 2.6.0
Conclusion: it looks like it may not be possible Launch an app on OS X with command line
open
doesn't except arguments.