[Python-checkins] python/dist/src/Lib/plat-mac bundlebuilder.py,1.11,1.12
jvr@users.sourceforge.net
jvr@users.sourceforge.net
Tue, 25 Feb 2003 12:15:44 -0800
Update of /cvsroot/python/python/dist/src/Lib/plat-mac
In directory sc8-pr-cvs1:/tmp/cvs-serv3248
Modified Files:
bundlebuilder.py
Log Message:
Resolving parts of #688907:
- Replaced bootstrap shell script with Python script. This means
standalone apps built with bundlebuilder will not work on MacOS < 10.1,
since we depend (again) on an installed Python.
- Add a hack to set sys.executable; the bootstrap script does os.execve()
with an argv[0] that's different from the actual Python executable
(it has to match the CFBundleExecutable entry in the Info.plist to make
the app work both from the Finder and the command line, and it has to be
the bootstrap script), yet a proper sys.executable is needed to spawn
auxiliary processes.
Index: bundlebuilder.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/bundlebuilder.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** bundlebuilder.py 24 Feb 2003 16:27:08 -0000 1.11
--- bundlebuilder.py 25 Feb 2003 20:15:40 -0000 1.12
***************
*** 231,235 ****
--- 231,245 ----
return path, MAGIC + '\0\0\0\0' + marshal.dumps(code)
+ SITECUSTOMIZE_PY = """\
+ import sys, os
+ executable = os.getenv("PYTHONEXECUTABLE")
+ if executable is not None:
+ sys.executable = executable
+ """
+
+ SITE_PY += SITECUSTOMIZE_PY
SITE_CO = compile(SITE_PY, "<-bundlebuilder.py->", "exec")
+ SITECUSTOMIZE_CO = compile(SITECUSTOMIZE_PY, "<-bundlebuilder.py->", "exec")
+
EXT_LOADER = """\
***************
*** 256,268 ****
BOOTSTRAP_SCRIPT = """\
! #!/bin/sh
! execdir=$(dirname "${0}")
! executable="${execdir}/%(executable)s"
! resdir=$(dirname "${execdir}")/Resources
! main="${resdir}/%(mainprogram)s"
! PYTHONPATH="$resdir"
! export PYTHONPATH
! exec "${executable}" "${main}" "$@"
"""
--- 266,281 ----
BOOTSTRAP_SCRIPT = """\
! #!/usr/bin/env python
! import sys, os
! execdir = os.path.dirname(sys.argv[0])
! executable = os.path.join(execdir, "%(executable)s")
! resdir = os.path.join(os.path.dirname(execdir), "Resources")
! mainprogram = os.path.join(resdir, "%(mainprogram)s")
!
! sys.argv.insert(1, mainprogram)
! os.environ["PYTHONPATH"] = resdir
! os.environ["PYTHONEXECUTABLE"] = executable
! os.execve(executable, sys.argv, os.environ)
"""
***************
*** 416,419 ****
--- 429,436 ----
if self.standalone:
self.addPythonModules()
+ else:
+ sitecustomizepath = pathjoin(self.bundlepath, "Contents", "Resources",
+ "sitecustomize" + PYC_EXT)
+ writePyc(SITECUSTOMIZE_CO, sitecustomizepath)
if self.strip and not self.symlink:
self.stripBinaries()
***************
*** 487,490 ****
--- 504,510 ----
site.__code__ = SITE_CO
mf.scan_code(SITE_CO, site)
+
+ # warnings.py gets imported implicitly from C
+ mf.import_hook("warnings")
includeModules = self.includeModules[:]