summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/command/build.py
blob: bcbb9332e4e237d5aeb7659b40c1c2b214f08839 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""distutils.command.build

Implements the Distutils 'build' command."""

# created 1999/03/08, Greg Ward

__rcsid__ = "$Id$"

import os
from distutils.core import Command


class build (Command):

    description = "build everything needed to install"

    options = [('build-base=', 'b',
                "base directory for build library"),
               ('build-lib=', 'l',
                "directory for platform-shared files"),
               ('build-platlib=', 'p',
                "directory for platform-specific files"),
               ('debug', 'g',
                "compile extensions and libraries with debugging information"),
              ]

    def set_default_options (self):
        self.build_base = 'build'
        # these are decided only after 'build_base' has its final value
        # (unless overridden by the user or client)
        self.build_lib = None
        self.build_platlib = None
        self.debug = None

    def set_final_options (self):
        # 'build_lib' and 'build_platlib' just default to 'lib' and
        # 'platlib' under the base build directory
        if self.build_lib is None:
            self.build_lib = os.path.join (self.build_base, 'lib')
        if self.build_platlib is None:
            self.build_platlib = os.path.join (self.build_base, 'platlib')


    def run (self):

        # For now, "build" means "build_py" then "build_ext".  (Eventually
        # it should also build documentation.)

        # Invoke the 'build_py' command to "build" pure Python modules
        # (ie. copy 'em into the build tree)
        if self.distribution.packages or self.distribution.py_modules:
            self.run_peer ('build_py')

        # Build any standalone C libraries next -- they're most likely to
        # be needed by extension modules, so obviously have to be done
        # first!
        if self.distribution.libraries:
            self.run_peer ('build_lib')

        # And now 'build_ext' -- compile extension modules and put them
        # into the build tree
        if self.distribution.ext_modules:
            self.run_peer ('build_ext')

# end class Build