release.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. """
  12. This module contains code useful for doing releases of PyInstaller.
  13. PyInstaller uses package 'zest.releaser' to automate releases. This module
  14. contains mostly customization for the release process.
  15. zest.releaser allows customization by exposing some entry points. For details:
  16. https://zestreleaser.readthedocs.org/en/latest/entrypoints.html
  17. """
  18. import os
  19. from PyInstaller.compat import exec_command, getenv
  20. def sign_source_distribution(data):
  21. """
  22. Sign the tgz or zip archive that will be uploaded to PYPI.
  23. :param data:
  24. """
  25. print()
  26. # zest.releaser does a clean checkout where it generates tgz/zip in 'dist'
  27. # directory and those files will be then uploaded to pypi.
  28. dist_dir = os.path.join(data['tagdir'], 'dist')
  29. cmd = ['gpg', '--detach-sign', '--armor']
  30. if getenv("PYINSTALLER_CODESIGNING_ID"):
  31. print("Using gpg identity", getenv("PYINSTALLER_CODESIGNING_ID"),
  32. "for signing.")
  33. cmd.extend(['--local-user', getenv("PYINSTALLER_CODESIGNING_ID")])
  34. # Sign all files in 'dist' directory.
  35. for f in os.listdir(dist_dir):
  36. f = os.path.join(dist_dir, f)
  37. print('Signing file %s' % f)
  38. exec_command(*cmd + [f])