comparison contrib/packaging/hgpackaging/util.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents 9c07d345fd6d
children d053d3f10b6a
comparison
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
30 """Finds Visual C++ Runtime DLLs to include in distribution.""" 30 """Finds Visual C++ Runtime DLLs to include in distribution."""
31 winsxs = pathlib.Path(os.environ['SYSTEMROOT']) / 'WinSxS' 31 winsxs = pathlib.Path(os.environ['SYSTEMROOT']) / 'WinSxS'
32 32
33 prefix = 'amd64' if x64 else 'x86' 33 prefix = 'amd64' if x64 else 'x86'
34 34
35 candidates = sorted(p for p in os.listdir(winsxs) 35 candidates = sorted(
36 if p.lower().startswith('%s_microsoft.vc90.crt_' % prefix)) 36 p
37 for p in os.listdir(winsxs)
38 if p.lower().startswith('%s_microsoft.vc90.crt_' % prefix)
39 )
37 40
38 for p in candidates: 41 for p in candidates:
39 print('found candidate VC runtime: %s' % p) 42 print('found candidate VC runtime: %s' % p)
40 43
41 # Take the newest version. 44 # Take the newest version.
70 return { 73 return {
71 'root': base, 74 'root': base,
72 'version': version, 75 'version': version,
73 'bin_root': bin_version, 76 'bin_root': bin_version,
74 'bin_x86': bin_version / 'x86', 77 'bin_x86': bin_version / 'x86',
75 'bin_x64': bin_version / 'x64' 78 'bin_x64': bin_version / 'x64',
76 } 79 }
77 80
78 81
79 def find_signtool(): 82 def find_signtool():
80 """Find signtool.exe from the Windows SDK.""" 83 """Find signtool.exe from the Windows SDK."""
87 return p 90 return p
88 91
89 raise Exception('could not find signtool.exe in Windows 10 SDK') 92 raise Exception('could not find signtool.exe in Windows 10 SDK')
90 93
91 94
92 def sign_with_signtool(file_path, description, subject_name=None, 95 def sign_with_signtool(
93 cert_path=None, cert_password=None, 96 file_path,
94 timestamp_url=None): 97 description,
98 subject_name=None,
99 cert_path=None,
100 cert_password=None,
101 timestamp_url=None,
102 ):
95 """Digitally sign a file with signtool.exe. 103 """Digitally sign a file with signtool.exe.
96 104
97 ``file_path`` is file to sign. 105 ``file_path`` is file to sign.
98 ``description`` is text that goes in the signature. 106 ``description`` is text that goes in the signature.
99 107
112 120
113 while cert_path and not cert_password: 121 while cert_path and not cert_password:
114 cert_password = getpass.getpass('password for %s: ' % cert_path) 122 cert_password = getpass.getpass('password for %s: ' % cert_path)
115 123
116 args = [ 124 args = [
117 str(find_signtool()), 'sign', 125 str(find_signtool()),
126 'sign',
118 '/v', 127 '/v',
119 '/fd', 'sha256', 128 '/fd',
120 '/d', description, 129 'sha256',
130 '/d',
131 description,
121 ] 132 ]
122 133
123 if cert_path: 134 if cert_path:
124 args.extend(['/f', str(cert_path), '/p', cert_password]) 135 args.extend(['/f', str(cert_path), '/p', cert_password])
125 elif subject_name: 136 elif subject_name: