Commit e35c6015 authored by Guido van Rossum's avatar Guido van Rossum

Add a feature to support specifying an additional search directory for

packages.  (Mark Hammond)

Folded some long lines.
parent ce5988b3
...@@ -28,6 +28,11 @@ Options: ...@@ -28,6 +28,11 @@ Options:
-m: Additional arguments are module names instead of filenames. -m: Additional arguments are module names instead of filenames.
-a package=dir: Additional directories to be added to the package's
__path__. Used to simulate directories added by the
package at runtime (eg, by OpenGL and win32com).
More than one -a option may be given for each package.
-l file: Pass the file to the linker (windows only) -l file: Pass the file to the linker (windows only)
-d: Debugging mode for the module finder. -d: Debugging mode for the module finder.
...@@ -92,7 +97,7 @@ def main(): ...@@ -92,7 +97,7 @@ def main():
exec_prefix = None # settable with -P option exec_prefix = None # settable with -P option
extensions = [] extensions = []
exclude = [] # settable with -x option exclude = [] # settable with -x option
addn_link = [] # settable with -l, but only honored under Windows. addn_link = [] # settable with -l, but only honored under Windows.
path = sys.path[:] path = sys.path[:]
modargs = 0 modargs = 0
debug = 1 debug = 1
...@@ -100,7 +105,8 @@ def main(): ...@@ -100,7 +105,8 @@ def main():
win = sys.platform[:3] == 'win' win = sys.platform[:3] == 'win'
# default the exclude list for each platform # default the exclude list for each platform
# if win: exclude = exclude + ['dos', 'dospath', 'mac', 'macpath', 'MACFS', 'posix', 'os2'] ## if win: exclude = exclude + [
## 'dos', 'dospath', 'mac', 'macpath', 'MACFS', 'posix', 'os2']
# modules that are imported by the Python runtime # modules that are imported by the Python runtime
implicits = ["site", "exceptions"] implicits = ["site", "exceptions"]
...@@ -111,10 +117,11 @@ def main(): ...@@ -111,10 +117,11 @@ def main():
target = 'a.out' # normally derived from script name target = 'a.out' # normally derived from script name
makefile = 'Makefile' makefile = 'Makefile'
subsystem = 'console' subsystem = 'console'
if win: extensions_c = 'frozen_extensions.c'
# parse command line # parse command line
try: try:
opts, args = getopt.getopt(sys.argv[1:], 'de:hmo:p:P:qs:wx:l:') opts, args = getopt.getopt(sys.argv[1:], 'a:de:hmo:p:P:qs:wx:l:')
except getopt.error, msg: except getopt.error, msg:
usage('getopt error: ' + str(msg)) usage('getopt error: ' + str(msg))
...@@ -147,6 +154,8 @@ def main(): ...@@ -147,6 +154,8 @@ def main():
exclude.append(a) exclude.append(a)
if o == '-l': if o == '-l':
addn_link.append(a) addn_link.append(a)
if o == '-a':
apply(modulefinder.AddPackagePath, tuple(string.split(a,"=", 2)))
# default prefix and exec_prefix # default prefix and exec_prefix
if not exec_prefix: if not exec_prefix:
...@@ -169,7 +178,8 @@ def main(): ...@@ -169,7 +178,8 @@ def main():
config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') config_c_in = os.path.join(prefix, 'Modules', 'config.c.in')
frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c')
makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile')
if win: frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c') if win:
frozendllmain_c = os.path.join(exec_prefix, 'Pc\\frozen_dllmain.c')
else: else:
binlib = os.path.join(exec_prefix, binlib = os.path.join(exec_prefix,
'lib', 'python%s' % version, 'config') 'lib', 'python%s' % version, 'config')
...@@ -250,6 +260,7 @@ def main(): ...@@ -250,6 +260,7 @@ def main():
config_c = os.path.join(odir, config_c) config_c = os.path.join(odir, config_c)
target = os.path.join(odir, target) target = os.path.join(odir, target)
makefile = os.path.join(odir, makefile) makefile = os.path.join(odir, makefile)
if win: extensions_c = os.path.join(odir, extensions_c)
# Handle special entry point requirements # Handle special entry point requirements
# (on Windows, some frozen programs do not use __main__, but # (on Windows, some frozen programs do not use __main__, but
...@@ -260,7 +271,8 @@ def main(): ...@@ -260,7 +271,8 @@ def main():
if win: if win:
import winmakemakefile import winmakemakefile
try: try:
custom_entry_point, python_entry_is_main = winmakemakefile. get_custom_entry_point(subsystem) custom_entry_point, python_entry_is_main = \
winmakemakefile.get_custom_entry_point(subsystem)
except ValueError, why: except ValueError, why:
usage(why) usage(why)
...@@ -337,7 +349,7 @@ def main(): ...@@ -337,7 +349,7 @@ def main():
# search for unknown modules in extensions directories (not on Windows) # search for unknown modules in extensions directories (not on Windows)
addfiles = [] addfiles = []
addmoddefns = [] # Windows list of modules. frozen_extensions = [] # Windows list of modules.
if unknown or (not win and builtins): if unknown or (not win and builtins):
if not win: if not win:
addfiles, addmods = \ addfiles, addmods = \
...@@ -352,16 +364,10 @@ def main(): ...@@ -352,16 +364,10 @@ def main():
import checkextensions_win32 import checkextensions_win32
# Get a list of CExtension instances, each describing a module # Get a list of CExtension instances, each describing a module
# (including its source files) # (including its source files)
addmoddefns = checkextensions_win32.checkextensions(unknown, extensions) frozen_extensions = checkextensions_win32.checkextensions(
maindefn = checkextensions_win32.CExtension( '__main__', unknown, extensions)
[frozenmain_c, os.path.basename(frozen_c),frozendllmain_c]) for mod in frozen_extensions:
for mod in addmoddefns:
unknown.remove(mod.name) unknown.remove(mod.name)
builtins.append(mod.name)
addmoddefns.append( maindefn )
# report unknown modules # report unknown modules
if unknown: if unknown:
...@@ -371,12 +377,19 @@ def main(): ...@@ -371,12 +377,19 @@ def main():
# windows gets different treatment # windows gets different treatment
if win: if win:
# Taking a shortcut here... # Taking a shortcut here...
import winmakemakefile import winmakemakefile, checkextensions_win32
checkextensions_win32.write_extension_table(extensions_c,
frozen_extensions)
# Create a module definition for the bootstrap C code.
xtras = [frozenmain_c, os.path.basename(frozen_c),
frozendllmain_c, extensions_c]
maindefn = checkextensions_win32.CExtension( '__main__', xtras )
frozen_extensions.append( maindefn )
outfp = open(makefile, 'w') outfp = open(makefile, 'w')
try: try:
winmakemakefile.makemakefile(outfp, winmakemakefile.makemakefile(outfp,
locals(), locals(),
addmoddefns, frozen_extensions,
os.path.basename(target)) os.path.basename(target))
finally: finally:
outfp.close() outfp.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment