source: waf @ ce6f652

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since ce6f652 was 904702d, checked in by Paul Brossier <piem@piem.org>, 10 years ago

waf, waflib: update to 1.8.7

  • Property mode set to 100755
File size: 4.0 KB
Line 
1#!/usr/bin/env python
2# encoding: ISO8859-1
3# Thomas Nagy, 2005-2015
4
5"""
6Redistribution and use in source and binary forms, with or without
7modification, are permitted provided that the following conditions
8are met:
9
101. Redistributions of source code must retain the above copyright
11   notice, this list of conditions and the following disclaimer.
12
132. Redistributions in binary form must reproduce the above copyright
14   notice, this list of conditions and the following disclaimer in the
15   documentation and/or other materials provided with the distribution.
16
173. The name of the author may not be used to endorse or promote products
18   derived from this software without specific prior written permission.
19
20THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
21IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30POSSIBILITY OF SUCH DAMAGE.
31"""
32
33import os, sys, inspect
34
35VERSION="1.8.7"
36REVISION="073060339ba56c09e143ed641610cbec"
37GIT="x"
38INSTALL=''
39C1='#/'
40C2='#-'
41C3='#+'
42cwd = os.getcwd()
43join = os.path.join
44
45
46WAF='waf'
47def b(x):
48        return x
49if sys.hexversion>0x300000f:
50        WAF='waf3'
51        def b(x):
52                return x.encode()
53
54def err(m):
55        print(('\033[91mError: %s\033[0m' % m))
56        sys.exit(1)
57
58def unpack_wafdir(dir, src):
59        f = open(src,'rb')
60        c = 'corrupt archive (%d)'
61        while 1:
62                line = f.readline()
63                if not line: err('run waf-light from a folder containing waflib')
64                if line == b('#==>\n'):
65                        txt = f.readline()
66                        if not txt: err(c % 1)
67                        if f.readline() != b('#<==\n'): err(c % 2)
68                        break
69        if not txt: err(c % 3)
70        txt = txt[1:-1].replace(b(C1), b('\n')).replace(b(C2), b('\r')).replace(b(C3), b('\x00'))
71
72        import shutil, tarfile
73        try: shutil.rmtree(dir)
74        except OSError: pass
75        try:
76                for x in ('Tools', 'extras'):
77                        os.makedirs(join(dir, 'waflib', x))
78        except OSError:
79                err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
80
81        os.chdir(dir)
82        tmp = 't.bz2'
83        t = open(tmp,'wb')
84        try: t.write(txt)
85        finally: t.close()
86
87        try:
88                t = tarfile.open(tmp)
89        except:
90                try:
91                        os.system('bunzip2 t.bz2')
92                        t = tarfile.open('t')
93                        tmp = 't'
94                except:
95                        os.chdir(cwd)
96                        try: shutil.rmtree(dir)
97                        except OSError: pass
98                        err("Waf cannot be unpacked, check that bzip2 support is present")
99
100        try:
101                for x in t: t.extract(x)
102        finally:
103                t.close()
104
105        for x in ('Tools', 'extras'):
106                os.chmod(join('waflib',x), 493)
107
108        if sys.hexversion<0x300000f:
109                sys.path = [join(dir, 'waflib')] + sys.path
110                import fixpy2
111                fixpy2.fixdir(dir)
112
113        os.remove(tmp)
114        os.chdir(cwd)
115
116        try: dir = unicode(dir, 'mbcs')
117        except: pass
118        try:
119                from ctypes import windll
120                windll.kernel32.SetFileAttributesW(dir, 2)
121        except:
122                pass
123
124def test(dir):
125        try:
126                os.stat(join(dir, 'waflib'))
127                return os.path.abspath(dir)
128        except OSError:
129                pass
130
131def find_lib():
132        src = os.path.abspath(inspect.getfile(inspect.getmodule(err)))
133        base, name = os.path.split(src)
134
135        #devs use $WAFDIR
136        w=test(os.environ.get('WAFDIR', ''))
137        if w: return w
138
139        #waf-light
140        if name.endswith('waf-light'):
141                w = test(base)
142                if w: return w
143                err('waf-light requires waflib -> export WAFDIR=/folder')
144
145        dirname = '%s-%s-%s' % (WAF, VERSION, REVISION)
146        for i in (INSTALL,'/usr','/usr/local','/opt'):
147                w = test(i + '/lib/' + dirname)
148                if w: return w
149
150        #waf-local
151        dir = join(base, (sys.platform != 'win32' and '.' or '') + dirname)
152        w = test(dir)
153        if w: return w
154
155        #unpack
156        unpack_wafdir(dir, src)
157        return dir
158
159wafdir = find_lib()
160sys.path.insert(0, wafdir)
161
162if __name__ == '__main__':
163
164        from waflib import Scripting
165        Scripting.waf_entry_point(cwd, VERSION, wafdir)
166
Note: See TracBrowser for help on using the repository browser.