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 | |
Greg Ward | 37bc815 | 2000-01-30 18:34:15 +0000 | [diff] [blame^] | 15 | description = "build everything needed to install" |
| 16 | |
Greg Ward | e6ac2fc | 1999-09-29 12:38:18 +0000 | [diff] [blame] | 17 | 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 Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 23 | ] |
| 24 | |
| 25 | def set_default_options (self): |
Greg Ward | e6ac2fc | 1999-09-29 12:38:18 +0000 | [diff] [blame] | 26 | self.build_base = 'build' |
| 27 | # these are decided only after 'build_base' has its final value |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 28 | # (unless overridden by the user or client) |
Greg Ward | e6ac2fc | 1999-09-29 12:38:18 +0000 | [diff] [blame] | 29 | self.build_lib = None |
| 30 | self.build_platlib = None |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 31 | |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 32 | def set_final_options (self): |
Greg Ward | e6ac2fc | 1999-09-29 12:38:18 +0000 | [diff] [blame] | 33 | # 'build_lib' and 'build_platlib' just default to 'lib' and |
| 34 | # 'platlib' under the base build directory |
| 35 | if self.build_lib is None: |
| 36 | self.build_lib = os.path.join (self.build_base, 'lib') |
| 37 | if self.build_platlib is None: |
| 38 | self.build_platlib = os.path.join (self.build_base, 'platlib') |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 39 | |
| 40 | |
| 41 | def run (self): |
| 42 | |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 43 | # For now, "build" means "build_py" then "build_ext". (Eventually |
| 44 | # it should also build documentation.) |
| 45 | |
Greg Ward | 02e1c56 | 1999-09-21 18:27:55 +0000 | [diff] [blame] | 46 | # Invoke the 'build_py' command to "build" pure Python modules |
| 47 | # (ie. copy 'em into the build tree) |
| 48 | if self.distribution.packages or self.distribution.py_modules: |
| 49 | self.run_peer ('build_py') |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 50 | |
Greg Ward | 02e1c56 | 1999-09-21 18:27:55 +0000 | [diff] [blame] | 51 | # And now 'build_ext' -- compile extension modules and put them |
| 52 | # into the build tree |
| 53 | if self.distribution.ext_modules: |
| 54 | self.run_peer ('build_ext') |
Greg Ward | 13ae1c8 | 1999-03-22 14:55:25 +0000 | [diff] [blame] | 55 | |
| 56 | # end class Build |