@@ -378,35 +378,34 @@ def byte_compile (py_files,
378378 else :
379379 script = open (script_name , "w" )
380380
381- script .write ("""\
381+ with script :
382+ script .write ("""\
382383 from distutils.util import byte_compile
383384files = [
384385""" )
385386
386- # XXX would be nice to write absolute filenames, just for
387- # safety's sake (script should be more robust in the face of
388- # chdir'ing before running it). But this requires abspath'ing
389- # 'prefix' as well, and that breaks the hack in build_lib's
390- # 'byte_compile()' method that carefully tacks on a trailing
391- # slash (os.sep really) to make sure the prefix here is "just
392- # right". This whole prefix business is rather delicate -- the
393- # problem is that it's really a directory, but I'm treating it
394- # as a dumb string, so trailing slashes and so forth matter.
395-
396- #py_files = map(os.path.abspath, py_files)
397- #if prefix:
398- # prefix = os.path.abspath(prefix)
399-
400- script .write (",\n " .join (map (repr , py_files )) + "]\n " )
401- script .write ("""
387+ # XXX would be nice to write absolute filenames, just for
388+ # safety's sake (script should be more robust in the face of
389+ # chdir'ing before running it). But this requires abspath'ing
390+ # 'prefix' as well, and that breaks the hack in build_lib's
391+ # 'byte_compile()' method that carefully tacks on a trailing
392+ # slash (os.sep really) to make sure the prefix here is "just
393+ # right". This whole prefix business is rather delicate -- the
394+ # problem is that it's really a directory, but I'm treating it
395+ # as a dumb string, so trailing slashes and so forth matter.
396+
397+ #py_files = map(os.path.abspath, py_files)
398+ #if prefix:
399+ # prefix = os.path.abspath(prefix)
400+
401+ script .write (",\n " .join (map (repr , py_files )) + "]\n " )
402+ script .write ("""
402403byte_compile(files, optimize=%r, force=%r,
403404 prefix=%r, base_dir=%r,
404405 verbose=%r, dry_run=0,
405406 direct=1)
406407""" % (optimize , force , prefix , base_dir , verbose ))
407408
408- script .close ()
409-
410409 cmd = [sys .executable ]
411410 cmd .extend (subprocess ._optim_args_from_interpreter_flags ())
412411 cmd .append (script_name )
0 commit comments