def build_windows(): """Build windows executables/setups.""" utils.print_title("Updating 3rdparty content") update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False) utils.print_title("Building Windows binaries") parts = str(sys.version_info.major), str(sys.version_info.minor) ver = ''.join(parts) dot_ver = '.'.join(parts) # Get python path from registry if possible try: reg64_key = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Python\PythonCore' r'\{}\InstallPath'.format(dot_ver)) python_x64 = winreg.QueryValueEx(reg64_key, 'ExecutablePath')[0] except FileNotFoundError: python_x64 = r'C:\Python{}\python.exe'.format(ver) out_pyinstaller = os.path.join('dist', 'qutebrowser') out_64 = os.path.join('dist', 'qutebrowser-{}-x64'.format(qutebrowser.__version__)) artifacts = [] from scripts.dev import gen_versioninfo utils.print_title("Updating VersionInfo file") gen_versioninfo.main() utils.print_title("Running pyinstaller 64bit") _maybe_remove(out_64) call_tox('pyinstaller', '-r', python=python_x64) shutil.move(out_pyinstaller, out_64) utils.print_title("Running 64bit smoke test") smoke_test(os.path.join(out_64, 'qutebrowser.exe')) utils.print_title("Building installers") subprocess.run(['makensis.exe', '/DX64', '/DVERSION={}'.format(qutebrowser.__version__), 'misc/qutebrowser.nsi'], check=True) name_64 = 'qutebrowser-{}-amd64.exe'.format(qutebrowser.__version__) artifacts += [ (os.path.join('dist', name_64), 'application/vnd.microsoft.portable-executable', 'Windows 64bit installer'), ] utils.print_title("Zipping 64bit standalone...") name = 'qutebrowser-{}-windows-standalone-amd64'.format( qutebrowser.__version__) shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_64)) artifacts.append(('{}.zip'.format(name), 'application/zip', 'Windows 64bit standalone')) return artifacts
def build_windows(*, gh_token, skip_packaging, only_32bit, only_64bit, debug): """Build windows executables/setups.""" utils.print_title("Updating 3rdparty content") update_3rdparty.run(nsis=True, ace=False, pdfjs=True, fancy_dmg=False, gh_token=gh_token) utils.print_title("Building Windows binaries") artifacts = [] from scripts.dev import gen_versioninfo utils.print_title("Updating VersionInfo file") gen_versioninfo.main() if not only_32bit: artifacts += _build_windows_single( x64=True, skip_packaging=skip_packaging, debug=debug, ) if not only_64bit: artifacts += _build_windows_single( x64=False, skip_packaging=skip_packaging, debug=debug, ) return artifacts
def build_windows( *, gh_token: str, skip_packaging: bool, only_32bit: bool, only_64bit: bool, debug: bool, ) -> List[Artifact]: """Build windows executables/setups.""" utils.print_title("Updating 3rdparty content") # FIXME:qt6 Use modern PDF.js version here update_3rdparty.run(nsis=True, ace=False, pdfjs=True, legacy_pdfjs=True, fancy_dmg=False, gh_token=gh_token) utils.print_title("Building Windows binaries") artifacts = [] from scripts.dev import gen_versioninfo utils.print_title("Updating VersionInfo file") gen_versioninfo.main() if not only_32bit: artifacts += _build_windows_single( x64=True, skip_packaging=skip_packaging, debug=debug, ) if not only_64bit: artifacts += _build_windows_single( x64=False, skip_packaging=skip_packaging, debug=debug, ) return artifacts
def build_mac(*, gh_token, debug): """Build macOS .dmg/.app.""" utils.print_title("Cleaning up...") for f in ['wc.dmg', 'template.dmg']: try: os.remove(f) except FileNotFoundError: pass for d in ['dist', 'build']: shutil.rmtree(d, ignore_errors=True) utils.print_title("Updating 3rdparty content") update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False, gh_token=gh_token) utils.print_title("Building .app via pyinstaller") call_tox('pyinstaller-64', '-r', debug=debug) utils.print_title("Patching .app") patch_mac_app() utils.print_title("Building .dmg") subprocess.run(['make', '-f', 'scripts/dev/Makefile-dmg'], check=True) suffix = "-debug" if debug else "" dmg_path = f'dist/qutebrowser-{qutebrowser.__version__}{suffix}.dmg' os.rename('qutebrowser.dmg', dmg_path) utils.print_title("Running smoke test") try: with tempfile.TemporaryDirectory() as tmpdir: subprocess.run( ['hdiutil', 'attach', dmg_path, '-mountpoint', tmpdir], check=True) try: binary = os.path.join(tmpdir, 'qutebrowser.app', 'Contents', 'MacOS', 'qutebrowser') smoke_test(binary, debug=debug) finally: print("Waiting 10s for dmg to be detachable...") time.sleep(10) subprocess.run(['hdiutil', 'detach', tmpdir], check=False) except PermissionError as e: print("Failed to remove tempdir: {}".format(e)) return [(dmg_path, 'application/x-apple-diskimage', 'macOS .dmg')]
def build_windows(*, skip_packaging, skip_32bit): """Build windows executables/setups.""" utils.print_title("Updating 3rdparty content") update_3rdparty.run(nsis=True, ace=False, pdfjs=True, fancy_dmg=False) utils.print_title("Building Windows binaries") python_x64 = _get_windows_python_path(x64=True) python_x86 = None if skip_32bit else _get_windows_python_path(x64=False) out_pyinstaller = os.path.join('dist', 'qutebrowser') artifacts = [] from scripts.dev import gen_versioninfo utils.print_title("Updating VersionInfo file") gen_versioninfo.main() if skip_32bit: out_32 = None else: utils.print_title("Running pyinstaller 32bit") out_32 = os.path.join( 'dist', 'qutebrowser-{}-x86'.format(qutebrowser.__version__)) _maybe_remove(out_32) call_tox('pyinstaller-32', '-r', python=python_x86) shutil.move(out_pyinstaller, out_32) utils.print_title("Running pyinstaller 64bit") out_64 = os.path.join('dist', 'qutebrowser-{}-x64'.format(qutebrowser.__version__)) _maybe_remove(out_64) call_tox('pyinstaller-64', '-r', python=python_x64) shutil.move(out_pyinstaller, out_64) if not skip_32bit: utils.print_title("Running 32bit smoke test") smoke_test(os.path.join(out_32, 'qutebrowser.exe')) utils.print_title("Running 64bit smoke test") smoke_test(os.path.join(out_64, 'qutebrowser.exe')) if not skip_packaging: artifacts += _package_windows(out_32, out_64) return artifacts
def build_mac(): """Build macOS .dmg/.app.""" utils.print_title("Cleaning up...") for f in ['wc.dmg', 'template.dmg']: try: os.remove(f) except FileNotFoundError: pass for d in ['dist', 'build']: shutil.rmtree(d, ignore_errors=True) utils.print_title("Updating 3rdparty content") update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False) utils.print_title("Building .app via pyinstaller") call_tox('pyinstaller', '-r') utils.print_title("Patching .app") patch_mac_app() utils.print_title("Building .dmg") subprocess.run(['make', '-f', 'scripts/dev/Makefile-dmg'], check=True) dmg_name = 'glimpsebrowser-{}.dmg'.format(glimpsebrowser.__version__) os.rename('glimpsebrowser.dmg', dmg_name) utils.print_title("Running smoke test") try: with tempfile.TemporaryDirectory() as tmpdir: subprocess.run( ['hdiutil', 'attach', dmg_name, '-mountpoint', tmpdir], check=True) try: binary = os.path.join(tmpdir, 'glimpsebrowser.app', 'Contents', 'MacOS', 'glimpsebrowser') smoke_test(binary) finally: time.sleep(5) subprocess.run(['hdiutil', 'detach', tmpdir]) except PermissionError as e: print("Failed to remove tempdir: {}".format(e)) return [(dmg_name, 'application/x-apple-diskimage', 'macOS .dmg')]
def build_mac(): """Build macOS .dmg/.app.""" utils.print_title("Cleaning up...") for f in ['wc.dmg', 'template.dmg']: try: os.remove(f) except FileNotFoundError: pass for d in ['dist', 'build']: shutil.rmtree(d, ignore_errors=True) utils.print_title("Updating 3rdparty content") update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False) utils.print_title("Building .app via pyinstaller") call_tox('pyinstaller', '-r') utils.print_title("Patching .app") patch_mac_app() utils.print_title("Building .dmg") subprocess.run(['make', '-f', 'scripts/dev/Makefile-dmg'], check=True) dmg_name = 'qutebrowser-{}.dmg'.format(qutebrowser.__version__) os.rename('qutebrowser.dmg', dmg_name) utils.print_title("Running smoke test") try: with tempfile.TemporaryDirectory() as tmpdir: subprocess.run(['hdiutil', 'attach', dmg_name, '-mountpoint', tmpdir], check=True) try: binary = os.path.join(tmpdir, 'qutebrowser.app', 'Contents', 'MacOS', 'qutebrowser') smoke_test(binary) finally: time.sleep(5) subprocess.run(['hdiutil', 'detach', tmpdir]) except PermissionError as e: print("Failed to remove tempdir: {}".format(e)) return [(dmg_name, 'application/x-apple-diskimage', 'macOS .dmg')]
def build_windows(): """Build windows executables/setups.""" utils.print_title("Updating 3rdparty content") update_3rdparty.run(nsis=True, ace=False, pdfjs=True, fancy_dmg=False) utils.print_title("Building Windows binaries") python_x64 = _get_windows_python_path(x64=True) python_x86 = _get_windows_python_path(x64=False) out_pyinstaller = os.path.join('dist', 'qutebrowser') out_32 = os.path.join('dist', 'qutebrowser-{}-x86'.format(qutebrowser.__version__)) out_64 = os.path.join('dist', 'qutebrowser-{}-x64'.format(qutebrowser.__version__)) artifacts = [] from scripts.dev import gen_versioninfo utils.print_title("Updating VersionInfo file") gen_versioninfo.main() utils.print_title("Running pyinstaller 32bit") _maybe_remove(out_32) call_tox('pyinstaller', '-r', python=python_x86) shutil.move(out_pyinstaller, out_32) patch_windows(out_32, x64=False) utils.print_title("Running pyinstaller 64bit") _maybe_remove(out_64) call_tox('pyinstaller', '-r', python=python_x64) shutil.move(out_pyinstaller, out_64) patch_windows(out_64, x64=True) utils.print_title("Running 32bit smoke test") smoke_test(os.path.join(out_32, 'qutebrowser.exe')) utils.print_title("Running 64bit smoke test") smoke_test(os.path.join(out_64, 'qutebrowser.exe')) utils.print_title("Building installers") subprocess.run([ 'makensis.exe', '/DVERSION={}'.format(qutebrowser.__version__), 'misc/nsis/qutebrowser.nsi' ], check=True) subprocess.run([ 'makensis.exe', '/DX86', '/DVERSION={}'.format( qutebrowser.__version__), 'misc/nsis/qutebrowser.nsi' ], check=True) name_32 = 'qutebrowser-{}-win32.exe'.format(qutebrowser.__version__) name_64 = 'qutebrowser-{}-amd64.exe'.format(qutebrowser.__version__) artifacts += [ (os.path.join('dist', name_32), 'application/vnd.microsoft.portable-executable', 'Windows 32bit installer'), (os.path.join('dist', name_64), 'application/vnd.microsoft.portable-executable', 'Windows 64bit installer'), ] utils.print_title("Zipping 32bit standalone...") name = 'qutebrowser-{}-windows-standalone-win32'.format( qutebrowser.__version__) shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_32)) artifacts.append( ('{}.zip'.format(name), 'application/zip', 'Windows 32bit standalone')) utils.print_title("Zipping 64bit standalone...") name = 'qutebrowser-{}-windows-standalone-amd64'.format( qutebrowser.__version__) shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_64)) artifacts.append( ('{}.zip'.format(name), 'application/zip', 'Windows 64bit standalone')) return artifacts
def build_mac( *, gh_token: Optional[str], skip_packaging: bool, debug: bool, ) -> List[Artifact]: """Build macOS .dmg/.app.""" utils.print_title("Cleaning up...") for f in ['wc.dmg', 'template.dmg']: try: os.remove(f) except FileNotFoundError: pass for d in ['dist', 'build']: shutil.rmtree(d, ignore_errors=True) utils.print_title("Updating 3rdparty content") # FIXME:qt6 Use modern PDF.js version here update_3rdparty.run(ace=False, pdfjs=True, legacy_pdfjs=True, fancy_dmg=False, gh_token=gh_token) utils.print_title("Building .app via pyinstaller") call_tox('pyinstaller-64', '-r', debug=debug) utils.print_title("Patching .app") patch_mac_app() utils.print_title("Re-signing .app") sign_mac_app() dist_path = pathlib.Path("dist") utils.print_title("Running pre-dmg smoke test") smoke_test(_mac_bin_path(dist_path), debug=debug) if skip_packaging: return [] utils.print_title("Building .dmg") dmg_makefile_path = REPO_ROOT / "scripts" / "dev" / "Makefile-dmg" subprocess.run(['make', '-f', dmg_makefile_path], check=True) suffix = "-debug" if debug else "" dmg_path = dist_path / f'qutebrowser-{qutebrowser.__version__}{suffix}.dmg' pathlib.Path('qutebrowser.dmg').rename(dmg_path) utils.print_title("Running smoke test") try: with tempfile.TemporaryDirectory() as tmp: tmp_path = pathlib.Path(tmp) subprocess.run(['hdiutil', 'attach', dmg_path, '-mountpoint', tmp_path], check=True) try: smoke_test(_mac_bin_path(tmp_path), debug=debug) finally: print("Waiting 10s for dmg to be detachable...") time.sleep(10) subprocess.run(['hdiutil', 'detach', tmp_path], check=False) except PermissionError as e: print(f"Failed to remove tempdir: {e}") return [ Artifact( path=dmg_path, mimetype='application/x-apple-diskimage', description='macOS .dmg' ) ]