1#-----------------------------------------------------------------------------
2# Copyright (c) 2005-2019, PyInstaller Development Team.
3#
4# Distributed under the terms of the GNU General Public License with exception
5# for distributing bootloader.
6#
7# The full license is in the file COPYING.txt, distributed with this software.
8#-----------------------------------------------------------------------------
9
10
11__all__ = ('HOMEPATH', 'PLATFORM', '__version__')
12
13import os
14import sys
15
16from . import compat
17from .compat import is_win, is_py2
18from .utils.git import get_repo_revision
19
20
21# Note: Keep this variable as plain string so it could be updated automatically
22#       when doing a release.
23__version__ = '3.5'
24
25
26# Absolute path of this package's directory. Save this early so all
27# submodules can use the absolute path. This is required e.g. if the
28# current directorey changes prior to loading the hooks.
29PACKAGEPATH = os.path.abspath(os.path.dirname(__file__))
30
31HOMEPATH = os.path.dirname(PACKAGEPATH)
32if is_win and is_py2:
33    # This ensures for Python 2 that PyInstaller will work on Windows
34    # with paths containing foreign characters.
35    try:
36        unicode(HOMEPATH)
37    except UnicodeDecodeError:
38        # Do conversion to ShortPathName really only in case HOMEPATH is not
39        # ascii only - conversion to unicode type cause this unicode error.
40        try:
41            HOMEPATH = compat.win32api.GetShortPathName(HOMEPATH)
42        except ImportError:
43            pass
44
45
46# Update __version__ as necessary.
47if os.path.exists(os.path.join(HOMEPATH, 'setup.py')):
48    # PyInstaller is run directly from source without installation or
49    # __version__ is called from 'setup.py' ...
50    if compat.getenv('PYINSTALLER_DO_RELEASE') == '1':
51        # Suppress the git revision when doing a release.
52        pass
53    elif 'sdist' not in sys.argv:
54        # and 'setup.py' was not called with 'sdist' argument.
55        # For creating source tarball we do not want git revision
56        # in the filename.
57        try:
58            __version__ += get_repo_revision()
59        except Exception:
60            # Write to stderr because stdout is used for eval() statement
61            # in some subprocesses.
62            sys.stderr.write('WARN: failed to parse git revision')
63else:
64    # PyInstaller was installed by `python setup.py install'.
65    import pkg_resources
66    __version__ = pkg_resources.get_distribution('PyInstaller').version
67
68
69## Default values of paths where to put files created by PyInstaller.
70## Mind option-help in build_main when changes these
71# Folder where to put created .spec file.
72DEFAULT_SPECPATH = compat.getcwd()
73# Folder where to put created .spec file.
74# Where to put the final app.
75DEFAULT_DISTPATH = os.path.join(compat.getcwd(), 'dist')
76# Where to put all the temporary work files, .log, .pyz and etc.
77DEFAULT_WORKPATH = os.path.join(compat.getcwd(), 'build')
78
79
80PLATFORM = compat.system + '-' + compat.architecture
81# Include machine name in path to bootloader for some machines.
82# e.g. 'arm'
83if compat.machine:
84    PLATFORM += '-' + compat.machine
85