blob: 28241e104fb9d04df435b86e1a685ddcf44ba3b0 [file] [log] [blame]
Greg Ward13ae1c81999-03-22 14:55:25 +00001"""distutils.command.build
2
3Implements the Distutils 'build' command."""
4
5# created 1999/03/08, Greg Ward
6
7__rcsid__ = "$Id$"
8
9import os
10from distutils.core import Command
11
12
Greg Ward1993f9a2000-02-18 00:13:53 +000013class build (Command):
Greg Ward13ae1c81999-03-22 14:55:25 +000014
Greg Ward37bc8152000-01-30 18:34:15 +000015 description = "build everything needed to install"
16
Greg Wardbbeceea2000-02-18 00:25:39 +000017 user_options = [
18 ('build-base=', 'b',
19 "base directory for build library"),
20 ('build-lib=', 'l',
21 "directory for platform-shared files"),
22 ('build-platlib=', 'p',
23 "directory for platform-specific files"),
24 ('debug', 'g',
25 "compile extensions and libraries with debugging information"),
26 ]
Greg Ward13ae1c81999-03-22 14:55:25 +000027
Greg Warde01149c2000-02-18 00:35:22 +000028 def initialize_options (self):
Greg Warde6ac2fc1999-09-29 12:38:18 +000029 self.build_base = 'build'
30 # these are decided only after 'build_base' has its final value
Greg Ward13ae1c81999-03-22 14:55:25 +000031 # (unless overridden by the user or client)
Greg Warde6ac2fc1999-09-29 12:38:18 +000032 self.build_lib = None
33 self.build_platlib = None
Greg Ward32462002000-02-09 02:19:49 +000034 self.debug = None
Greg Ward13ae1c81999-03-22 14:55:25 +000035
Greg Warde01149c2000-02-18 00:35:22 +000036 def finalize_options (self):
Greg Warde6ac2fc1999-09-29 12:38:18 +000037 # 'build_lib' and 'build_platlib' just default to 'lib' and
38 # 'platlib' under the base build directory
39 if self.build_lib is None:
40 self.build_lib = os.path.join (self.build_base, 'lib')
41 if self.build_platlib is None:
42 self.build_platlib = os.path.join (self.build_base, 'platlib')
Greg Ward13ae1c81999-03-22 14:55:25 +000043
44
45 def run (self):
46
Greg Ward13ae1c81999-03-22 14:55:25 +000047 # For now, "build" means "build_py" then "build_ext". (Eventually
48 # it should also build documentation.)
49
Greg Ward02e1c561999-09-21 18:27:55 +000050 # Invoke the 'build_py' command to "build" pure Python modules
51 # (ie. copy 'em into the build tree)
52 if self.distribution.packages or self.distribution.py_modules:
53 self.run_peer ('build_py')
Greg Ward13ae1c81999-03-22 14:55:25 +000054
Greg Ward5f7c18e2000-02-05 02:24:16 +000055 # Build any standalone C libraries next -- they're most likely to
56 # be needed by extension modules, so obviously have to be done
57 # first!
58 if self.distribution.libraries:
59 self.run_peer ('build_lib')
60
Greg Ward02e1c561999-09-21 18:27:55 +000061 # And now 'build_ext' -- compile extension modules and put them
62 # into the build tree
63 if self.distribution.ext_modules:
64 self.run_peer ('build_ext')
Greg Ward13ae1c81999-03-22 14:55:25 +000065
66# end class Build