blob: 82a4e6c292f688a210c07a6b667f77cdc72a8a93 [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
13class Build (Command):
14
Greg Ward37bc8152000-01-30 18:34:15 +000015 description = "build everything needed to install"
16
Greg Warde6ac2fc1999-09-29 12:38:18 +000017 options = [('build-base=', 'b',
18 "base directory for build library"),
19 ('build-lib=', 'l',
20 "directory for platform-shared files"),
21 ('build-platlib=', 'p',
22 "directory for platform-specific files"),
Greg Ward32462002000-02-09 02:19:49 +000023 ('debug', 'g',
24 "compile extensions and libraries with debugging information"),
Greg Ward13ae1c81999-03-22 14:55:25 +000025 ]
26
27 def set_default_options (self):
Greg Warde6ac2fc1999-09-29 12:38:18 +000028 self.build_base = 'build'
29 # these are decided only after 'build_base' has its final value
Greg Ward13ae1c81999-03-22 14:55:25 +000030 # (unless overridden by the user or client)
Greg Warde6ac2fc1999-09-29 12:38:18 +000031 self.build_lib = None
32 self.build_platlib = None
Greg Ward32462002000-02-09 02:19:49 +000033 self.debug = None
Greg Ward13ae1c81999-03-22 14:55:25 +000034
Greg Ward13ae1c81999-03-22 14:55:25 +000035 def set_final_options (self):
Greg Warde6ac2fc1999-09-29 12:38:18 +000036 # 'build_lib' and 'build_platlib' just default to 'lib' and
37 # 'platlib' under the base build directory
38 if self.build_lib is None:
39 self.build_lib = os.path.join (self.build_base, 'lib')
40 if self.build_platlib is None:
41 self.build_platlib = os.path.join (self.build_base, 'platlib')
Greg Ward13ae1c81999-03-22 14:55:25 +000042
43
44 def run (self):
45
Greg Ward13ae1c81999-03-22 14:55:25 +000046 # For now, "build" means "build_py" then "build_ext". (Eventually
47 # it should also build documentation.)
48
Greg Ward02e1c561999-09-21 18:27:55 +000049 # Invoke the 'build_py' command to "build" pure Python modules
50 # (ie. copy 'em into the build tree)
51 if self.distribution.packages or self.distribution.py_modules:
52 self.run_peer ('build_py')
Greg Ward13ae1c81999-03-22 14:55:25 +000053
Greg Ward5f7c18e2000-02-05 02:24:16 +000054 # Build any standalone C libraries next -- they're most likely to
55 # be needed by extension modules, so obviously have to be done
56 # first!
57 if self.distribution.libraries:
58 self.run_peer ('build_lib')
59
Greg Ward02e1c561999-09-21 18:27:55 +000060 # And now 'build_ext' -- compile extension modules and put them
61 # into the build tree
62 if self.distribution.ext_modules:
63 self.run_peer ('build_ext')
Greg Ward13ae1c81999-03-22 14:55:25 +000064
65# end class Build