__init__.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #-----------------------------------------------------------------------------
  2. # Copyright (c) 2005-2022, 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__', 'DEFAULT_DISTPATH', 'DEFAULT_SPECPATH', 'DEFAULT_WORKPATH')
  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 when doing a release.
  17. __version__ = '5.1'
  18. # Absolute path of this package's directory. Save this early so all submodules can use the absolute path. This is
  19. # required for example if the current directory changes prior to loading the hooks.
  20. PACKAGEPATH = os.path.abspath(os.path.dirname(__file__))
  21. HOMEPATH = os.path.dirname(PACKAGEPATH)
  22. # Update __version__ as necessary.
  23. if os.path.exists(os.path.join(HOMEPATH, 'setup.py')):
  24. # PyInstaller is run directly from source without installation, or __version__ is called from 'setup.py'...
  25. if compat.getenv('PYINSTALLER_DO_RELEASE') == '1':
  26. # Suppress the git revision when doing a release.
  27. pass
  28. elif 'sdist' not in sys.argv:
  29. # and 'setup.py' was not called with 'sdist' argument. For creating source tarball we do not want git revision
  30. # in the filename.
  31. try:
  32. __version__ += get_repo_revision()
  33. except Exception:
  34. # Write to stderr because stdout is used for eval() statement in some subprocesses.
  35. sys.stderr.write('WARN: failed to parse git revision')
  36. else:
  37. # PyInstaller was installed by `python setup.py install'.
  38. import pkg_resources
  39. __version__ = pkg_resources.get_distribution('PyInstaller').version
  40. # Default values of paths where to put files created by PyInstaller. If changing these, do not forget to update the
  41. # help text for corresponding command-line options, defined in build_main.
  42. # Where to put created .spec file.
  43. DEFAULT_SPECPATH = os.getcwd()
  44. # Where to put the final frozen application.
  45. DEFAULT_DISTPATH = os.path.join(os.getcwd(), 'dist')
  46. # Where to put all the temporary files; .log, .pyz, etc.
  47. DEFAULT_WORKPATH = os.path.join(os.getcwd(), 'build')
  48. PLATFORM = compat.system + '-' + compat.architecture
  49. # Include machine name in path to bootloader for some machines (e.g., 'arm'). Explicitly avoid doing this on macOS,
  50. # where we keep universal2 bootloaders in Darwin-64bit folder regardless of whether we are on x86_64 or arm64.
  51. if compat.machine and not compat.is_darwin:
  52. PLATFORM += '-' + compat.machine
  53. # Similarly, disambiguate musl Linux from glibc Linux.
  54. if compat.is_musl:
  55. PLATFORM += '-musl'