__init__.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-2021, PyInstaller Development Team.
  3. #
  4. # Distributed under the terms of the GNU General Public License (version 2
  5. # or later) with exception for distributing the bootloader.
  6. #
  7. # The full license is in the file COPYING.txt, distributed with this software.
  8. #
  9. # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
  10. #-----------------------------------------------------------------------------
  11. __all__ = ('HOMEPATH', 'PLATFORM', '__version__')
  12. import os
  13. import sys
  14. from PyInstaller import compat
  15. from PyInstaller.utils.git import get_repo_revision
  16. # Note: Keep this variable as plain string so it could be updated automatically
  17. # when doing a release.
  18. __version__ = '4.5.1'
  19. # Absolute path of this package's directory. Save this early so all
  20. # submodules can use the absolute path. This is required e.g. if the
  21. # current directory changes prior to loading the hooks.
  22. PACKAGEPATH = os.path.abspath(os.path.dirname(__file__))
  23. HOMEPATH = os.path.dirname(PACKAGEPATH)
  24. # Update __version__ as necessary.
  25. if os.path.exists(os.path.join(HOMEPATH, 'setup.py')):
  26. # PyInstaller is run directly from source without installation or
  27. # __version__ is called from 'setup.py' ...
  28. if compat.getenv('PYINSTALLER_DO_RELEASE') == '1':
  29. # Suppress the git revision when doing a release.
  30. pass
  31. elif 'sdist' not in sys.argv:
  32. # and 'setup.py' was not called with 'sdist' argument.
  33. # For creating source tarball we do not want git revision
  34. # in the filename.
  35. try:
  36. __version__ += get_repo_revision()
  37. except Exception:
  38. # Write to stderr because stdout is used for eval() statement
  39. # in some subprocesses.
  40. sys.stderr.write('WARN: failed to parse git revision')
  41. else:
  42. # PyInstaller was installed by `python setup.py install'.
  43. import pkg_resources
  44. __version__ = pkg_resources.get_distribution('PyInstaller').version
  45. ## Default values of paths where to put files created by PyInstaller.
  46. ## Mind option-help in build_main when changes these
  47. # Folder where to put created .spec file.
  48. DEFAULT_SPECPATH = os.getcwd()
  49. # Folder where to put created .spec file.
  50. # Where to put the final app.
  51. DEFAULT_DISTPATH = os.path.join(os.getcwd(), 'dist')
  52. # Where to put all the temporary work files, .log, .pyz and etc.
  53. DEFAULT_WORKPATH = os.path.join(os.getcwd(), 'build')
  54. PLATFORM = compat.system + '-' + compat.architecture
  55. # Include machine name in path to bootloader for some machines (e.g., 'arm').
  56. # Explicitly avoid doing this on macOS, where we keep universal2 bootloaders
  57. # in Darwin-64bit folder regardless of whether we are on x86_64 or arm64.
  58. if compat.machine and not compat.is_darwin:
  59. PLATFORM += '-' + compat.machine