Don't use utils.is_* in build_release.py

This partially reverts ef1c83862b
Otherwise, we'd have to have PyQt5 installed in the environment which runs
build_release.py.
This commit is contained in:
Florian Bruhin 2017-09-26 07:25:59 +02:00
parent e766cf5ed1
commit 5a60630450

View File

@ -36,8 +36,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
os.pardir)) os.pardir))
import qutebrowser import qutebrowser
from qutebrowser.utils import utils from scripts import utils as utils
from scripts import utils as scriptutils
# from scripts.dev import update_3rdparty # from scripts.dev import update_3rdparty
@ -71,7 +70,7 @@ def call_tox(toxenv, *args, python=sys.executable):
def run_asciidoc2html(args): def run_asciidoc2html(args):
"""Common buildsteps used for all OS'.""" """Common buildsteps used for all OS'."""
scriptutils.print_title("Running asciidoc2html.py") utils.print_title("Running asciidoc2html.py")
if args.asciidoc is not None: if args.asciidoc is not None:
a2h_args = ['--asciidoc'] + args.asciidoc a2h_args = ['--asciidoc'] + args.asciidoc
else: else:
@ -128,7 +127,7 @@ def patch_mac_app():
def build_mac(): def build_mac():
"""Build macOS .dmg/.app.""" """Build macOS .dmg/.app."""
scriptutils.print_title("Cleaning up...") utils.print_title("Cleaning up...")
for f in ['wc.dmg', 'template.dmg']: for f in ['wc.dmg', 'template.dmg']:
try: try:
os.remove(f) os.remove(f)
@ -136,20 +135,20 @@ def build_mac():
pass pass
for d in ['dist', 'build']: for d in ['dist', 'build']:
shutil.rmtree(d, ignore_errors=True) shutil.rmtree(d, ignore_errors=True)
scriptutils.print_title("Updating 3rdparty content") utils.print_title("Updating 3rdparty content")
# Currently disabled because QtWebEngine has no pdfjs support # Currently disabled because QtWebEngine has no pdfjs support
# update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False) # update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False)
scriptutils.print_title("Building .app via pyinstaller") utils.print_title("Building .app via pyinstaller")
call_tox('pyinstaller', '-r') call_tox('pyinstaller', '-r')
scriptutils.print_title("Patching .app") utils.print_title("Patching .app")
patch_mac_app() patch_mac_app()
scriptutils.print_title("Building .dmg") utils.print_title("Building .dmg")
subprocess.check_call(['make', '-f', 'scripts/dev/Makefile-dmg']) subprocess.check_call(['make', '-f', 'scripts/dev/Makefile-dmg'])
dmg_name = 'qutebrowser-{}.dmg'.format(qutebrowser.__version__) dmg_name = 'qutebrowser-{}.dmg'.format(qutebrowser.__version__)
os.rename('qutebrowser.dmg', dmg_name) os.rename('qutebrowser.dmg', dmg_name)
scriptutils.print_title("Running smoke test") utils.print_title("Running smoke test")
try: try:
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
@ -178,11 +177,11 @@ def patch_windows(out_dir):
def build_windows(): def build_windows():
"""Build windows executables/setups.""" """Build windows executables/setups."""
scriptutils.print_title("Updating 3rdparty content") utils.print_title("Updating 3rdparty content")
# Currently disabled because QtWebEngine has no pdfjs support # Currently disabled because QtWebEngine has no pdfjs support
# update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False) # update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False)
scriptutils.print_title("Building Windows binaries") utils.print_title("Building Windows binaries")
parts = str(sys.version_info.major), str(sys.version_info.minor) parts = str(sys.version_info.major), str(sys.version_info.minor)
ver = ''.join(parts) ver = ''.join(parts)
python_x86 = r'C:\Python{}-32\python.exe'.format(ver) python_x86 = r'C:\Python{}-32\python.exe'.format(ver)
@ -195,19 +194,19 @@ def build_windows():
artifacts = [] artifacts = []
scriptutils.print_title("Running pyinstaller 32bit") utils.print_title("Running pyinstaller 32bit")
_maybe_remove(out_32) _maybe_remove(out_32)
call_tox('pyinstaller', '-r', python=python_x86) call_tox('pyinstaller', '-r', python=python_x86)
shutil.move(out_pyinstaller, out_32) shutil.move(out_pyinstaller, out_32)
patch_windows(out_32) patch_windows(out_32)
scriptutils.print_title("Running pyinstaller 64bit") utils.print_title("Running pyinstaller 64bit")
_maybe_remove(out_64) _maybe_remove(out_64)
call_tox('pyinstaller', '-r', python=python_x64) call_tox('pyinstaller', '-r', python=python_x64)
shutil.move(out_pyinstaller, out_64) shutil.move(out_pyinstaller, out_64)
patch_windows(out_64) patch_windows(out_64)
scriptutils.print_title("Building installers") utils.print_title("Building installers")
subprocess.check_call(['makensis.exe', subprocess.check_call(['makensis.exe',
'/DVERSION={}'.format(qutebrowser.__version__), '/DVERSION={}'.format(qutebrowser.__version__),
'misc/qutebrowser.nsi']) 'misc/qutebrowser.nsi'])
@ -228,12 +227,12 @@ def build_windows():
'Windows 64bit installer'), 'Windows 64bit installer'),
] ]
scriptutils.print_title("Running 32bit smoke test") utils.print_title("Running 32bit smoke test")
smoke_test(os.path.join(out_32, 'qutebrowser.exe')) smoke_test(os.path.join(out_32, 'qutebrowser.exe'))
scriptutils.print_title("Running 64bit smoke test") utils.print_title("Running 64bit smoke test")
smoke_test(os.path.join(out_64, 'qutebrowser.exe')) smoke_test(os.path.join(out_64, 'qutebrowser.exe'))
scriptutils.print_title("Zipping 32bit standalone...") utils.print_title("Zipping 32bit standalone...")
name = 'qutebrowser-{}-windows-standalone-win32'.format( name = 'qutebrowser-{}-windows-standalone-win32'.format(
qutebrowser.__version__) qutebrowser.__version__)
shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_32)) shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_32))
@ -241,7 +240,7 @@ def build_windows():
'application/zip', 'application/zip',
'Windows 32bit standalone')) 'Windows 32bit standalone'))
scriptutils.print_title("Zipping 64bit standalone...") utils.print_title("Zipping 64bit standalone...")
name = 'qutebrowser-{}-windows-standalone-amd64'.format( name = 'qutebrowser-{}-windows-standalone-amd64'.format(
qutebrowser.__version__) qutebrowser.__version__)
shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_64)) shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_64))
@ -254,7 +253,7 @@ def build_windows():
def build_sdist(): def build_sdist():
"""Build an sdist and list the contents.""" """Build an sdist and list the contents."""
scriptutils.print_title("Building sdist") utils.print_title("Building sdist")
_maybe_remove('dist') _maybe_remove('dist')
@ -277,10 +276,10 @@ def build_sdist():
assert '.pyc' not in by_ext assert '.pyc' not in by_ext
scriptutils.print_title("sdist contents") utils.print_title("sdist contents")
for ext, files in sorted(by_ext.items()): for ext, files in sorted(by_ext.items()):
scriptutils.print_subtitle(ext) utils.print_subtitle(ext)
print('\n'.join(files)) print('\n'.join(files))
filename = 'qutebrowser-{}.tar.gz'.format(qutebrowser.__version__) filename = 'qutebrowser-{}.tar.gz'.format(qutebrowser.__version__)
@ -309,7 +308,7 @@ def github_upload(artifacts, tag):
tag: The name of the release tag tag: The name of the release tag
""" """
import github3 import github3
scriptutils.print_title("Uploading to github...") utils.print_title("Uploading to github...")
token = read_github_token() token = read_github_token()
gh = github3.login(token=token) gh = github3.login(token=token)
@ -344,7 +343,7 @@ def main():
parser.add_argument('--upload', help="Tag to upload the release for", parser.add_argument('--upload', help="Tag to upload the release for",
nargs=1, required=False, metavar='TAG') nargs=1, required=False, metavar='TAG')
args = parser.parse_args() args = parser.parse_args()
scriptutils.change_cwd() utils.change_cwd()
upload_to_pypi = False upload_to_pypi = False
@ -355,7 +354,7 @@ def main():
read_github_token() read_github_token()
run_asciidoc2html(args) run_asciidoc2html(args)
if utils.is_windows: if os.name == 'nt':
if sys.maxsize > 2**32: if sys.maxsize > 2**32:
# WORKAROUND # WORKAROUND
print("Due to a python/Windows bug, this script needs to be run ") print("Due to a python/Windows bug, this script needs to be run ")
@ -365,21 +364,21 @@ def main():
print("https://github.com/pypa/virtualenv/issues/774") print("https://github.com/pypa/virtualenv/issues/774")
sys.exit(1) sys.exit(1)
artifacts = build_windows() artifacts = build_windows()
elif utils.is_mac: elif sys.platform == 'darwin':
artifacts = build_mac() artifacts = build_mac()
else: else:
artifacts = build_sdist() artifacts = build_sdist()
upload_to_pypi = True upload_to_pypi = True
if args.upload is not None: if args.upload is not None:
scriptutils.print_title("Press enter to release...") utils.print_title("Press enter to release...")
input() input()
github_upload(artifacts, args.upload[0]) github_upload(artifacts, args.upload[0])
if upload_to_pypi: if upload_to_pypi:
pypi_upload(artifacts) pypi_upload(artifacts)
else: else:
print() print()
scriptutils.print_title("Artifacts") utils.print_title("Artifacts")
for artifact in artifacts: for artifact in artifacts:
print(artifact) print(artifact)