Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8a3ed3f8
Commit
8a3ed3f8
authored
Feb 25, 2003
by
Just van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some comments, minor tweaks
parent
5bfba3ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
3 deletions
+34
-3
Lib/plat-mac/bundlebuilder.py
Lib/plat-mac/bundlebuilder.py
+34
-3
No files found.
Lib/plat-mac/bundlebuilder.py
View file @
8a3ed3f8
...
@@ -230,6 +230,18 @@ if USE_ZIPIMPORT:
...
@@ -230,6 +230,18 @@ if USE_ZIPIMPORT:
path
=
fullname
.
replace
(
"."
,
os
.
sep
)
+
PYC_EXT
path
=
fullname
.
replace
(
"."
,
os
.
sep
)
+
PYC_EXT
return
path
,
MAGIC
+
'
\
0
\
0
\
0
\
0
'
+
marshal
.
dumps
(
code
)
return
path
,
MAGIC
+
'
\
0
\
0
\
0
\
0
'
+
marshal
.
dumps
(
code
)
#
# The following snippet gets added as sitecustomize.py[co] to
# non-standalone apps and appended to our custom site.py for
# standalone apps. The bootstrap scripts calls os.execve() with
# an argv[0] that's different from the actual executable: argv[0]
# is the bootstrap script itself and matches the CFBundleExecutable
# value in the Info.plist. This is needed to keep the Finder happy
# and have the app work from the command line as well. However,
# this causes sys.executable to also be that value, so we correct
# that from the PYTHONEXECUTABLE environment variable that the
# bootstrap script sets.
#
SITECUSTOMIZE_PY
=
"""
\
SITECUSTOMIZE_PY
=
"""
\
import sys, os
import sys, os
executable = os.getenv("PYTHONEXECUTABLE")
executable = os.getenv("PYTHONEXECUTABLE")
...
@@ -241,7 +253,10 @@ SITE_PY += SITECUSTOMIZE_PY
...
@@ -241,7 +253,10 @@ SITE_PY += SITECUSTOMIZE_PY
SITE_CO
=
compile
(
SITE_PY
,
"<-bundlebuilder.py->"
,
"exec"
)
SITE_CO
=
compile
(
SITE_PY
,
"<-bundlebuilder.py->"
,
"exec"
)
SITECUSTOMIZE_CO
=
compile
(
SITECUSTOMIZE_PY
,
"<-bundlebuilder.py->"
,
"exec"
)
SITECUSTOMIZE_CO
=
compile
(
SITECUSTOMIZE_PY
,
"<-bundlebuilder.py->"
,
"exec"
)
#
# Extension modules can't be in the modules zip archive, so a placeholder
# is added instead, that loads the extension from a specified location.
#
EXT_LOADER
=
"""
\
EXT_LOADER
=
"""
\
def __load():
def __load():
import imp, sys, os
import imp, sys, os
...
@@ -264,6 +279,17 @@ MAYMISS_MODULES = ['mac', 'os2', 'nt', 'ntpath', 'dos', 'dospath',
...
@@ -264,6 +279,17 @@ MAYMISS_MODULES = ['mac', 'os2', 'nt', 'ntpath', 'dos', 'dospath',
STRIP_EXEC
=
"/usr/bin/strip"
STRIP_EXEC
=
"/usr/bin/strip"
#
# We're using a stock interpreter to run the app, yet we need
# a way to pass the Python main program to the interpreter. The
# bootstrapping script fires up the interpreter with the right
# arguments. os.execve() is used as OSX doesn't like us to
# start a real new process. Also, the executable name must match
# the CFBundleExecutable value in the Info.plist, so we lie
# deliberately with argv[0]. The actual Python executable is
# passed in an environment variable so we can "repair"
# sys.executable later.
#
BOOTSTRAP_SCRIPT
=
"""
\
BOOTSTRAP_SCRIPT
=
"""
\
#!/usr/bin/env python
#!/usr/bin/env python
...
@@ -279,13 +305,18 @@ os.environ["PYTHONEXECUTABLE"] = executable
...
@@ -279,13 +305,18 @@ os.environ["PYTHONEXECUTABLE"] = executable
os.execve(executable, sys.argv, os.environ)
os.execve(executable, sys.argv, os.environ)
"""
"""
ARGVEMULATOR
=
"""
\
#
# Optional wrapper that converts "dropped files" into sys.argv values.
#
ARGV_EMULATOR
=
"""
\
import argvemulator, os
import argvemulator, os
argvemulator.ArgvCollector().mainloop()
argvemulator.ArgvCollector().mainloop()
execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s"))
execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s"))
"""
"""
class
AppBuilder
(
BundleBuilder
):
class
AppBuilder
(
BundleBuilder
):
# A Python main program. If this argument is given, the main
# A Python main program. If this argument is given, the main
...
@@ -401,7 +432,7 @@ class AppBuilder(BundleBuilder):
...
@@ -401,7 +432,7 @@ class AppBuilder(BundleBuilder):
resdirpath
=
pathjoin
(
self
.
bundlepath
,
resdir
)
resdirpath
=
pathjoin
(
self
.
bundlepath
,
resdir
)
mainprogrampath
=
pathjoin
(
resdirpath
,
mainprogram
)
mainprogrampath
=
pathjoin
(
resdirpath
,
mainprogram
)
makedirs
(
resdirpath
)
makedirs
(
resdirpath
)
open
(
mainprogrampath
,
"w"
).
write
(
ARGVEMULATOR
%
locals
())
open
(
mainprogrampath
,
"w"
).
write
(
ARGV
_
EMULATOR
%
locals
())
if
self
.
standalone
:
if
self
.
standalone
:
self
.
includeModules
.
append
(
"argvemulator"
)
self
.
includeModules
.
append
(
"argvemulator"
)
self
.
includeModules
.
append
(
"os"
)
self
.
includeModules
.
append
(
"os"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment