summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/command/build_py.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-11-14 17:10:19 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-11-14 17:10:19 (GMT)
commitf8361623f0e5ab6c6337afcccdb442f285590869 (patch)
tree91b0d49055dc1046f4b570cc034473feab770205 /Lib/packaging/command/build_py.py
parentd5d4406c8ebbbdf8a8961fc119be22b15a1c40ad (diff)
downloadcpython-f8361623f0e5ab6c6337afcccdb442f285590869.zip
cpython-f8361623f0e5ab6c6337afcccdb442f285590869.tar.gz
cpython-f8361623f0e5ab6c6337afcccdb442f285590869.tar.bz2
Clean up byte-compilation code in packaging (#11254 followup).
- Don't use keyword arguments for debug_override; I find it more readable to have a comment explaining that True makes pyc and False pyo than to write out the non-obvious (when you haven’t read the doc) argument name - Move duplicate code from build_py and install_lib into cmd - Remove obsolete verbose argument of util.byte_compile - Remove obsolete passing of -O/-OO to the Python process spawned by util.byte_compile (I’ll remove the whole spawning later, after I write more tests to check the contents of pyc and pyo files; now that byte_compile does not depend on the value of __debug__ in the calling Python, we can call py_compile or compileall directly)
Diffstat (limited to 'Lib/packaging/command/build_py.py')
-rw-r--r--Lib/packaging/command/build_py.py29
1 files changed, 6 insertions, 23 deletions
diff --git a/Lib/packaging/command/build_py.py b/Lib/packaging/command/build_py.py
index 5faae39..0062140 100644
--- a/Lib/packaging/command/build_py.py
+++ b/Lib/packaging/command/build_py.py
@@ -18,7 +18,7 @@ class build_py(Command, Mixin2to3):
description = "build pure Python modules (copy to build directory)"
- # The options for controlling byte compilations are two independent sets;
+ # The options for controlling byte compilation are two independent sets;
# more info in install_lib or the reST docs
user_options = [
@@ -113,7 +113,8 @@ class build_py(Command, Mixin2to3):
self.run_2to3(self._updated_files, self._doctests_2to3,
self.use_2to3_fixers)
- self.byte_compile(self.get_outputs(include_bytecode=False))
+ self.byte_compile(self.get_outputs(include_bytecode=False),
+ prefix=self.build_lib)
# -- Top-level worker functions ------------------------------------
@@ -335,11 +336,9 @@ class build_py(Command, Mixin2to3):
outputs.append(filename)
if include_bytecode:
if self.compile:
- outputs.append(imp.cache_from_source(filename,
- debug_override=True))
- if self.optimize > 0:
- outputs.append(imp.cache_from_source(filename,
- debug_override=False))
+ outputs.append(imp.cache_from_source(filename, True))
+ if self.optimize:
+ outputs.append(imp.cache_from_source(filename, False))
outputs += [
os.path.join(build_dir, filename)
@@ -391,19 +390,3 @@ class build_py(Command, Mixin2to3):
for package_, module, module_file in modules:
assert package == package_
self.build_module(module, module_file, package)
-
- def byte_compile(self, files):
- from packaging.util import byte_compile # FIXME use compileall
- prefix = self.build_lib
- if prefix[-1] != os.sep:
- prefix = prefix + os.sep
-
- # XXX this code is essentially the same as the 'byte_compile()
- # method of the "install_lib" command, except for the determination
- # of the 'prefix' string. Hmmm.
- if self.compile:
- byte_compile(files, optimize=0,
- force=self.force, prefix=prefix, dry_run=self.dry_run)
- if self.optimize > 0:
- byte_compile(files, optimize=self.optimize,
- force=self.force, prefix=prefix, dry_run=self.dry_run)