release.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 contains mostly customization for the
  14. 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' directory and those files will be then
  27. # 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"), "for signing.")
  32. cmd.extend(['--local-user', getenv("PYINSTALLER_CODESIGNING_ID")])
  33. # Sign all files in 'dist' directory.
  34. for f in os.listdir(dist_dir):
  35. f = os.path.join(dist_dir, f)
  36. print('Signing file %s' % f)
  37. exec_command(*cmd + [f])