我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用cx_Freeze.setup()。
def wrapped_cmd(cmd): class Command(cmd): def run(self): if 'src' not in sys.path: sys.path.append('src') from transpyler.jupyter.setup import setup_assets setup_assets(True) cmd.run(self) return Command # Run setup() function
def setup(*args, **kwargs): # Checking preconditions and such signtool_path = get_windows_signtool_path() print('Using this signtool:', signtool_path) pfx_path = glob.glob(os.path.join('..', '*.pfx')) if len(pfx_path) != 1: raise RuntimeError('Expected to find exactly one PFX in the outer dir, found this: %r' % pfx_path) pfx_path = pfx_path[0] print('Using this certificate:', pfx_path) pfx_password = input('Enter password to read the certificate file: ').strip() # Freezing cx_Freeze.setup(*args, **kwargs) # Code signing the outputs print('Signing the outputs...') for out in glob.glob(os.path.join('dist', '*.msi')): out_copy = '.signed.'.join(out.rsplit('.', 1)) try: shutil.rmtree(out_copy) except Exception: pass shutil.copy(out, out_copy) print('Signing file:', out_copy) while True: try: subprocess.check_call([signtool_path, 'sign', '/f', pfx_path, '/p', pfx_password, '/t', WINDOWS_SIGNATURE_TIMESTAMPING_SERVER, out_copy]) except Exception as ex: print('SignTool failed:', ex) if input('Try again? y/[n] ').lower().strip()[0] == 'y': pass else: raise else: break print('All files were signed successfully')