d664527f8489015bdb010a0c18bb4ee0a15f590f
[scons.git] / src / setup.py
1 #
2 # Copyright (c) 2001, 2002 Steven Knight
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
16 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
17 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
23
24 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
25
26 import os
27 import os.path
28 import sys
29
30 (head, tail) = os.path.split(sys.argv[0])
31
32 if head:
33     os.chdir(head)
34     sys.argv[0] = tail
35
36 from distutils.core import setup
37 from distutils.command.install_lib import install_lib
38
39 class my_install_lib(install_lib):
40     def finalize_options(self):
41         install_lib.finalize_options(self)
42         head = self.install_dir
43         while head:
44             if head == os.sep:
45                 head = None
46                 break
47             else:
48                 head, tail = os.path.split(head)
49             if tail[:6] == "python":
50                 self.install_dir = os.path.join(head, "scons")
51                 # Our original packaging scheme placed the build engine
52                 # in a private library directory that contained the SCons
53                 # version number in the directory name.  Here's how this
54                 # was supported here.  See the Construct file for details
55                 # on other files that would need to be changed to support
56                 # this as well.
57                 #self.install_dir = os.path.join(head, "scons-__VERSION__")
58                 return
59             elif tail[:6] == "Python":
60                 self.install_dir = os.path.join(head, tail)
61                 return
62
63 arguments = {
64     'name'             : "scons",
65     'version'          : "__VERSION__",
66     'packages'         : ["SCons",
67                           "SCons.Node",
68                           "SCons.Scanner",
69                           "SCons.Sig",
70                           "SCons.Script"],
71     'package_dir'      : {'' : 'engine'},
72     'scripts'          : ["script/scons"],
73     'cmdclass'         : {'install_lib' : my_install_lib}
74 }
75
76 try:
77     if sys.argv[1] == "bdist_wininst":
78         arguments['data_files'] = [('.', ["script/scons.bat"])]
79 except IndexError:
80     pass
81
82 apply(setup, (), arguments)