source: project/pyinstaller.py @ 0e2dbf4

Revision 0e2dbf4, 2.7 KB checked in by Martin Zibricky <mzibr.public@gmail.com>, 3 months ago (diff)

Merge branch feature-485-junit_xml into develop.

  • Property mode set to 100755
Line 
1#! /usr/bin/env python
2#
3# Wrapper around Configure.py / Makespec.py / Build.py
4#
5# Copyright (C) 2010, Martin Zibricky
6# Copyright (C) 2011, Hartmut Goebel
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version 2
11# of the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
21
22import os
23import optparse
24
25import PyInstaller.makespec
26import PyInstaller.build
27import PyInstaller.compat
28import PyInstaller.log
29
30
31# Warn when old command line option is used
32
33from PyInstaller import get_version
34from PyInstaller.log import logger
35
36
37def run_makespec(opts, args):
38    # Split pathex by using the path separator
39    temppaths = opts.pathex[:]
40    opts.pathex = []
41    for p in temppaths:
42        opts.pathex.extend(p.split(os.pathsep))
43
44    spec_file = PyInstaller.makespec.main(args, **opts.__dict__)
45    logger.info('wrote %s' % spec_file)
46    return spec_file
47
48
49def run_build(opts, spec_file):
50    PyInstaller.build.main(spec_file, **opts.__dict__)
51
52
53def __add_options(parser):
54    parser.add_option('-v', '--version', default=False, action='store_true',
55                      help='show program version')
56
57
58def main():
59    parser = optparse.OptionParser(
60        usage='python %prog [opts] <scriptname> [ <scriptname> ...] | <specfile>'
61        )
62    __add_options(parser)
63    PyInstaller.makespec.__add_options(parser)
64    PyInstaller.build.__add_options(parser)
65    PyInstaller.log.__add_options(parser)
66    PyInstaller.compat.__add_obsolete_options(parser)
67
68    opts, args = parser.parse_args()
69    PyInstaller.log.__process_options(parser, opts)
70
71    # Print program version and exit
72    if opts.version:
73        print get_version()
74        raise SystemExit(0)
75
76    if not args:
77        parser.error('Requires at least one scriptname file '
78                     'or exactly one .spec-file')
79
80    # Skip creating .spec when .spec file is supplied
81    if args[0].endswith('.spec'):
82        spec_file = args[0]
83    else:
84        spec_file = run_makespec(opts, args)
85
86    run_build(opts, spec_file)
87
88
89if __name__ == '__main__':
90    try:
91        main()
92    except KeyboardInterrupt:
93        raise SystemExit("Aborted by user request.")
Note: See TracBrowser for help on using the repository browser.