Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 1 | """distutils.command.build |
| 2 | |
| 3 | Implements the Distutils 'build' command.""" |
| 4 | |
| 5 | # created 1999/03/08, Greg Ward |
| 6 | |
| 7 | __rcsid__ = "$Id$" |
| 8 | |
| 9 | import os |
| 10 | from distutils.core import Command |
| 11 | |
| 12 | |
| 13 | class 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 Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 18 | ] |
| 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 Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 27 | 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 Ward | 36e68e2 | 1999-09-13 13:52:12 +0000 | [diff] [blame] | 33 | self.platdir = os.path.join (self.basedir, 'platlib') |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 34 | |
| 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 Ward | 02e1c56 | 1999-09-21 18:27:55 +0000 | [diff] [blame] | 43 | # 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 Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 47 | |
Greg Ward | 02e1c56 | 1999-09-21 18:27:55 +0000 | [diff] [blame] | 48 | # 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 Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 52 | |
| 53 | # end class Build |