blob: b74e51cfea2766eb5bad2c1d3187822b0d05fc12 [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
15 options = [('basedir=', 'b', "base directory for build library"),
16 ('libdir=', 'l', "directory for platform-shared files"),
17 ('platdir=', 'p', "directory for platform-specific files"),
Greg Ward13ae1c81999-03-22 14:55:25 +000018 ]
19
20 def set_default_options (self):
21 self.basedir = 'build'
22 # these are decided only after 'basedir' has its final value
23 # (unless overridden by the user or client)
24 self.libdir = None
25 self.platdir = None
26
Greg Ward13ae1c81999-03-22 14:55:25 +000027 def set_final_options (self):
28 # 'libdir' and 'platdir' just default to 'lib' and 'plat' under
29 # the base build directory
30 if self.libdir is None:
31 self.libdir = os.path.join (self.basedir, 'lib')
32 if self.platdir is None:
Greg Ward36e68e21999-09-13 13:52:12 +000033 self.platdir = os.path.join (self.basedir, 'platlib')
Greg Ward13ae1c81999-03-22 14:55:25 +000034
35
36 def run (self):
37
38 self.set_final_options ()
39
40 # For now, "build" means "build_py" then "build_ext". (Eventually
41 # it should also build documentation.)
42
Greg Ward02e1c561999-09-21 18:27:55 +000043 # Invoke the 'build_py' command to "build" pure Python modules
44 # (ie. copy 'em into the build tree)
45 if self.distribution.packages or self.distribution.py_modules:
46 self.run_peer ('build_py')
Greg Ward13ae1c81999-03-22 14:55:25 +000047
Greg Ward02e1c561999-09-21 18:27:55 +000048 # And now 'build_ext' -- compile extension modules and put them
49 # into the build tree
50 if self.distribution.ext_modules:
51 self.run_peer ('build_ext')
Greg Ward13ae1c81999-03-22 14:55:25 +000052
53# end class Build