source: waf @ f3bb92c

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

waf, waflib: update to 1.7.13

  • Property mode set to 100755
File size: 3.9 KB
RevLine 
[653ac08]1#!/usr/bin/env python
2# encoding: ISO8859-1
[6ed0f4e]3# Thomas Nagy, 2005-2012
[653ac08]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
34
[c101fe1]35VERSION="1.7.13"
36REVISION="5a064c2686fe54de4e11018d22148cfc"
[653ac08]37INSTALL=''
[c101fe1]38C1='#('
39C2='#$'
[653ac08]40cwd = os.getcwd()
41join = os.path.join
42
43
44WAF='waf'
45def b(x):
46        return x
47if sys.hexversion>0x300000f:
48        WAF='waf3'
49        def b(x):
50                return x.encode()
51
52def err(m):
53        print(('\033[91mError: %s\033[0m' % m))
54        sys.exit(1)
55
56def unpack_wafdir(dir):
57        f = open(sys.argv[0],'rb')
58        c = 'corrupt archive (%d)'
59        while 1:
60                line = f.readline()
61                if not line: err('run waf-light from a folder containing waflib')
62                if line == b('#==>\n'):
63                        txt = f.readline()
64                        if not txt: err(c % 1)
65                        if f.readline() != b('#<==\n'): err(c % 2)
66                        break
67        if not txt: err(c % 3)
68        txt = txt[1:-1].replace(b(C1), b('\n')).replace(b(C2), b('\r'))
69
70        import shutil, tarfile
71        try: shutil.rmtree(dir)
72        except OSError: pass
73        try:
74                for x in ['Tools', 'extras']:
75                        os.makedirs(join(dir, 'waflib', x))
76        except OSError:
[6ed0f4e]77                err("Cannot unpack waf lib into %s\nMove waf in a writable directory" % dir)
[653ac08]78
79        os.chdir(dir)
80        tmp = 't.bz2'
81        t = open(tmp,'wb')
[6ed0f4e]82        try: t.write(txt)
83        finally: t.close()
[653ac08]84
85        try:
86                t = tarfile.open(tmp)
87        except:
88                try:
89                        os.system('bunzip2 t.bz2')
90                        t = tarfile.open('t')
91                        tmp = 't'
92                except:
93                        os.chdir(cwd)
94                        try: shutil.rmtree(dir)
95                        except OSError: pass
96                        err("Waf cannot be unpacked, check that bzip2 support is present")
97
[6ed0f4e]98        try:
99                for x in t: t.extract(x)
100        finally:
101                t.close()
[653ac08]102
103        for x in ['Tools', 'extras']:
104                os.chmod(join('waflib',x), 493)
105
106        if sys.hexversion<0x300000f:
107                sys.path = [join(dir, 'waflib')] + sys.path
108                import fixpy2
109                fixpy2.fixdir(dir)
110
[c101fe1]111        os.remove(tmp)
[653ac08]112        os.chdir(cwd)
113
114        try: dir = unicode(dir, 'mbcs')
115        except: pass
116        try:
117                from ctypes import windll
118                windll.kernel32.SetFileAttributesW(dir, 2)
119        except:
120                pass
121
122def test(dir):
123        try:
124                os.stat(join(dir, 'waflib'))
125                return os.path.abspath(dir)
126        except OSError:
127                pass
128
129def find_lib():
130        name = sys.argv[0]
131        base = os.path.dirname(os.path.abspath(name))
132
133        #devs use $WAFDIR
134        w=test(os.environ.get('WAFDIR', ''))
135        if w: return w
136
137        #waf-light
138        if name.endswith('waf-light'):
139                w = test(base)
140                if w: return w
141                err('waf-light requires waflib -> export WAFDIR=/folder')
142
143        dirname = '%s-%s-%s' % (WAF, VERSION, REVISION)
144        for i in [INSTALL,'/usr','/usr/local','/opt']:
145                w = test(i + '/lib/' + dirname)
146                if w: return w
147
148        #waf-local
149        dir = join(base, (sys.platform != 'win32' and '.' or '') + dirname)
150        w = test(dir)
151        if w: return w
152
153        #unpack
154        unpack_wafdir(dir)
155        return dir
156
157wafdir = find_lib()
158sys.path.insert(0, wafdir)
159
160if __name__ == '__main__':
[6ed0f4e]161
[653ac08]162        from waflib import Scripting
163        Scripting.waf_entry_point(cwd, VERSION, wafdir)
164
Note: See TracBrowser for help on using the repository browser.