summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/util.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-10-03 03:31:05 (GMT)
committerGreg Ward <gward@python.net>2000-10-03 03:31:05 (GMT)
commit9216cfe7ba0257f10790f919e50283114a3476dd (patch)
tree1b6735fb2bfae0dd6dd8fd8dd37927e895066f08 /Lib/distutils/util.py
parentd52755f41c1545a1e6dcc0f38ebed0a1fd1fa5e8 (diff)
downloadcpython-9216cfe7ba0257f10790f919e50283114a3476dd.zip
cpython-9216cfe7ba0257f10790f919e50283114a3476dd.tar.gz
cpython-9216cfe7ba0257f10790f919e50283114a3476dd.tar.bz2
Added a long-winded comment (and commented-out comment to go with out)
about how it would be nice to write absolute paths to the temporary byte-compilation script, but this doesn't work because it screws up the trailing-slash trickery done to 'prefix' in build_py's 'byte_compile()' method. Fixed to use 'execute()' instead of 'os.remove()' to remove the temporary script: now it doesn't blow up in dry-run mode!
Diffstat (limited to 'Lib/distutils/util.py')
-rw-r--r--Lib/distutils/util.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 8a8b77a..7522ee2 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -353,6 +353,21 @@ def byte_compile (py_files,
from distutils.util import byte_compile
files = [
""")
+
+ # XXX would be nice to write absolute filenames, just for
+ # safety's sake (script should be more robust in the face of
+ # chdir'ing before running it). But this requires abspath'ing
+ # 'prefix' as well, and that breaks the hack in build_lib's
+ # 'byte_compile()' method that carefully tacks on a trailing
+ # slash (os.sep really) to make sure the prefix here is "just
+ # right". This whole prefix business is rather delicate -- the
+ # problem is that it's really a directory, but I'm treating it
+ # as a dumb string, so trailing slashes and so forth matter.
+
+ #py_files = map(os.path.abspath, py_files)
+ #if prefix:
+ # prefix = os.path.abspath(prefix)
+
script.write(string.join(map(repr, py_files), ",\n") + "]\n")
script.write("""
byte_compile(files, optimize=%s, force=%s,
@@ -369,7 +384,8 @@ byte_compile(files, optimize=%s, force=%s,
elif optimize == 2:
cmd.insert(1, "-OO")
spawn(cmd, verbose=verbose, dry_run=dry_run)
- os.remove(script_name)
+ execute(os.remove, (script_name,), "removing %s" % script_name,
+ verbose=verbose, dry_run=dry_run)
# "Direct" byte-compilation: use the py_compile module to compile
# right here, right now. Note that the script generated in indirect