]>
Commit | Line | Data |
---|---|---|
48e785bb JK |
1 | diff -dur -x '*~' -x '*.orig' -x '*.rej' Python-3.2.1.orig/Lib/distutils/tests/test_build_py.py Python-3.2.1/Lib/distutils/tests/test_build_py.py |
2 | --- Python-3.2.1.orig/Lib/distutils/tests/test_build_py.py 2011-07-09 08:58:47.000000000 +0200 | |
3 | +++ Python-3.2.1/Lib/distutils/tests/test_build_py.py 2011-07-15 13:55:54.000000000 +0200 | |
7dd2ca46 | 4 | @@ -3,6 +3,7 @@ |
5 | import os | |
6 | import sys | |
7 | import io | |
8 | +import imp | |
9 | import unittest | |
10 | ||
11 | from distutils.command.build_py import build_py | |
48e785bb | 12 | @@ -57,13 +58,15 @@ |
7dd2ca46 | 13 | self.assertEqual(len(cmd.get_outputs()), 3) |
14 | pkgdest = os.path.join(destination, "pkg") | |
15 | files = os.listdir(pkgdest) | |
7dd2ca46 | 16 | + byte_compiled_files = os.listdir(os.path.join(pkgdest, "__pycache__")) |
48e785bb JK |
17 | self.assertIn("__init__.py", files) |
18 | self.assertIn("README.txt", files) | |
19 | + init_pyc = "__init__.{}.pyc".format(imp.get_tag()) | |
20 | # XXX even with -O, distutils writes pyc, not pyo; bug? | |
21 | if sys.dont_write_bytecode: | |
22 | - self.assertNotIn("__init__.pyc", files) | |
23 | + self.assertNotIn(init_pyc, byte_compiled_files) | |
24 | else: | |
25 | - self.assertIn("__init__.pyc", files) | |
26 | + self.assertIn(init_pyc, byte_compiled_files) | |
7dd2ca46 | 27 | |
48e785bb | 28 | def test_empty_package_dir(self): |
7dd2ca46 | 29 | # See SF 1668596/1720897. |
48e785bb JK |
30 | diff -dur -x '*~' -x '*.orig' -x '*.rej' Python-3.2.1.orig/Lib/distutils/tests/test_install_lib.py Python-3.2.1/Lib/distutils/tests/test_install_lib.py |
31 | --- Python-3.2.1.orig/Lib/distutils/tests/test_install_lib.py 2011-07-09 08:58:47.000000000 +0200 | |
32 | +++ Python-3.2.1/Lib/distutils/tests/test_install_lib.py 2011-07-15 13:53:50.000000000 +0200 | |
7dd2ca46 | 33 | @@ -1,6 +1,7 @@ |
34 | """Tests for distutils.command.install_data.""" | |
35 | import sys | |
36 | import os | |
37 | +import imp | |
38 | import unittest | |
39 | ||
40 | from distutils.command.install_lib import install_lib | |
48e785bb | 41 | @@ -36,14 +37,19 @@ |
7dd2ca46 | 42 | 'byte-compile not supported') |
43 | def test_byte_compile(self): | |
44 | pkg_dir, dist = self.create_dist() | |
45 | + cache_dir = os.path.join(pkg_dir, '__pycache__') | |
46 | cmd = install_lib(dist) | |
47 | cmd.compile = cmd.optimize = 1 | |
48 | ||
49 | f = os.path.join(pkg_dir, 'foo.py') | |
50 | self.write_file(f, '# python file') | |
51 | cmd.byte_compile([f]) | |
52 | - self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc'))) | |
53 | - self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo'))) | |
54 | + compiled_file = os.path.join(cache_dir, | |
55 | + "foo.{}.pyc".format(imp.get_tag())) | |
56 | + optimized_file = os.path.join(cache_dir, | |
57 | + "foo.{}.pyo".format(imp.get_tag())) | |
58 | + self.assertTrue(os.path.exists(compiled_file)) | |
59 | + self.assertTrue(os.path.exists(optimized_file)) | |
60 | ||
61 | def test_get_outputs(self): | |
62 | pkg_dir, dist = self.create_dist() | |
48e785bb JK |
63 | diff -dur -x '*~' -x '*.orig' -x '*.rej' Python-3.2.1.orig/Lib/distutils/util.py Python-3.2.1/Lib/distutils/util.py |
64 | --- Python-3.2.1.orig/Lib/distutils/util.py 2011-07-09 08:58:47.000000000 +0200 | |
65 | +++ Python-3.2.1/Lib/distutils/util.py 2011-07-15 13:53:50.000000000 +0200 | |
66 | @@ -6,7 +6,7 @@ | |
7dd2ca46 | 67 | |
68 | __revision__ = "$Id$" | |
69 | ||
70 | -import sys, os, string, re | |
71 | +import sys, os, string, re, imp | |
72 | from distutils.errors import DistutilsPlatformError | |
73 | from distutils.dep_util import newer | |
74 | from distutils.spawn import spawn | |
48e785bb | 75 | @@ -531,7 +531,7 @@ |
7dd2ca46 | 76 | # Terminology from the py_compile module: |
77 | # cfile - byte-compiled file | |
78 | # dfile - purported source filename (same as 'file' by default) | |
79 | - cfile = file + (__debug__ and "c" or "o") | |
80 | + cfile = imp.cache_from_source(file, debug_override=not optimize) | |
81 | dfile = file | |
82 | if prefix: | |
83 | if file[:len(prefix)] != prefix: |