Issue #23731: Implement PEP 488.

The concept of .pyo files no longer exists. Now .pyc files have an
optional `opt-` tag which specifies if any extra optimizations beyond
the peepholer were applied.
This commit is contained in:
Brett Cannon 2015-04-13 14:21:02 -04:00
parent a63cc21234
commit f299abdafa
56 changed files with 4731 additions and 4621 deletions

View file

@ -120,8 +120,8 @@ class BuildPyTestCase(support.TempdirManager,
found = os.listdir(cmd.build_lib)
self.assertEqual(sorted(found), ['__pycache__', 'boiledeggs.py'])
found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
self.assertEqual(sorted(found),
['boiledeggs.%s.pyo' % sys.implementation.cache_tag])
expect = 'boiledeggs.{}.opt-1.pyc'.format(sys.implementation.cache_tag)
self.assertEqual(sorted(found), [expect])
def test_dir_in_package_data(self):
"""

View file

@ -44,12 +44,11 @@ class InstallLibTestCase(support.TempdirManager,
f = os.path.join(project_dir, 'foo.py')
self.write_file(f, '# python file')
cmd.byte_compile([f])
pyc_file = importlib.util.cache_from_source('foo.py',
debug_override=True)
pyo_file = importlib.util.cache_from_source('foo.py',
debug_override=False)
pyc_file = importlib.util.cache_from_source('foo.py', optimization='')
pyc_opt_file = importlib.util.cache_from_source('foo.py',
optimization=cmd.optimize)
self.assertTrue(os.path.exists(pyc_file))
self.assertTrue(os.path.exists(pyo_file))
self.assertTrue(os.path.exists(pyc_opt_file))
def test_get_outputs(self):
project_dir, dist = self.create_dist()
@ -66,8 +65,8 @@ class InstallLibTestCase(support.TempdirManager,
cmd.distribution.packages = ['spam']
cmd.distribution.script_name = 'setup.py'
# get_outputs should return 4 elements: spam/__init__.py, .pyc and
# .pyo, foo.import-tag-abiflags.so / foo.pyd
# get_outputs should return 4 elements: spam/__init__.py and .pyc,
# foo.import-tag-abiflags.so / foo.pyd
outputs = cmd.get_outputs()
self.assertEqual(len(outputs), 4, outputs)