[Pythonmac-SIG] Allow multiple executables in a single py2app bundle
David Brooks
dave at bcs.co.nz
Mon Feb 21 00:56:23 CET 2011
Resending, as didn't make it to the list when sent on 18 February...
Hi,
The following patch enables the name of the stub executable to determine
the Python script to run. This allows multiple scripts to use a common
runtime.
Required manual steps are to make copies of the stub in ./MacOS and to
copy the actual Python scripts into ./Resources.
N.B. The py2app/apptemplate/prebuilt contents need to be recreated by
running 'python setup.py build' in py2app/apptemplate, before running
the main 'setup.py install'.
Enjoy!
Dave
=================================================
diff --git a/py2app/apptemplate/src/main.c b/py2app/apptemplate/src/main.c
--- a/py2app/apptemplate/src/main.c
+++ b/py2app/apptemplate/src/main.c
@@ -1017,8 +1017,9 @@
argv_new = alloca((argc + 1) * sizeof(char *));
argv_new[argc] = NULL;
- argv_new[0] = c_mainScript;
- memcpy(&argv_new[1],&argv[1], (argc - 1) * sizeof(char *));
+ //argv_new[0] = c_mainScript;
+ //memcpy(&argv_new[1],&argv[1], (argc - 1) * sizeof(char *));
+ memcpy(argv_new, argv, argc * sizeof(char *));
py2app_PySys_SetArgv(argc, argv_new);
diff --git a/py2app/bootstrap/boot_app.py b/py2app/bootstrap/boot_app.py
--- a/py2app/bootstrap/boot_app.py
+++ b/py2app/bootstrap/boot_app.py
@@ -7,7 +7,7 @@
site.addsitedir(os.path.join(base, 'Python', 'site-packages'))
if not scripts:
import __main__
- for script in scripts:
- path = os.path.join(base, script)
- sys.argv[0] = __file__ = path
- execfile(path, globals(), globals())
+ script = sys.argv[0].split('/')[-1] + '.py'
+ path = os.path.join(base, script)
+ sys.argv[0] = __file__ = path
+ execfile(path, globals(), globals())
=================================================
More information about the Pythonmac-SIG
mailing list