Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/build_py.py @ 79691:05c8928362ee
Merge __next__ method link fixes with 3.3.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Fri, 12 Oct 2012 13:46:37 +0300 |
| parents | a1c17a5a460f |
| children | 265d369ad3b9 30aa032c4bd0 |
| rev | line source |
|---|---|
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1 """distutils.command.build_py |
|
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Implements the Distutils 'build_py' command.""" |
|
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
4 |
|
73322
ea926dff958f
More fixes for PEP 3147 compliance in distutils (#11254)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
5 import os |
|
ea926dff958f
More fixes for PEP 3147 compliance in distutils (#11254)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
6 import imp |
|
56741
a3cb812d80f9
Merged revisions 75704 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
49911
diff
changeset
|
7 import sys |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
8 from glob import glob |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
9 |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
10 from distutils.core import Command |
|
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
11 from distutils.errors import * |
|
49911
60e775eaaaee
Issue #4073: Add 2to3 support to build_scripts, refactor that support
Martin v. Löwis <martin@v.loewis.de>
parents:
49506
diff
changeset
|
12 from distutils.util import convert_path, Mixin2to3 |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22833
diff
changeset
|
13 from distutils import log |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
14 |
|
11813
eaeda4621f7d
Renamed all command classes so they're exactly the same as the name of the
Greg Ward <gward@python.net>
parents:
11690
diff
changeset
|
15 class build_py (Command): |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
16 |
|
11683
47f75a17b103
Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents:
11658
diff
changeset
|
17 description = "\"build\" pure Python modules (copy to build directory)" |
|
47f75a17b103
Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents:
11658
diff
changeset
|
18 |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
19 user_options = [ |
|
11884
758a87f4cb2c
Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
20 ('build-lib=', 'd', "directory to \"build\" (copy) to"), |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
21 ('compile', 'c', "compile .py to .pyc"), |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
22 ('no-compile', None, "don't compile .py files [default]"), |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
23 ('optimize=', 'O', |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
24 "also compile with optimization: -O1 for \"python -O\", " |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
25 "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), |
| 14434 | 26 ('force', 'f', "forcibly build everything (ignore file timestamps)"), |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
27 ] |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
28 |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
29 boolean_options = ['compile', 'force'] |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
30 negative_opt = {'no-compile' : 'compile'} |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14434
diff
changeset
|
31 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
32 def initialize_options(self): |
|
11884
758a87f4cb2c
Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
33 self.build_lib = None |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
34 self.py_modules = None |
|
11262
810c25d5041c
Changed to reflect the new "command options" regime -- in particular,
Greg Ward <gward@python.net>
parents:
11247
diff
changeset
|
35 self.package = None |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
36 self.package_data = None |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
37 self.package_dir = None |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
38 self.compile = 0 |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
39 self.optimize = 0 |
|
12314
20a5cbf9fcc0
Added '--force' option -- very clear what it means for building (ignore
Greg Ward <gward@python.net>
parents:
12094
diff
changeset
|
40 self.force = None |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
41 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
42 def finalize_options(self): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
43 self.set_undefined_options('build', |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
44 ('build_lib', 'build_lib'), |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
45 ('force', 'force')) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
46 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
47 # Get the distribution options that are aliases for build_py |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
48 # options -- list of packages and list of modules. |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
49 self.packages = self.distribution.packages |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
50 self.py_modules = self.distribution.py_modules |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
51 self.package_data = self.distribution.package_data |
|
21856
2f616474eaec
package_dir must be converted from the distutils path conventions to
Thomas Heller <theller@ctypes.org>
parents:
21268
diff
changeset
|
52 self.package_dir = {} |
|
2f616474eaec
package_dir must be converted from the distutils path conventions to
Thomas Heller <theller@ctypes.org>
parents:
21268
diff
changeset
|
53 if self.distribution.package_dir: |
|
2f616474eaec
package_dir must be converted from the distutils path conventions to
Thomas Heller <theller@ctypes.org>
parents:
21268
diff
changeset
|
54 for name, path in self.distribution.package_dir.items(): |
|
2f616474eaec
package_dir must be converted from the distutils path conventions to
Thomas Heller <theller@ctypes.org>
parents:
21268
diff
changeset
|
55 self.package_dir[name] = convert_path(path) |
|
32366
509072c3fa26
fix bug: list of data files was initialized too soon in build_py
Fred Drake <fdrake@acm.org>
parents:
32328
diff
changeset
|
56 self.data_files = self.get_data_files() |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
57 |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
58 # Ick, copied straight from install_lib.py (fancy_getopt needs a |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
59 # type system! Hell, *everything* needs a type system!!!) |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
60 if not isinstance(self.optimize, int): |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
61 try: |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
62 self.optimize = int(self.optimize) |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
63 assert 0 <= self.optimize <= 2 |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
64 except (ValueError, AssertionError): |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
65 raise DistutilsOptionError("optimize must be 0, 1, or 2") |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
66 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
67 def run(self): |
|
11545
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
68 # XXX copy_file by default preserves atime and mtime. IMHO this is |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
69 # the right thing to do, but perhaps it should be an option -- in |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
70 # particular, a site administrator might want installed files to |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
71 # reflect the time of installation rather than the last |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
72 # modification time before the installed release. |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
73 |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
74 # XXX copy_file by default preserves mode, which appears to be the |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
75 # wrong thing to do: if a file is read-only in the working |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
76 # directory, we want it to be installed read/write so that the next |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
77 # installation of the same module distribution can overwrite it |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
78 # without problems. (This might be a Unix-specific issue.) Thus |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
79 # we turn off 'preserve_mode' when copying to the build directory, |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
80 # since the build directory is supposed to be exactly what the |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
81 # installation will look like (ie. we preserve mode when |
|
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
82 # installing). |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
83 |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
84 # Two options control which modules will be installed: 'packages' |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
85 # and 'py_modules'. The former lets us work with whole packages, not |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
86 # specifying individual modules at all; the latter is for |
|
28114
14463f478240
[Patch #695090 from Bernhard Herzog] Allow specifying both py_modules and packages
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
87 # specifying modules one-at-a-time. |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
88 |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
89 if self.py_modules: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
90 self.build_modules() |
|
28114
14463f478240
[Patch #695090 from Bernhard Herzog] Allow specifying both py_modules and packages
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
91 if self.packages: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
92 self.build_packages() |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
93 self.build_package_data() |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
94 |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
95 self.byte_compile(self.get_outputs(include_bytecode=0)) |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
96 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
97 def get_data_files(self): |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
98 """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
99 data = [] |
|
32378
a9a4b0df512a
If self.packages is None (this can happen, I saw it), return
Sjoerd Mullender <sjoerd@acm.org>
parents:
32366
diff
changeset
|
100 if not self.packages: |
|
a9a4b0df512a
If self.packages is None (this can happen, I saw it), return
Sjoerd Mullender <sjoerd@acm.org>
parents:
32366
diff
changeset
|
101 return data |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
102 for package in self.packages: |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
103 # Locate package source directory |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
104 src_dir = self.get_package_dir(package) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
105 |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
106 # Compute package build directory |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
107 build_dir = os.path.join(*([self.build_lib] + package.split('.'))) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
108 |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
109 # Length of path to strip from found files |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41558
diff
changeset
|
110 plen = 0 |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41558
diff
changeset
|
111 if src_dir: |
|
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
41558
diff
changeset
|
112 plen = len(src_dir)+1 |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
113 |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
114 # Strip directory from globbed filenames |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
115 filenames = [ |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
116 file[plen:] for file in self.find_data_files(package, src_dir) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
117 ] |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
118 data.append((package, src_dir, build_dir, filenames)) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
119 return data |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
120 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
121 def find_data_files(self, package, src_dir): |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
122 """Return filenames for package's data files in 'src_dir'""" |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
123 globs = (self.package_data.get('', []) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
124 + self.package_data.get(package, [])) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
125 files = [] |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
126 for pattern in globs: |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
127 # Each pattern has to be converted to a platform-specific path |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
128 filelist = glob(os.path.join(src_dir, convert_path(pattern))) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
129 # Files that match more than one pattern are only added once |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
130 files.extend([fn for fn in filelist if fn not in files]) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
131 return files |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
132 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
133 def build_package_data(self): |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
134 """Copy data files into build directory""" |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
135 lastdir = None |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
136 for package, src_dir, build_dir, filenames in self.data_files: |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
137 for filename in filenames: |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
138 target = os.path.join(build_dir, filename) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
139 self.mkpath(os.path.dirname(target)) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
140 self.copy_file(os.path.join(src_dir, filename), target, |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
141 preserve_mode=False) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
142 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
143 def get_package_dir(self, package): |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
144 """Return the directory, relative to the top of the source |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
145 distribution, where package 'package' should be found |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
146 (at least according to the 'package_dir' option, if any).""" |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
37048
diff
changeset
|
147 path = package.split('.') |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
148 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
149 if not self.package_dir: |
| 11521 | 150 if path: |
| 37048 | 151 return os.path.join(*path) |
| 11521 | 152 else: |
| 153 return '' | |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
154 else: |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
155 tail = [] |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
156 while path: |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
157 try: |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
37048
diff
changeset
|
158 pdir = self.package_dir['.'.join(path)] |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
159 except KeyError: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
160 tail.insert(0, path[-1]) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
161 del path[-1] |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
162 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
163 tail.insert(0, pdir) |
| 37048 | 164 return os.path.join(*tail) |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
165 else: |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
166 # Oops, got all the way through 'path' without finding a |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
167 # match in package_dir. If package_dir defines a directory |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
168 # for the root (nameless) package, then fallback on it; |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
169 # otherwise, we might as well have not consulted |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
170 # package_dir at all, as we just use the directory implied |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
171 # by 'tail' (which should be the same as the original value |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
172 # of 'path' at this point). |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
173 pdir = self.package_dir.get('') |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
174 if pdir is not None: |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
175 tail.insert(0, pdir) |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
176 |
| 11521 | 177 if tail: |
| 37048 | 178 return os.path.join(*tail) |
| 11521 | 179 else: |
| 180 return '' | |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
181 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
182 def check_package(self, package, package_dir): |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
183 # Empty dir name means current directory, which we can probably |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
184 # assume exists. Also, os.path.exists and isdir don't know about |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
185 # my "empty string means current dir" convention, so we have to |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
186 # circumvent them. |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
187 if package_dir != "": |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
188 if not os.path.exists(package_dir): |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
189 raise DistutilsFileError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
190 "package directory '%s' does not exist" % package_dir) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
191 if not os.path.isdir(package_dir): |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
192 raise DistutilsFileError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
193 "supposed package directory '%s' exists, " |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
194 "but is not a directory" % package_dir) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
195 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
196 # Require __init__.py for all but the "root package" |
| 11521 | 197 if package: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
198 init_py = os.path.join(package_dir, "__init__.py") |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
199 if os.path.isfile(init_py): |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
200 return init_py |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
201 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22833
diff
changeset
|
202 log.warn(("package init file '%s' not found " + |
|
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22833
diff
changeset
|
203 "(or not a regular file)"), init_py) |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
204 |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
205 # Either not in a package at all (__init__.py not expected), or |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
206 # __init__.py doesn't exist -- so don't return the filename. |
|
23679
b18348bdca08
Make None return explicit
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
207 return None |
| 21268 | 208 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
209 def check_module(self, module, module_file): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
210 if not os.path.isfile(module_file): |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22833
diff
changeset
|
211 log.warn("file %s (for module %s) not found", module_file, module) |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
212 return False |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
213 else: |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
214 return True |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
215 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
216 def find_package_modules(self, package, package_dir): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
217 self.check_package(package, package_dir) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
218 module_files = glob(os.path.join(package_dir, "*.py")) |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
219 modules = [] |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13987
diff
changeset
|
220 setup_script = os.path.abspath(self.distribution.script_name) |
|
11545
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
221 |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
222 for f in module_files: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
223 abs_f = os.path.abspath(f) |
|
11545
7555990e8db9
Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents:
11521
diff
changeset
|
224 if abs_f != setup_script: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
225 module = os.path.splitext(os.path.basename(f))[0] |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
226 modules.append((package, module, f)) |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13987
diff
changeset
|
227 else: |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
13987
diff
changeset
|
228 self.debug_print("excluding %s" % setup_script) |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
229 return modules |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
230 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
231 def find_modules(self): |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
232 """Finds individually-specified Python modules, ie. those listed by |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
233 module name in 'self.py_modules'. Returns a list of tuples (package, |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
234 module_base, filename): 'package' is a tuple of the path through |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
235 package-space to the module; 'module_base' is the bare (no |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
236 packages, no dots) module name, and 'filename' is the path to the |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
237 ".py" file (relative to the distribution root) that implements the |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
238 module. |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
239 """ |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
240 # Map package names to tuples of useful info about the package: |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
241 # (package_dir, checked) |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
242 # package_dir - the directory where we'll find source files for |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
243 # this package |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
244 # checked - true if we have checked that the package directory |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
245 # is valid (exists, contains __init__.py, ... ?) |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
246 packages = {} |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
247 |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
248 # List of (package, module, filename) tuples to return |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
249 modules = [] |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
250 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
251 # We treat modules-in-packages almost the same as toplevel modules, |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
252 # just the "package" for a toplevel is empty (either an empty |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
253 # string or empty list, depending on context). Differences: |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
254 # - don't check for __init__.py in directory for empty package |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
255 for module in self.py_modules: |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
37048
diff
changeset
|
256 path = module.split('.') |
|
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
37048
diff
changeset
|
257 package = '.'.join(path[0:-1]) |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
258 module_base = path[-1] |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
259 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
260 try: |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
261 (package_dir, checked) = packages[package] |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
262 except KeyError: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
263 package_dir = self.get_package_dir(package) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
264 checked = 0 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
265 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
266 if not checked: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
267 init_py = self.check_package(package, package_dir) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
268 packages[package] = (package_dir, 1) |
|
12760
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
269 if init_py: |
|
0f1e4e3935d7
Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
270 modules.append((package, "__init__", init_py)) |
|
10437
3bc8f53041c0
First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
271 |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
272 # XXX perhaps we should also check for just .pyc files |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
273 # (so greedy closed-source bastards can distribute Python |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
274 # modules too) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
275 module_file = os.path.join(package_dir, module_base + ".py") |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
276 if not self.check_module(module, module_file): |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
277 continue |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
278 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
279 modules.append((package, module_base, module_file)) |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
280 |
|
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
281 return modules |
|
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
282 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
283 def find_all_modules(self): |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
284 """Compute the list of all modules that will be built, whether |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
285 they are specified one-module-at-a-time ('self.py_modules') or |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
286 by whole packages ('self.packages'). Return a list of tuples |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
287 (package, module, module_file), just like 'find_modules()' and |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
288 'find_package_modules()' do.""" |
|
28114
14463f478240
[Patch #695090 from Bernhard Herzog] Allow specifying both py_modules and packages
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
289 modules = [] |
|
12847
4916d40d9677
Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents:
12760
diff
changeset
|
290 if self.py_modules: |
|
28114
14463f478240
[Patch #695090 from Bernhard Herzog] Allow specifying both py_modules and packages
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
291 modules.extend(self.find_modules()) |
|
14463f478240
[Patch #695090 from Bernhard Herzog] Allow specifying both py_modules and packages
Andrew M. Kuchling <amk@amk.ca>
parents:
26285
diff
changeset
|
292 if self.packages: |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
293 for package in self.packages: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
294 package_dir = self.get_package_dir(package) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
295 m = self.find_package_modules(package, package_dir) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
296 modules.extend(m) |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
297 return modules |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
298 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
299 def get_source_files(self): |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
300 return [module[-1] for module in self.find_all_modules()] |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
301 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
302 def get_module_outfile(self, build_dir, package, module): |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
303 outfile_path = [build_dir] + list(package) + [module + ".py"] |
| 37048 | 304 return os.path.join(*outfile_path) |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
305 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
306 def get_outputs(self, include_bytecode=1): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
307 modules = self.find_all_modules() |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
308 outputs = [] |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
309 for (package, module, module_file) in modules: |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
37048
diff
changeset
|
310 package = package.split('.') |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
311 filename = self.get_module_outfile(self.build_lib, package, module) |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
312 outputs.append(filename) |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
313 if include_bytecode: |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
314 if self.compile: |
|
73322
ea926dff958f
More fixes for PEP 3147 compliance in distutils (#11254)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
315 outputs.append(imp.cache_from_source(filename, |
|
ea926dff958f
More fixes for PEP 3147 compliance in distutils (#11254)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
316 debug_override=True)) |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
317 if self.optimize > 0: |
|
73322
ea926dff958f
More fixes for PEP 3147 compliance in distutils (#11254)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
318 outputs.append(imp.cache_from_source(filename, |
|
ea926dff958f
More fixes for PEP 3147 compliance in distutils (#11254)
Éric Araujo <merwok@netwok.org>
parents:
71540
diff
changeset
|
319 debug_override=False)) |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
320 |
|
32328
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
321 outputs += [ |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
322 os.path.join(build_dir, filename) |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
323 for package, src_dir, build_dir, filenames in self.data_files |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
324 for filename in filenames |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
325 ] |
|
f49471953689
Add support for package data.
Fred Drake <fdrake@acm.org>
parents:
28114
diff
changeset
|
326 |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
327 return outputs |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
328 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
329 def build_module(self, module, module_file, package): |
|
43577
ace45b361e87
Patch# 1258 by Christian Heimes: kill basestring.
Guido van Rossum <guido@python.org>
parents:
43026
diff
changeset
|
330 if isinstance(package, str): |
|
41480
99027c2b3fd2
Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents:
37048
diff
changeset
|
331 package = package.split('.') |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
332 elif not isinstance(package, (list, tuple)): |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
333 raise TypeError( |
|
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
334 "'package' must be a string (dot-separated), list, or tuple") |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
335 |
|
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
336 # Now put the module source file into the "build" area -- this is |
|
11884
758a87f4cb2c
Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
337 # easy, we just copy it somewhere under self.build_lib (the build |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
338 # directory for Python source). |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
339 outfile = self.get_module_outfile(self.build_lib, package, module) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
340 dir = os.path.dirname(outfile) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
341 self.mkpath(dir) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
342 return self.copy_file(module_file, outfile, preserve_mode=0) |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
343 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
344 def build_modules(self): |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
345 modules = self.find_modules() |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
346 for (package, module, module_file) in modules: |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
347 # Now "build" the module -- ie. copy the source file to |
|
11884
758a87f4cb2c
Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
348 # self.build_lib (the build directory for Python source). |
|
11339
6f7507ef2b11
Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents:
11299
diff
changeset
|
349 # (Actually, it gets copied to the directory for this package |
|
11884
758a87f4cb2c
Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
350 # under self.build_lib.) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
351 self.build_module(module, module_file, package) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
352 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
353 def build_packages(self): |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
354 for package in self.packages: |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
355 # Get list of (package, module, module_file) tuples based on |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
356 # scanning the package directory. 'package' is only included |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
357 # in the tuple so that 'find_modules()' and |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
358 # 'find_package_tuples()' have a consistent interface; it's |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
359 # ignored here (apart from a sanity check). Also, 'module' is |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
360 # the *unqualified* module name (ie. no dots, no package -- we |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
361 # already know its package!), and 'module_file' is the path to |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
362 # the .py file, relative to the current directory |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
363 # (ie. including 'package_dir'). |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
364 package_dir = self.get_package_dir(package) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
365 modules = self.find_package_modules(package, package_dir) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
366 |
|
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
367 # Now loop over the modules we found, "building" each one (just |
|
11884
758a87f4cb2c
Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
368 # copy it to self.build_lib). |
|
12094
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
369 for (package_, module, module_file) in modules: |
|
8d1c69bdc4f2
Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents:
11903
diff
changeset
|
370 assert package == package_ |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14943
diff
changeset
|
371 self.build_module(module, module_file, package) |
|
11299
6d646f7e1a1c
Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents:
11280
diff
changeset
|
372 |
|
43026
a6d3930b5613
General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents:
42084
diff
changeset
|
373 def byte_compile(self, files): |
|
56741
a3cb812d80f9
Merged revisions 75704 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
49911
diff
changeset
|
374 if sys.dont_write_bytecode: |
|
a3cb812d80f9
Merged revisions 75704 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
49911
diff
changeset
|
375 self.warn('byte-compiling is disabled, skipping.') |
|
a3cb812d80f9
Merged revisions 75704 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
49911
diff
changeset
|
376 return |
|
a3cb812d80f9
Merged revisions 75704 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
49911
diff
changeset
|
377 |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
378 from distutils.util import byte_compile |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
379 prefix = self.build_lib |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
380 if prefix[-1] != os.sep: |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
381 prefix = prefix + os.sep |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
382 |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
383 # XXX this code is essentially the same as the 'byte_compile() |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
384 # method of the "install_lib" command, except for the determination |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
385 # of the 'prefix' string. Hmmm. |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
386 if self.compile: |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
387 byte_compile(files, optimize=0, |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22833
diff
changeset
|
388 force=self.force, prefix=prefix, dry_run=self.dry_run) |
|
14963
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
389 if self.optimize > 0: |
|
73d09322f2c3
Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents:
14948
diff
changeset
|
390 byte_compile(files, optimize=self.optimize, |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22833
diff
changeset
|
391 force=self.force, prefix=prefix, dry_run=self.dry_run) |
| 45995 | 392 |
|
49911
60e775eaaaee
Issue #4073: Add 2to3 support to build_scripts, refactor that support
Martin v. Löwis <martin@v.loewis.de>
parents:
49506
diff
changeset
|
393 class build_py_2to3(build_py, Mixin2to3): |
| 45995 | 394 def run(self): |
|
46016
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
395 self.updated_files = [] |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
396 |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
397 # Base class code |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
398 if self.py_modules: |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
399 self.build_modules() |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
400 if self.packages: |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
401 self.build_packages() |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
402 self.build_package_data() |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
403 |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
404 # 2to3 |
|
49911
60e775eaaaee
Issue #4073: Add 2to3 support to build_scripts, refactor that support
Martin v. Löwis <martin@v.loewis.de>
parents:
49506
diff
changeset
|
405 self.run_2to3(self.updated_files) |
| 45995 | 406 |
|
46016
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
407 # Remaining base class code |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
408 self.byte_compile(self.get_outputs(include_bytecode=0)) |
|
957cba755315
Invoke byte-compilation after running 2to3.
Martin v. Löwis <martin@v.loewis.de>
parents:
45995
diff
changeset
|
409 |
| 45995 | 410 def build_module(self, module, module_file, package): |
| 411 res = build_py.build_module(self, module, module_file, package) | |
| 412 if res[1]: | |
| 413 # file was copied | |
| 414 self.updated_files.append(res[0]) | |
| 415 return res |
