blob: 1586e60b07145d2c10efd8c5e438db1f74fe658a [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 Warde6ac2fc1999-09-29 12:38:18 +000015 options = [('build-base=', 'b',
16 "base directory for build library"),
17 ('build-lib=', 'l',
18 "directory for platform-shared files"),
19 ('build-platlib=', 'p',
20 "directory for platform-specific files"),
Greg Ward13ae1c81999-03-22 14:55:25 +000021 ]
22
23 def set_default_options (self):
Greg Warde6ac2fc1999-09-29 12:38:18 +000024 self.build_base = 'build'
25 # these are decided only after 'build_base' has its final value
Greg Ward13ae1c81999-03-22 14:55:25 +000026 # (unless overridden by the user or client)
Greg Warde6ac2fc1999-09-29 12:38:18 +000027 self.build_lib = None
28 self.build_platlib = None
Greg Ward13ae1c81999-03-22 14:55:25 +000029
Greg Ward13ae1c81999-03-22 14:55:25 +000030 def set_final_options (self):
Greg Warde6ac2fc1999-09-29 12:38:18 +000031 # 'build_lib' and 'build_platlib' just default to 'lib' and
32 # 'platlib' under the base build directory
33 if self.build_lib is None:
34 self.build_lib = os.path.join (self.build_base, 'lib')
35 if self.build_platlib is None:
36 self.build_platlib = os.path.join (self.build_base, 'platlib')
Greg Ward13ae1c81999-03-22 14:55:25 +000037
38
39 def run (self):
40
Greg Ward13ae1c81999-03-22 14:55:25 +000041 # For now, "build" means "build_py" then "build_ext". (Eventually
42 # it should also build documentation.)
43
Greg Ward02e1c561999-09-21 18:27:55 +000044 # Invoke the 'build_py' command to "build" pure Python modules
45 # (ie. copy 'em into the build tree)
46 if self.distribution.packages or self.distribution.py_modules:
47 self.run_peer ('build_py')
Greg Ward13ae1c81999-03-22 14:55:25 +000048
Greg Ward02e1c561999-09-21 18:27:55 +000049 # And now 'build_ext' -- compile extension modules and put them
50 # into the build tree
51 if self.distribution.ext_modules:
52 self.run_peer ('build_ext')
Greg Ward13ae1c81999-03-22 14:55:25 +000053
54# end class Build