mirror of
https://github.com/python/cpython.git
synced 2025-11-11 02:52:04 +00:00
Fix test_frozen.
This commit is contained in:
parent
79139b247b
commit
96bf7e8a37
8 changed files with 87 additions and 87 deletions
|
|
@ -12,14 +12,15 @@
|
||||||
the appropriate bytes from M___main__.c. */
|
the appropriate bytes from M___main__.c. */
|
||||||
|
|
||||||
static unsigned char M___hello__[] = {
|
static unsigned char M___hello__[] = {
|
||||||
99,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
|
99,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,
|
||||||
0,64,0,0,0,115,9,0,0,0,100,0,0,71,72,100,
|
0,64,0,0,0,115,14,0,0,0,101,0,0,100,0,0,
|
||||||
1,0,83,40,2,0,0,0,115,14,0,0,0,72,101,108,
|
131,1,0,1,100,1,0,83,40,2,0,0,0,115,14,0,
|
||||||
108,111,32,119,111,114,108,100,46,46,46,78,40,0,0,0,
|
0,0,72,101,108,108,111,32,119,111,114,108,100,46,46,46,
|
||||||
0,40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,
|
78,40,1,0,0,0,116,5,0,0,0,112,114,105,110,116,
|
||||||
115,8,0,0,0,104,101,108,108,111,46,112,121,115,8,0,
|
40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,115,
|
||||||
0,0,60,109,111,100,117,108,101,62,1,0,0,0,115,0,
|
8,0,0,0,104,101,108,108,111,46,112,121,115,8,0,0,
|
||||||
0,0,0,
|
0,60,109,111,100,117,108,101,62,1,0,0,0,115,0,0,
|
||||||
|
0,0,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SIZE (int)sizeof(M___hello__)
|
#define SIZE (int)sizeof(M___hello__)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ def __init__(self, file, mode, bufsize):
|
||||||
self.readline = self.__file.readline
|
self.readline = self.__file.readline
|
||||||
self.readlines = self.__file.readlines
|
self.readlines = self.__file.readlines
|
||||||
self.seek = self.__file.seek
|
self.seek = self.__file.seek
|
||||||
self.softspace = self.__file.softspace
|
|
||||||
self.tell = self.__file.tell
|
self.tell = self.__file.tell
|
||||||
self.truncate = self.__file.truncate
|
self.truncate = self.__file.truncate
|
||||||
self.write = self.__file.write
|
self.write = self.__file.write
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ def main():
|
||||||
# proces option arguments
|
# proces option arguments
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == '-h':
|
if o == '-h':
|
||||||
print __doc__
|
print(__doc__)
|
||||||
return
|
return
|
||||||
if o == '-d':
|
if o == '-d':
|
||||||
debug = debug + 1
|
debug = debug + 1
|
||||||
|
|
@ -222,7 +222,7 @@ def main():
|
||||||
if win:
|
if win:
|
||||||
extensions_c = 'frozen_extensions.c'
|
extensions_c = 'frozen_extensions.c'
|
||||||
if ishome:
|
if ishome:
|
||||||
print "(Using Python source directory)"
|
print("(Using Python source directory)")
|
||||||
binlib = exec_prefix
|
binlib = exec_prefix
|
||||||
incldir = os.path.join(prefix, 'Include')
|
incldir = os.path.join(prefix, 'Include')
|
||||||
config_h_dir = exec_prefix
|
config_h_dir = exec_prefix
|
||||||
|
|
@ -310,7 +310,7 @@ def main():
|
||||||
if odir and not os.path.isdir(odir):
|
if odir and not os.path.isdir(odir):
|
||||||
try:
|
try:
|
||||||
os.mkdir(odir)
|
os.mkdir(odir)
|
||||||
print "Created output directory", odir
|
print("Created output directory", odir)
|
||||||
except os.error as msg:
|
except os.error as msg:
|
||||||
usage('%s: mkdir failed (%s)' % (odir, str(msg)))
|
usage('%s: mkdir failed (%s)' % (odir, str(msg)))
|
||||||
base = ''
|
base = ''
|
||||||
|
|
@ -371,7 +371,7 @@ def main():
|
||||||
|
|
||||||
if debug > 0:
|
if debug > 0:
|
||||||
mf.report()
|
mf.report()
|
||||||
print
|
print()
|
||||||
dict = mf.modules
|
dict = mf.modules
|
||||||
|
|
||||||
if error_if_any_missing:
|
if error_if_any_missing:
|
||||||
|
|
@ -479,18 +479,18 @@ def main():
|
||||||
# Done!
|
# Done!
|
||||||
|
|
||||||
if odir:
|
if odir:
|
||||||
print 'Now run "make" in', odir,
|
print('Now run "make" in', odir, end=' ')
|
||||||
print 'to build the target:', base_target
|
print('to build the target:', base_target)
|
||||||
else:
|
else:
|
||||||
print 'Now run "make" to build the target:', base_target
|
print('Now run "make" to build the target:', base_target)
|
||||||
|
|
||||||
|
|
||||||
# Print usage message and exit
|
# Print usage message and exit
|
||||||
|
|
||||||
def usage(msg):
|
def usage(msg):
|
||||||
sys.stdout = sys.stderr
|
sys.stdout = sys.stderr
|
||||||
print "Error:", msg
|
print("Error:", msg)
|
||||||
print "Use ``%s -h'' for help" % sys.argv[0]
|
print("Use ``%s -h'' for help" % sys.argv[0])
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
print 'Hello world...'
|
print('Hello world...')
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ def makeconfig(infp, outfp, modules, with_ifdef=0):
|
||||||
def test():
|
def test():
|
||||||
import sys
|
import sys
|
||||||
if not sys.argv[3:]:
|
if not sys.argv[3:]:
|
||||||
print 'usage: python makeconfig.py config.c.in outputfile',
|
print('usage: python makeconfig.py config.c.in outputfile', end=' ')
|
||||||
print 'modulename ...'
|
print('modulename ...')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if sys.argv[1] == '-':
|
if sys.argv[1] == '-':
|
||||||
infp = sys.stdin
|
infp = sys.stdin
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
|
||||||
outfp = bkfile.open(base + file, 'w')
|
outfp = bkfile.open(base + file, 'w')
|
||||||
files.append(file)
|
files.append(file)
|
||||||
if debug:
|
if debug:
|
||||||
print "freezing", mod, "..."
|
print("freezing", mod, "...")
|
||||||
str = marshal.dumps(m.__code__)
|
str = marshal.dumps(m.__code__)
|
||||||
size = len(str)
|
size = len(str)
|
||||||
if m.__path__:
|
if m.__path__:
|
||||||
|
|
@ -53,7 +53,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
|
||||||
writecode(outfp, mangled, str)
|
writecode(outfp, mangled, str)
|
||||||
outfp.close()
|
outfp.close()
|
||||||
if debug:
|
if debug:
|
||||||
print "generating table of frozen modules"
|
print("generating table of frozen modules")
|
||||||
outfp = bkfile.open(base + 'frozen.c', 'w')
|
outfp = bkfile.open(base + 'frozen.c', 'w')
|
||||||
for mod, mangled, size in done:
|
for mod, mangled, size in done:
|
||||||
outfp.write('extern unsigned char M_%s[];\n' % mangled)
|
outfp.write('extern unsigned char M_%s[];\n' % mangled)
|
||||||
|
|
|
||||||
|
|
@ -84,29 +84,29 @@ def test():
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
if not sys.argv[1:]:
|
if not sys.argv[1:]:
|
||||||
print 'usage: python parsesetup.py Makefile*|Setup* ...'
|
print('usage: python parsesetup.py Makefile*|Setup* ...')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
base = os.path.basename(arg)
|
base = os.path.basename(arg)
|
||||||
if base[:8] == 'Makefile':
|
if base[:8] == 'Makefile':
|
||||||
print 'Make style parsing:', arg
|
print('Make style parsing:', arg)
|
||||||
v = getmakevars(arg)
|
v = getmakevars(arg)
|
||||||
prdict(v)
|
prdict(v)
|
||||||
elif base[:5] == 'Setup':
|
elif base[:5] == 'Setup':
|
||||||
print 'Setup style parsing:', arg
|
print('Setup style parsing:', arg)
|
||||||
m, v = getsetupinfo(arg)
|
m, v = getsetupinfo(arg)
|
||||||
prdict(m)
|
prdict(m)
|
||||||
prdict(v)
|
prdict(v)
|
||||||
else:
|
else:
|
||||||
print arg, 'is neither a Makefile nor a Setup file'
|
print(arg, 'is neither a Makefile nor a Setup file')
|
||||||
print '(name must begin with "Makefile" or "Setup")'
|
print('(name must begin with "Makefile" or "Setup")')
|
||||||
|
|
||||||
def prdict(d):
|
def prdict(d):
|
||||||
keys = d.keys()
|
keys = d.keys()
|
||||||
keys.sort()
|
keys.sort()
|
||||||
for key in keys:
|
for key in keys:
|
||||||
value = d[key]
|
value = d[key]
|
||||||
print "%-15s" % key, str(value)
|
print("%-15s" % key, str(value))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
test()
|
||||||
|
|
|
||||||
|
|
@ -52,29 +52,29 @@ def makemakefile(outfp, vars, files, target):
|
||||||
|
|
||||||
def realwork(vars, moddefns, target):
|
def realwork(vars, moddefns, target):
|
||||||
version_suffix = "%r%r" % sys.version_info[:2]
|
version_suffix = "%r%r" % sys.version_info[:2]
|
||||||
print "# Makefile for Microsoft Visual C++ generated by freeze.py script"
|
print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
|
||||||
print
|
print()
|
||||||
print 'target = %s' % target
|
print('target = %s' % target)
|
||||||
print 'pythonhome = %s' % vars['prefix']
|
print('pythonhome = %s' % vars['prefix'])
|
||||||
print
|
print()
|
||||||
print 'DEBUG=0 # Set to 1 to use the _d versions of Python.'
|
print('DEBUG=0 # Set to 1 to use the _d versions of Python.')
|
||||||
print '!IF $(DEBUG)'
|
print('!IF $(DEBUG)')
|
||||||
print 'debug_suffix=_d'
|
print('debug_suffix=_d')
|
||||||
print 'c_debug=/Zi /Od /DDEBUG /D_DEBUG'
|
print('c_debug=/Zi /Od /DDEBUG /D_DEBUG')
|
||||||
print 'l_debug=/DEBUG'
|
print('l_debug=/DEBUG')
|
||||||
print 'temp_dir=Build\\Debug'
|
print('temp_dir=Build\\Debug')
|
||||||
print '!ELSE'
|
print('!ELSE')
|
||||||
print 'debug_suffix='
|
print('debug_suffix=')
|
||||||
print 'c_debug=/Ox'
|
print('c_debug=/Ox')
|
||||||
print 'l_debug='
|
print('l_debug=')
|
||||||
print 'temp_dir=Build\\Release'
|
print('temp_dir=Build\\Release')
|
||||||
print '!ENDIF'
|
print('!ENDIF')
|
||||||
print
|
print()
|
||||||
|
|
||||||
print '# The following line assumes you have built Python using the standard instructions'
|
print('# The following line assumes you have built Python using the standard instructions')
|
||||||
print '# Otherwise fix the following line to point to the library.'
|
print('# Otherwise fix the following line to point to the library.')
|
||||||
print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix
|
print('pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix)
|
||||||
print
|
print()
|
||||||
|
|
||||||
# We only ever write one "entry point" symbol - either
|
# We only ever write one "entry point" symbol - either
|
||||||
# "main" or "WinMain". Therefore, there is no need to
|
# "main" or "WinMain". Therefore, there is no need to
|
||||||
|
|
@ -88,59 +88,59 @@ def realwork(vars, moddefns, target):
|
||||||
target_ext = ".dll"
|
target_ext = ".dll"
|
||||||
|
|
||||||
|
|
||||||
print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix
|
print("# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix)
|
||||||
print "cdl = /MD"
|
print("cdl = /MD")
|
||||||
print
|
print()
|
||||||
print "all: $(target)$(debug_suffix)%s" % (target_ext)
|
print("all: $(target)$(debug_suffix)%s" % (target_ext))
|
||||||
print
|
print()
|
||||||
|
|
||||||
print '$(temp_dir):'
|
print('$(temp_dir):')
|
||||||
print ' if not exist $(temp_dir)\. mkdir $(temp_dir)'
|
print(' if not exist $(temp_dir)\. mkdir $(temp_dir)')
|
||||||
print
|
print()
|
||||||
|
|
||||||
objects = []
|
objects = []
|
||||||
libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"]
|
libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"]
|
||||||
for moddefn in moddefns:
|
for moddefn in moddefns:
|
||||||
print "# Module", moddefn.name
|
print("# Module", moddefn.name)
|
||||||
for file in moddefn.sourceFiles:
|
for file in moddefn.sourceFiles:
|
||||||
base = os.path.basename(file)
|
base = os.path.basename(file)
|
||||||
base, ext = os.path.splitext(base)
|
base, ext = os.path.splitext(base)
|
||||||
objects.append(base + ".obj")
|
objects.append(base + ".obj")
|
||||||
print '$(temp_dir)\%s.obj: "%s"' % (base, file)
|
print('$(temp_dir)\%s.obj: "%s"' % (base, file))
|
||||||
print "\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE",
|
print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ')
|
||||||
print '"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\'
|
print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\')
|
||||||
print "\t\t$(cflags) $(cdebug) $(cinclude) \\"
|
print("\t\t$(cflags) $(cdebug) $(cinclude) \\")
|
||||||
extra = moddefn.GetCompilerOptions()
|
extra = moddefn.GetCompilerOptions()
|
||||||
if extra:
|
if extra:
|
||||||
print "\t\t%s \\" % (' '.join(extra),)
|
print("\t\t%s \\" % (' '.join(extra),))
|
||||||
print '\t\t"%s"' % file
|
print('\t\t"%s"' % file)
|
||||||
print
|
print()
|
||||||
|
|
||||||
# Add .lib files this module needs
|
# Add .lib files this module needs
|
||||||
for modlib in moddefn.GetLinkerLibs():
|
for modlib in moddefn.GetLinkerLibs():
|
||||||
if modlib not in libs:
|
if modlib not in libs:
|
||||||
libs.append(modlib)
|
libs.append(modlib)
|
||||||
|
|
||||||
print "ADDN_LINK_FILES=",
|
print("ADDN_LINK_FILES=", end=' ')
|
||||||
for addn in vars['addn_link']: print '"%s"' % (addn),
|
for addn in vars['addn_link']: print('"%s"' % (addn), end=' ')
|
||||||
print ; print
|
print() ; print()
|
||||||
|
|
||||||
print "OBJS=",
|
print("OBJS=", end=' ')
|
||||||
for obj in objects: print '"$(temp_dir)\%s"' % (obj),
|
for obj in objects: print('"$(temp_dir)\%s"' % (obj), end=' ')
|
||||||
print ; print
|
print() ; print()
|
||||||
|
|
||||||
print "LIBS=",
|
print("LIBS=", end=' ')
|
||||||
for lib in libs: print '"%s"' % (lib),
|
for lib in libs: print('"%s"' % (lib), end=' ')
|
||||||
print ; print
|
print() ; print()
|
||||||
|
|
||||||
print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext)
|
print("$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext))
|
||||||
print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags),
|
print("\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), end=' ')
|
||||||
print "\t$(OBJS) \\"
|
print("\t$(OBJS) \\")
|
||||||
print "\t$(LIBS) \\"
|
print("\t$(LIBS) \\")
|
||||||
print "\t$(ADDN_LINK_FILES) \\"
|
print("\t$(ADDN_LINK_FILES) \\")
|
||||||
print "\t$(pythonlib) $(lcustom) $(l_debug)\\"
|
print("\t$(pythonlib) $(lcustom) $(l_debug)\\")
|
||||||
print "\t$(resources)"
|
print("\t$(resources)")
|
||||||
print
|
print()
|
||||||
print "clean:"
|
print("clean:")
|
||||||
print "\t-rm -f *.obj"
|
print("\t-rm -f *.obj")
|
||||||
print "\t-rm -f $(target).exe"
|
print("\t-rm -f $(target).exe")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue