File: create_build.py

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (55 lines) | stat: -rw-r--r-- 1,668 bytes parent folder | download | duplicates (6)
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
# Copyright Bruno da Silva de Oliveira 2006. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

import os
import sys
import shutil
import fnmatch
from zipfile import ZipFile, ZIP_DEFLATED

def findfiles(directory, mask):
    def visit(files, dir, names):
        for name in names:
            if fnmatch.fnmatch(name, mask):
                files.append(os.path.join(dir, name))
    files = []
    os.path.walk(directory, visit, files)
    return files
                
        
def main():
    # test if PyXML is installed
    try:
        import _xmlplus.parsers.expat
        pyxml = '--includes _xmlplus.parsers.expat'
    except ImportError:
        pyxml = ''
    # create exe
    status = os.system('python setup.py py2exe %s >& build.log' % pyxml)
    if status != 0:
        raise RuntimeError, 'Error creating EXE'

    # create distribution
    import pyste
    version = pyste.__VERSION__
    zip = ZipFile('pyste-%s.zip' % version, 'w', ZIP_DEFLATED)    
    # include the base files
    dist_dir = 'dist/pyste'
    for basefile in os.listdir(dist_dir):
        zip.write(os.path.join(dist_dir, basefile), os.path.join('pyste', basefile))
    # include documentation
    for doc_file in findfiles('../doc', '*.*'):
        dest_name = os.path.join('pyste/doc', doc_file[3:])
        zip.write(doc_file, dest_name)
    zip.write('../index.html', 'pyste/doc/index.html')
    zip.close()
    # cleanup
    os.remove('build.log')
    shutil.rmtree('build')
    shutil.rmtree('dist')
    

if __name__ == '__main__':
    sys.path.append('../src')
    main()