annotate Lib/distutils/command/build_py.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents ac4931ab0369
children cdf6a3a50407
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
33965
893d46576737 Update compatibility comments to 2.1, corresponding to PEP 291 1.13.
Martin v. Löwis <martin@v.loewis.de>
parents: 32378
diff changeset
5 # This module should be kept compatible with Python 2.1.
26285
42bfc98d295b Add comment to Distutil files about requiring 1.5.2 compatibility, as
Andrew M. Kuchling <amk@amk.ca>
parents: 26210
diff changeset
6
11897
017e592c0fd2 Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents: 11884
diff changeset
7 __revision__ = "$Id$"
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
8
45468
1d84bf5f9478 Patch #2167 from calvin: Remove unused imports
Christian Heimes <christian@cheimes.de>
parents: 41929
diff changeset
9 import string, os
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
10 from types import *
58205
ac4931ab0369 Merged revisions 75669-75671 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 48260
diff changeset
11 import sys
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
12 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
13
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
14 from distutils.core import Command
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
15 from distutils.errors import *
21856
2f616474eaec package_dir must be converted from the distutils path conventions to
Thomas Heller <theller@ctypes.org>
parents: 21268
diff changeset
16 from distutils.util import convert_path
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22833
diff changeset
17 from distutils import log
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
18
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
19 class build_py (Command):
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
20
11683
47f75a17b103 Added 'description' class attribute to every command class (to help the
Greg Ward <gward@python.net>
parents: 11658
diff changeset
21 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
22
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
23 user_options = [
11884
758a87f4cb2c Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents: 11817
diff changeset
24 ('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
25 ('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
26 ('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
27 ('optimize=', 'O',
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
28 "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
29 "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
14434
34379127ee3b Typo fix.
Greg Ward <gward@python.net>
parents: 14237
diff changeset
30 ('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
31 ]
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
32
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
33 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
34 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
35
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
36
11817
476eaa38e2d6 Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents: 11815
diff changeset
37 def initialize_options (self):
11884
758a87f4cb2c Build reorg: change 'build_dir' option to 'build_lib'.
Greg Ward <gward@python.net>
parents: 11817
diff changeset
38 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
39 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
40 self.package = None
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
41 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
42 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
43 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
44 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
45 self.force = None
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
46
11817
476eaa38e2d6 Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents: 11815
diff changeset
47 def finalize_options (self):
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
48 self.set_undefined_options('build',
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
49 ('build_lib', 'build_lib'),
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
50 ('force', 'force'))
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
51
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
52 # 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
53 # 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
54 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
55 self.py_modules = self.distribution.py_modules
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
56 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
57 self.package_dir = {}
2f616474eaec package_dir must be converted from the distutils path conventions to
Thomas Heller <theller@ctypes.org>
parents: 21268
diff changeset
58 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
59 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
60 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
61 self.data_files = self.get_data_files()
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
62
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
63 # 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
64 # type system! Hell, *everything* needs a type system!!!)
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
65 if type(self.optimize) is not IntType:
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
66 try:
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
67 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
68 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
69 except (ValueError, AssertionError):
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
70 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
71
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
72 def run (self):
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
73
11545
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 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
75 # 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
76 # 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
77 # 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
78 # 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
79
7555990e8db9 Fixed 'find_package_modules()' to ensure that we never build (and thus
Greg Ward <gward@python.net>
parents: 11521
diff changeset
80 # 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
81 # 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
82 # 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
83 # 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
84 # 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
85 # 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
86 # 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
87 # 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
88 # installing).
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
89
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
90 # 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
91 # 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
92 # 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
93 # specifying modules one-at-a-time.
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
94
12847
4916d40d9677 Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents: 12760
diff changeset
95 if self.py_modules:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
96 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
97 if self.packages:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
98 self.build_packages()
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
99 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
100
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
101 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
102
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
103 # run ()
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 14963
diff changeset
104
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
105 def get_data_files (self):
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
106 """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
107 data = []
32378
a9a4b0df512a If self.packages is None (this can happen, I saw it), return
Sjoerd Mullender <sjoerd@acm.org>
parents: 32366
diff changeset
108 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
109 return data
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
110 for package in self.packages:
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
111 # Locate package source directory
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
112 src_dir = self.get_package_dir(package)
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 # Compute package build directory
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
115 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
116
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
117 # Length of path to strip from found files
41929
24efa2e448bc SF 1668596/1720897: distutils now copies data files
Neal Norwitz <nnorwitz@gmail.com>
parents: 33965
diff changeset
118 plen = 0
24efa2e448bc SF 1668596/1720897: distutils now copies data files
Neal Norwitz <nnorwitz@gmail.com>
parents: 33965
diff changeset
119 if src_dir:
24efa2e448bc SF 1668596/1720897: distutils now copies data files
Neal Norwitz <nnorwitz@gmail.com>
parents: 33965
diff changeset
120 plen = len(src_dir)+1
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
121
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
122 # Strip directory from globbed filenames
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
123 filenames = [
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
124 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
125 ]
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
126 data.append((package, src_dir, build_dir, filenames))
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
127 return data
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
128
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
129 def find_data_files (self, package, src_dir):
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
130 """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
131 globs = (self.package_data.get('', [])
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
132 + self.package_data.get(package, []))
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
133 files = []
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
134 for pattern in globs:
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
135 # 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
136 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
137 # 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
138 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
139 return files
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
140
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
141 def build_package_data (self):
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
142 """Copy data files into build directory"""
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
143 lastdir = None
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
144 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
145 for filename in filenames:
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
146 target = os.path.join(build_dir, filename)
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
147 self.mkpath(os.path.dirname(target))
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
148 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
149 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
150
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
151 def get_package_dir (self, package):
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
152 """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
153 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
154 (at least according to the 'package_dir' option, if any)."""
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
155
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
156 path = string.split(package, '.')
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
157
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
158 if not self.package_dir:
11521
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
159 if path:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
160 return apply(os.path.join, path)
11521
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
161 else:
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
162 return ''
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
163 else:
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
164 tail = []
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
165 while path:
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
166 try:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
167 pdir = self.package_dir[string.join(path, '.')]
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
168 except KeyError:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
169 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
170 del path[-1]
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
171 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
172 tail.insert(0, pdir)
48260
2be17d368a9c Update distutils so that it triggers no warnings when run under -3.
Brett Cannon <bcannon@gmail.com>
parents: 45468
diff changeset
173 return os.path.join(*tail)
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
174 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
175 # 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
176 # 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
177 # 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
178 # 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
179 # 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
180 # 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
181 # 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
182 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
183 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
184 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
185
11521
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
186 if tail:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
187 return apply(os.path.join, tail)
11521
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
188 else:
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
189 return ''
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
190
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
191 # get_package_dir ()
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
192
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
193
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
194 def check_package (self, package, package_dir):
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 # 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
197 # 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
198 # 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
199 # circumvent them.
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
200 if package_dir != "":
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
201 if not os.path.exists(package_dir):
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
202 raise DistutilsFileError, \
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
203 "package directory '%s' does not exist" % package_dir
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
204 if not os.path.isdir(package_dir):
11903
f8518f060bed Typo fix.
Greg Ward <gward@python.net>
parents: 11897
diff changeset
205 raise DistutilsFileError, \
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
206 ("supposed package directory '%s' exists, " +
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
207 "but is not a directory") % package_dir
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
208
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
209 # Require __init__.py for all but the "root package"
11521
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
210 if package:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
211 init_py = os.path.join(package_dir, "__init__.py")
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
212 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
213 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
214 else:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22833
diff changeset
215 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
216 "(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
217
0f1e4e3935d7 Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents: 12743
diff changeset
218 # 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
219 # __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
220 return None
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 14963
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 # check_package ()
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
223
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
224
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
225 def check_module (self, module, module_file):
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
226 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
227 log.warn("file %s (for module %s) not found", module_file, module)
22833
c865cf8bee40 Revert 0/1 -> False/True change; I didn't intend to muck w/ distutils.
Tim Peters <tim.peters@gmail.com>
parents: 22830
diff changeset
228 return 0
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
229 else:
22833
c865cf8bee40 Revert 0/1 -> False/True change; I didn't intend to muck w/ distutils.
Tim Peters <tim.peters@gmail.com>
parents: 22830
diff changeset
230 return 1
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
231
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
232 # check_module ()
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
233
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
234
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
235 def find_package_modules (self, package, package_dir):
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
236 self.check_package(package, package_dir)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
237 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
238 modules = []
14237
d9643e9c90eb Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents: 13987
diff changeset
239 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
240
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
241 for f in module_files:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
242 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
243 if abs_f != setup_script:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
244 module = os.path.splitext(os.path.basename(f))[0]
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
245 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
246 else:
d9643e9c90eb Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents: 13987
diff changeset
247 self.debug_print("excluding %s" % setup_script)
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
248 return modules
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
249
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
250
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
251 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
252 """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
253 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
254 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
255 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
256 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
257 ".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
258 module.
0f1e4e3935d7 Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents: 12743
diff changeset
259 """
0f1e4e3935d7 Fixed a couple of long-hidden bugs (amazing what you find when you
Greg Ward <gward@python.net>
parents: 12743
diff changeset
260
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
261 # 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
262 # (package_dir, checked)
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
263 # 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
264 # this package
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
265 # 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
266 # 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
267 packages = {}
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
268
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 # 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
270 modules = []
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
271
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
272 # 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
273 # 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
274 # 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
275 # - don't check for __init__.py in directory for empty package
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
276
12847
4916d40d9677 Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents: 12760
diff changeset
277 for module in self.py_modules:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
278 path = string.split(module, '.')
13987
f3bfcee745a7 Fix long-hidden inconsistency in internal interface: 'find_modules()' now
Greg Ward <gward@python.net>
parents: 12847
diff changeset
279 package = string.join(path[0:-1], '.')
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
280 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
281
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
282 try:
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
283 (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
284 except KeyError:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
285 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
286 checked = 0
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
287
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
288 if not checked:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
289 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
290 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
291 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
292 modules.append((package, "__init__", init_py))
10437
3bc8f53041c0 First checkin of real Distutils command modules.
Greg Ward <gward@python.net>
parents:
diff changeset
293
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
294 # 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
295 # (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
296 # modules too)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
297 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
298 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
299 continue
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
300
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
301 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
302
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
303 return modules
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
304
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
305 # find_modules ()
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
306
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
307
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
308 def find_all_modules (self):
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
309 """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
310 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
311 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
312 (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
313 'find_package_modules()' do."""
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
314
28114
14463f478240 [Patch #695090 from Bernhard Herzog] Allow specifying both py_modules and packages
Andrew M. Kuchling <amk@amk.ca>
parents: 26285
diff changeset
315 modules = []
12847
4916d40d9677 Renamed 'modules' option to 'py_modules', for consistency with Distribution
Greg Ward <gward@python.net>
parents: 12760
diff changeset
316 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
317 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
318 if self.packages:
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
319 for package in self.packages:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
320 package_dir = self.get_package_dir(package)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
321 m = self.find_package_modules(package, package_dir)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
322 modules.extend(m)
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
323
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
324 return modules
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
325
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
326 # find_all_modules ()
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
327
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
328
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
329 def get_source_files (self):
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
330
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
331 modules = self.find_all_modules()
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
332 filenames = []
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
333 for module in modules:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
334 filenames.append(module[-1])
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
335
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
336 return filenames
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
337
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
338
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
339 def get_module_outfile (self, build_dir, package, module):
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
340 outfile_path = [build_dir] + list(package) + [module + ".py"]
48260
2be17d368a9c Update distutils so that it triggers no warnings when run under -3.
Brett Cannon <bcannon@gmail.com>
parents: 45468
diff changeset
341 return os.path.join(*outfile_path)
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
342
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
343
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
344 def get_outputs (self, include_bytecode=1):
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
345 modules = self.find_all_modules()
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
346 outputs = []
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
347 for (package, module, module_file) in modules:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
348 package = string.split(package, '.')
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
349 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
350 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
351 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
352 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
353 outputs.append(filename + "c")
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
354 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
355 outputs.append(filename + "o")
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
356
32328
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
357 outputs += [
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
358 os.path.join(build_dir, filename)
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
359 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
360 for filename in filenames
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
361 ]
f49471953689 Add support for package data.
Fred Drake <fdrake@acm.org>
parents: 28114
diff changeset
362
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
363 return outputs
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
364
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
365
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
366 def build_module (self, module, module_file, package):
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
367 if type(package) is StringType:
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
368 package = string.split(package, '.')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
369 elif type(package) not in (ListType, TupleType):
11521
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
370 raise TypeError, \
ba07fff72511 [from 1999-11-04]
Greg Ward <gward@python.net>
parents: 11365
diff changeset
371 "'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
372
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
373 # 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
374 # 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
375 # directory for Python source).
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
376 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
377 dir = os.path.dirname(outfile)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
378 self.mkpath(dir)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
379 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
380
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
381
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
382 def build_modules (self):
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
383
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
384 modules = self.find_modules()
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
385 for (package, module, module_file) in modules:
11339
6f7507ef2b11 Renamed 'dir' option to be consistent with other commands.
Greg Ward <gward@python.net>
parents: 11299
diff changeset
386
11299
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
387 # 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
388 # 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
389 # (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
390 # under self.build_lib.)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
391 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
392
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
393 # build_modules ()
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
394
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
395
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
396 def build_packages (self):
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
397
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
398 for package in self.packages:
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
399
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
400 # 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
401 # scanning the package directory. 'package' is only included
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
402 # in the tuple so that 'find_modules()' and
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
403 # '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
404 # 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
405 # 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
406 # 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
407 # the .py file, relative to the current directory
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
408 # (ie. including 'package_dir').
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
409 package_dir = self.get_package_dir(package)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
410 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
411
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
412 # 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
413 # copy it to self.build_lib).
12094
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
414 for (package_, module, module_file) in modules:
8d1c69bdc4f2 Deleted some crufty comments and code.
Greg Ward <gward@python.net>
parents: 11903
diff changeset
415 assert package == package_
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14943
diff changeset
416 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
417
6d646f7e1a1c Basically a complete rewrite to support dealing with modules in whole
Greg Ward <gward@python.net>
parents: 11280
diff changeset
418 # build_packages ()
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
419
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
420
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
421 def byte_compile (self, files):
58205
ac4931ab0369 Merged revisions 75669-75671 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 48260
diff changeset
422 if sys.dont_write_bytecode:
ac4931ab0369 Merged revisions 75669-75671 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 48260
diff changeset
423 self.warn('byte-compiling is disabled, skipping.')
ac4931ab0369 Merged revisions 75669-75671 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 48260
diff changeset
424 return
ac4931ab0369 Merged revisions 75669-75671 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 48260
diff changeset
425
14963
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
426 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
427 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
428 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
429 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
430
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
431 # 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
432 # 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
433 # 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
434
73d09322f2c3 Added the ability to do byte-compilation at build time, currently off
Greg Ward <gward@python.net>
parents: 14948
diff changeset
435 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
436 byte_compile(files, optimize=0,
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22833
diff changeset
437 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
438 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
439 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
440 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
441
12743
e878a647e06e Normalized all the end-of-class lines.
Greg Ward <gward@python.net>
parents: 12318
diff changeset
442 # class build_py