summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests/support.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-11-03 04:08:28 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-11-03 04:08:28 (GMT)
commit880801501b778d93079afc11672dba86e60eab94 (patch)
tree32bad2da11ff3f125f67e46d93c308f18c311eab /Lib/packaging/tests/support.py
parentdfd232898d4ae64a4c176ed492eec5e1ab209ef8 (diff)
downloadcpython-880801501b778d93079afc11672dba86e60eab94.zip
cpython-880801501b778d93079afc11672dba86e60eab94.tar.gz
cpython-880801501b778d93079afc11672dba86e60eab94.tar.bz2
Improve byte-compilation in packaging to be independent of -O or -B.
The code I fixed to comply with PEP 3147 still had one bug: When run under python -O, some paths for pyc files would be pyo, because I called imp.cache_from_source without explicit debug_override argument in some places, and under -O that would return .pyo (this is well explained in the imp docs). Now all code (util.byte_compile, build_py, install_lib) can create .pyo files according to options given by users, without interference from the calling Python’s own optimize mode. On a related topic, I also removed the code that prevented byte compilation under python -B. The rationale is that packaging gives control over the creation of pyc files to the user with its own explicit option, and the behavior should not be changed if the calling Python happens to run with -B for whatever reason. I will argue that this is a bug fix and ask to be allowed to backport this change to distutils. Finally, I moved one nugget of information about the --compile and --optimize options from the source into the doc. It clears up a misunderstanding that I (and maybe other people) had.
Diffstat (limited to 'Lib/packaging/tests/support.py')
-rw-r--r--Lib/packaging/tests/support.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/packaging/tests/support.py b/Lib/packaging/tests/support.py
index 6e26ea4..66890c9 100644
--- a/Lib/packaging/tests/support.py
+++ b/Lib/packaging/tests/support.py
@@ -53,7 +53,7 @@ __all__ = [
# misc. functions and decorators
'fake_dec', 'create_distribution', 'copy_xxmodule_c', 'fixup_build_ext',
# imported from this module for backport purposes
- 'unittest', 'requires_zlib', 'skip_unless_symlink',
+ 'unittest', 'requires_zlib', 'skip_2to3_optimize', 'skip_unless_symlink',
]
@@ -357,3 +357,7 @@ try:
except ImportError:
skip_unless_symlink = unittest.skip(
'requires test.support.skip_unless_symlink')
+
+
+skip_2to3_optimize = unittest.skipIf(sys.flags.optimize,
+ "2to3 doesn't work under -O")