Exemplo n.º 1
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    parser = argparse.ArgumentParser()
    parser.add_argument('--website', help="Build website into a given "
                        "directory.", nargs=1)
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--no-authors', help=argparse.SUPPRESS,
                        action='store_true')
    args = parser.parse_args()
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass

    asciidoc = AsciiDoc(args)
    try:
        asciidoc.prepare()
    except FileNotFoundError:
        utils.print_col("Could not find asciidoc! Please install it, or use "
                        "the --asciidoc argument to point this script to the "
                        "correct python/asciidoc.py location!", 'red')
        sys.exit(1)

    try:
        asciidoc.build()
    finally:
        asciidoc.cleanup()
Exemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    args = parser.parse_args()
    utils.change_cwd()

    if os.name == 'nt':
        if sys.maxsize > 2**32:
            # WORKAROUND
            print("Due to a python/Windows bug, this script needs to be run ")
            print("with a 32bit Python.")
            print()
            print("See http://bugs.python.org/issue24493 and ")
            print("https://github.com/pypa/virtualenv/issues/774")
            sys.exit(1)
        run_asciidoc2html(args)
        build_windows()
    elif sys.platform == 'darwin':
        run_asciidoc2html(args)
        build_osx()
    else:
        build_sdist()
Exemplo n.º 3
0
def main():
    """Main entry point.

    Return:
        The pylint exit status.
    """
    utils.change_cwd()
    files = []
    for dirpath, _dirnames, filenames in os.walk('tests'):
        for fn in filenames:
            if os.path.splitext(fn)[1] == '.py':
                files.append(os.path.join(dirpath, fn))
    disabled = [
        'attribute-defined-outside-init',
        'redefined-outer-name',
        'unused-argument',
        # https://bitbucket.org/logilab/pylint/issue/511/
        'undefined-variable',
    ]
    no_docstring_rgx = ['^__.*__$', '^setup$']
    args = (['--disable={}'.format(','.join(disabled)),
             '--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx))] +
            sys.argv[1:] + files)
    ret = subprocess.call(['pylint'] + args)
    return ret
Exemplo n.º 4
0
def main():
    """Main entry point.

    Return:
        The return code to return.
    """
    utils.change_cwd()

    if sys.platform != 'linux':
        print("Skipping coverage checks on non-Linux system.")
        sys.exit()
    elif '-k' in sys.argv[1:]:
        print("Skipping coverage checks because -k is given.")
        sys.exit()
    elif '-m' in sys.argv[1:]:
        print("Skipping coverage checks because -m is given.")
        sys.exit()
    elif any(arg.startswith('tests' + os.sep) for arg in sys.argv[1:]):
        print("Skipping coverage checks because a filename is given.")
        sys.exit()

    for path in PERFECT_FILES:
        assert os.path.exists(os.path.join(*path.split('/'))), path

    with open('.coverage.xml', encoding='utf-8') as f:
        tree = ElementTree.parse(f)
    classes = tree.getroot().findall('./packages/package/classes/class')

    status = 0

    for klass in classes:
        filename = klass.attrib['filename']
        line_cov = float(klass.attrib['line-rate']) * 100
        branch_cov = float(klass.attrib['branch-rate']) * 100

        assert 0 <= line_cov <= 100, line_cov
        assert 0 <= branch_cov <= 100, branch_cov
        assert '\\' not in filename, filename
        assert '/' in filename, filename

        # Files without any branches have 0% coverage
        if branch_cov < 100 and klass.find('./lines/line[@branch="true"]'):
            is_bad = True
        else:
            is_bad = line_cov < 100

        if filename in PERFECT_FILES and is_bad:
            status = 1
            print("{} has {}% line and {}% branch coverage!".format(
                filename, line_cov, branch_cov))
        elif filename not in PERFECT_FILES and not is_bad:
            status = 1
            print("{} has 100% coverage but is not in PERFECT_FILES!".format(
                filename))

    os.remove('.coverage.xml')

    return status
Exemplo n.º 5
0
def main():
    """Main entry point.

    Return:
        The return code to return.
    """
    utils.change_cwd()
    status = check_coverage()
    os.remove(".coverage.xml")
    return status
Exemplo n.º 6
0
def main():
    """Clean up lint in the current dir."""
    utils.change_cwd()
    for elem in lint:
        for f in glob.glob(elem):
            remove(f)

    for root, _dirs, _files in os.walk(os.getcwd()):
        path = os.path.basename(root)
        if any([fnmatch.fnmatch(path, e) for e in recursive_lint]):
            remove(root)
Exemplo n.º 7
0
def main():
    """Main entry point.

    Return:
        The return code to return.
    """
    utils.change_cwd()
    if '--check-all' in sys.argv:
        main_check_all()
    else:
        main_check()
Exemplo n.º 8
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    parser = argparse.ArgumentParser()
    parser.add_argument('--all', help="Build all documentation into a given "
                        "directory.", nargs=1)
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    args = parser.parse_args()
    asciidoc_files = [
        ('FAQ.asciidoc', 'qutebrowser/html/doc/FAQ.html'),
        ('CHANGELOG.asciidoc', 'qutebrowser/html/doc/CHANGELOG.html'),
        ('doc/quickstart.asciidoc', 'qutebrowser/html/doc/quickstart.html'),
        ('doc/userscripts.asciidoc', 'qutebrowser/html/doc/userscripts.html'),
    ]
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass
    try:
        asciidoc = _get_asciidoc_cmd(args)
    except FileNotFoundError:
        utils.print_col("Could not find asciidoc! Please install it, or use "
                        "the --asciidoc argument to point this script to the "
                        "correct python/asciidoc.py location!", 'red')
        sys.exit(1)
    if args.all:
        for root, _dirs, files in os.walk(os.getcwd()):
            for filename in files:
                if os.path.splitext(filename)[1] != '.asciidoc':
                    continue
                src = os.path.join(root, filename)
                parts = [args.all[0]]
                dirname = os.path.dirname(src)
                if dirname:
                    parts.append(os.path.relpath(os.path.dirname(src)))
                parts.append(
                    os.extsep.join((os.path.splitext(os.path.basename(src))[0],
                                    'html')))
                dst = os.path.join(*parts)
                os.makedirs(os.path.dirname(dst), exist_ok=True)
                call_asciidoc(asciidoc, src, dst)
    else:
        for src in glob.glob('doc/help/*.asciidoc'):
            name, _ext = os.path.splitext(os.path.basename(src))
            dst = 'qutebrowser/html/doc/{}.html'.format(name)
            asciidoc_files.append((src, dst))
        for src, dst in asciidoc_files:
            call_asciidoc(asciidoc, src, dst)
Exemplo n.º 9
0
def main():
    """Regenerate all documentation."""
    utils.change_cwd()
    print("Generating manpage...")
    regenerate_manpage("doc/qutebrowser.1.asciidoc")
    print("Generating settings help...")
    generate_settings("doc/help/settings.asciidoc")
    print("Generating command help...")
    generate_commands("doc/help/commands.asciidoc")
    print("Generating authors in README...")
    regenerate_authors("README.asciidoc")
    if "--html" in sys.argv:
        asciidoc2html.main()
Exemplo n.º 10
0
def main():
    """Main entry point."""
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    args = parser.parse_args()
    utils.change_cwd()
    if os.name == 'nt':
        build_common(args)
        build_windows()
    else:
        print("This script does nothing except on Windows currently.")
Exemplo n.º 11
0
def main():
    """Regenerate all documentation."""
    utils.change_cwd()
    print("Generating manpage...")
    regenerate_manpage('doc/qutebrowser.1.asciidoc')
    print("Generating settings help...")
    generate_settings('doc/help/settings.asciidoc')
    print("Generating command help...")
    generate_commands('doc/help/commands.asciidoc')
    if '--no-authors' not in sys.argv:
        print("Generating authors in README...")
        regenerate_authors('README.asciidoc')
    if '--html' in sys.argv:
        asciidoc2html.main()
Exemplo n.º 12
0
def main():
    """Regenerate all documentation."""
    utils.change_cwd()
    print("Generating manpage...")
    regenerate_manpage('doc/qutebrowser.1.asciidoc')
    print("Generating settings help...")
    generate_settings('doc/help/settings.asciidoc')
    print("Generating command help...")
    generate_commands('doc/help/commands.asciidoc')
    if '--cheatsheet' in sys.argv:
        print("Regenerating cheatsheet .pngs")
        regenerate_cheatsheet()
    if '--html' in sys.argv:
        asciidoc2html.main()
Exemplo n.º 13
0
def main():
    """Regenerate all documentation."""
    utils.change_cwd()
    print("Generating manpage...")
    regenerate_manpage('doc/qutebrowser.1.asciidoc')
    print("Generating settings help...")
    generate_settings('doc/help/settings.asciidoc')
    print("Generating command help...")
    generate_commands('doc/help/commands.asciidoc')
    if '--cheatsheet' in sys.argv:
        print("Regenerating cheatsheet .pngs")
        regenerate_cheatsheet()
    if '--html' in sys.argv:
        asciidoc2html.main()
Exemplo n.º 14
0
def main():
    """Main entry point.

    Return:
        The pylint exit status.
    """
    utils.change_cwd()
    files = []
    for dirpath, _dirnames, filenames in os.walk('tests'):
        for fn in filenames:
            if os.path.splitext(fn)[1] == '.py':
                files.append(os.path.join(dirpath, fn))

    disabled = [
        # pytest fixtures
        'redefined-outer-name',
        'unused-argument',
        'too-many-arguments',
        # things which are okay in tests
        'missing-docstring',
        'protected-access',
        'len-as-condition',
        'compare-to-empty-string',
        'pointless-statement',
        'use-implicit-booleaness-not-comparison',
        # directories without __init__.py...
        'import-error',
        # tests/helpers imports
        'wrong-import-order',
        # https://github.com/PyCQA/pylint/issues/6036
        # https://github.com/PyCQA/pylint/issues/6037
        'unnecessary-ellipsis',
    ]

    toxinidir = sys.argv[1]
    pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [
        toxinidir,
    ]

    args = [
        '--disable={}'.format(','.join(disabled)),
        '--ignored-modules=helpers,pytest,PyQt5',
        r'--ignore-long-lines=(<?https?://|^# Copyright 201\d)|^ *def [a-z]',
        r'--method-rgx=[a-z_][A-Za-z0-9_]{1,100}$',
    ] + sys.argv[2:] + files
    env = os.environ.copy()
    env['PYTHONPATH'] = os.pathsep.join(pythonpath)

    ret = subprocess.run(['pylint'] + args, env=env, check=False).returncode
    return ret
Exemplo n.º 15
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--no-asciidoc', action='store_true',
                        help="Don't generate docs")
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--upload', action='store_true', required=False,
                        help="Toggle to upload the release to GitHub")
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-import
        read_github_token()

    if args.no_asciidoc:
        os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
    else:
        run_asciidoc2html(args)

    if os.name == 'nt':
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        artifacts = build_mac()
    else:
        upgrade_sdist_dependencies()
        test_makefile()
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload:
        utils.print_title("Press enter to release...")
        input()

        version_tag = "v" + qutebrowser.__version__

        github_upload(artifacts, version_tag)
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Exemplo n.º 16
0
def main():
    """Main entry point."""
    utils.change_cwd()
    read_files = config.read('.run_checks')
    if not read_files:
        raise IOError("Could not read config!")
    exit_status = collections.OrderedDict()
    exit_status_bool = {}

    args = _parse_args()
    checkers = _get_checkers()

    groups = ['global']
    groups += config.get('DEFAULT', 'targets').split(',')
    groups.append('setup')

    for group in groups:
        print()
        utils.print_col("==================== {} ====================".format(
            group), 'yellow')
        for name, func in checkers[group].items():
            utils.print_col("------ {} ------".format(name), 'cyan')
            if _checker_enabled(args, group, name):
                status = func()
                key = '{}_{}'.format(group, name)
                exit_status[key] = status
                if name == 'flake8':
                    # pyflakes uses True for errors and False for ok.
                    exit_status_bool[key] = not status
                elif isinstance(status, bool):
                    exit_status_bool[key] = status
                else:
                    # sys.exit(0) means no problems -> True, anything != 0
                    # means problems.
                    exit_status_bool[key] = (status == 0)
            else:
                utils.print_col("Checker disabled.", 'blue')
    print()
    utils.print_col("Exit status values:", 'yellow')
    for (k, v) in exit_status.items():
        ok = exit_status_bool[k]
        color = 'green' if ok else 'red'
        utils.print_col(
            '    {} - {} ({})'.format(k, 'ok' if ok else 'FAIL', v), color)

    if all(exit_status_bool):
        return 0
    else:
        return 1
Exemplo n.º 17
0
def main() -> None:
    """Install qutebrowser in a virtualenv.."""
    args = parse_args()
    venv_dir = pathlib.Path(args.venv_dir)
    wheels_dir = pathlib.Path(args.pyqt_wheels_dir)
    utils.change_cwd()

    if args.tox_error:
        show_tox_error(args.pyqt_type)
        sys.exit(1)
    elif (args.pyqt_version != 'auto'
          and args.pyqt_type not in ['binary', 'source']):
        utils.print_col(
            'The --pyqt-version option is only available when '
            'installing PyQt from binary or source', 'red')
        sys.exit(1)
    elif args.pyqt_wheels_dir != 'wheels' and args.pyqt_type != 'wheels':
        utils.print_col(
            'The --pyqt-wheels-dir option is only available when '
            'installing PyQt from wheels', 'red')
        sys.exit(1)

    if not args.keep:
        utils.print_title("Creating virtual environment")
        delete_old_venv(venv_dir)
        create_venv(venv_dir, use_virtualenv=args.virtualenv)

    upgrade_seed_pkgs(venv_dir)

    if args.pyqt_type == 'binary':
        install_pyqt_binary(venv_dir, args.pyqt_version)
    elif args.pyqt_type == 'source':
        install_pyqt_source(venv_dir, args.pyqt_version)
    elif args.pyqt_type == 'link':
        install_pyqt_link(venv_dir)
    elif args.pyqt_type == 'wheels':
        install_pyqt_wheels(venv_dir, wheels_dir)
    elif args.pyqt_type == 'skip':
        pass
    else:
        raise AssertionError

    install_requirements(venv_dir)
    install_qutebrowser(venv_dir)
    if args.dev:
        install_dev_requirements(venv_dir)

    if not args.skip_docs:
        regenerate_docs(venv_dir, args.asciidoc)
Exemplo n.º 18
0
def run(args) -> None:
    """Install qutebrowser in a virtualenv.."""
    venv_dir = pathlib.Path(args.venv_dir)
    wheels_dir = pathlib.Path(args.pyqt_wheels_dir)
    utils.change_cwd()

    if (args.pyqt_version != 'auto'
            and args.pyqt_type not in ['binary', 'source']):
        raise Error(
            'The --pyqt-version option is only available when installing PyQt '
            'from binary or source')

    if args.pyqt_wheels_dir != 'wheels' and args.pyqt_type != 'wheels':
        raise Error(
            'The --pyqt-wheels-dir option is only available when installing '
            'PyQt from wheels')

    if not args.keep:
        utils.print_title("Creating virtual environment")
        delete_old_venv(venv_dir)
        create_venv(venv_dir, use_virtualenv=args.virtualenv)

    upgrade_seed_pkgs(venv_dir)

    if args.pyqt_type == 'binary':
        install_pyqt_binary(venv_dir, args.pyqt_version)
    elif args.pyqt_type == 'source':
        install_pyqt_source(venv_dir, args.pyqt_version)
    elif args.pyqt_type == 'link':
        install_pyqt_link(venv_dir)
    elif args.pyqt_type == 'wheels':
        install_pyqt_wheels(venv_dir, wheels_dir)
    elif args.pyqt_type == 'skip':
        pass
    else:
        raise AssertionError

    apply_xcb_util_workaround(venv_dir, args.pyqt_type, args.pyqt_version)
    if args.pyqt_type != 'skip':
        run_qt_smoke_test(venv_dir)

    install_requirements(venv_dir)
    install_qutebrowser(venv_dir)
    if args.dev:
        install_dev_requirements(venv_dir)

    if not args.skip_docs:
        regenerate_docs(venv_dir, args.asciidoc)
Exemplo n.º 19
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc',
                        help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2,
                        required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--upload',
                        help="Tag to upload the release for",
                        nargs=1,
                        required=False,
                        metavar='TAG')
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload is not None:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-variable
        read_github_token()

    if os.name == 'nt':
        if sys.maxsize > 2**32:
            # WORKAROUND
            print("Due to a python/Windows bug, this script needs to be run ")
            print("with a 32bit Python.")
            print()
            print("See http://bugs.python.org/issue24493 and ")
            print("https://github.com/pypa/virtualenv/issues/774")
            sys.exit(1)
        run_asciidoc2html(args)
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        run_asciidoc2html(args)
        artifacts = build_mac()
    else:
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload is not None:
        utils.print_title("Press enter to release...")
        input()
        github_upload(artifacts, args.upload[0])
        if upload_to_pypi:
            pypi_upload(artifacts)
Exemplo n.º 20
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--upload', help="Tag to upload the release for",
                        nargs=1, required=False, metavar='TAG')
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload is not None:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-variable
        read_github_token()

    run_asciidoc2html(args)
    if os.name == 'nt':
        if sys.maxsize > 2**32:
            # WORKAROUND
            print("Due to a python/Windows bug, this script needs to be run ")
            print("with a 32bit Python.")
            print()
            print("See http://bugs.python.org/issue24493 and ")
            print("https://github.com/pypa/virtualenv/issues/774")
            sys.exit(1)
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        artifacts = build_mac()
    else:
        test_makefile()
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload is not None:
        utils.print_title("Press enter to release...")
        input()
        github_upload(artifacts, args.upload[0])
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Exemplo n.º 21
0
def main():
    """Main entry point."""
    utils.change_cwd()
    read_files = config.read('.run_checks')
    if not read_files:
        raise OSError("Could not read config!")
    exit_status = collections.OrderedDict()
    exit_status_bool = {}

    args = _parse_args()
    checkers = _get_checkers(args)

    groups = ['global']
    groups += config.get('DEFAULT', 'targets').split(',')
    groups.append('setup')

    for group in groups:
        print()
        utils.print_title(group)
        for name, func in checkers[group].items():
            if _checker_enabled(args, group, name):
                utils.print_subtitle(name)
                status = func()
                key = '{}_{}'.format(group, name)
                exit_status[key] = status
                if name == 'flake8':
                    # pyflakes uses True for errors and False for ok.
                    exit_status_bool[key] = not status
                elif isinstance(status, bool):
                    exit_status_bool[key] = status
                else:
                    # sys.exit(0) means no problems -> True, anything != 0
                    # means problems.
                    exit_status_bool[key] = (status == 0)
            elif not args.quiet:
                utils.print_subtitle(name)
                utils.print_col("Checker disabled.", 'blue')
    print()
    utils.print_col("Exit status values:", 'yellow')
    for (k, v) in exit_status.items():
        ok = exit_status_bool[k]
        color = 'green' if ok else 'red'
        utils.print_col(
            '    {} - {} ({})'.format(k, 'ok' if ok else 'FAIL', v), color)
    if all(exit_status_bool.values()):
        return 0
    else:
        return 1
Exemplo n.º 22
0
def main():
    """Main entry point."""
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc',
                        help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2,
                        required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    args = parser.parse_args()
    utils.change_cwd()
    if os.name == 'nt':
        build_common(args)
        build_windows()
    else:
        print("This script does nothing except on Windows currently.")
Exemplo n.º 23
0
def main():
    """Main entry point.

    Return:
        The return code to return.
    """
    utils.change_cwd()

    if sys.platform != "linux":
        print("Skipping coverage checks on non-Linux system.")
        sys.exit()

    for path in PERFECT_FILES:
        assert os.path.exists(os.path.join(*path.split("/"))), path

    with open(".coverage.xml", encoding="utf-8") as f:
        tree = ElementTree.parse(f)
    classes = tree.getroot().findall("./packages/package/classes/class")

    status = 0

    for klass in classes:
        filename = klass.attrib["filename"]
        line_cov = float(klass.attrib["line-rate"]) * 100
        branch_cov = float(klass.attrib["branch-rate"]) * 100

        assert 0 <= line_cov <= 100, line_cov
        assert 0 <= branch_cov <= 100, branch_cov
        assert "\\" not in filename, filename
        assert "/" in filename, filename

        # Files without any branches have 0% coverage
        if branch_cov < 100 and klass.find('./lines/line[@branch="true"]'):
            is_bad = True
        else:
            is_bad = line_cov < 100

        if filename in PERFECT_FILES and is_bad:
            status = 1
            print("{} has {}% line and {}% branch coverage!".format(filename, line_cov, branch_cov))
        elif filename not in PERFECT_FILES and not is_bad:
            status = 1
            print("{} has 100% coverage but is not in PERFECT_FILES!".format(filename))

    os.remove(".coverage.xml")

    return status
Exemplo n.º 24
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--no-asciidoc', action='store_true',
                        help="Don't generate docs")
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--upload', help="Tag to upload the release for",
                        nargs=1, required=False, metavar='TAG')
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload is not None:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-variable
        read_github_token()

    if args.no_asciidoc:
        os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
    else:
        run_asciidoc2html(args)

    if os.name == 'nt':
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        artifacts = build_mac()
    else:
        test_makefile()
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload is not None:
        utils.print_title("Press enter to release...")
        input()
        github_upload(artifacts, args.upload[0])
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Exemplo n.º 25
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc',
                        help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2,
                        required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--upload',
                        help="Tag to upload the release for",
                        nargs=1,
                        required=False,
                        metavar='TAG')
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload is not None:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-variable
        read_github_token()

    run_asciidoc2html(args)
    if os.name == 'nt':
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        artifacts = build_mac()
    else:
        test_makefile()
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload is not None:
        utils.print_title("Press enter to release...")
        input()
        github_upload(artifacts, args.upload[0])
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Exemplo n.º 26
0
def main():
    utils.change_cwd()
    out_filename = 'misc/file_version_info.txt'

    filevers = glimpsebrowser.__version_info__ + (0, )
    prodvers = glimpsebrowser.__version_info__ + (0, )
    str_filevers = glimpsebrowser.__version__
    str_prodvers = glimpsebrowser.__version__

    comment_text = glimpsebrowser.__doc__
    copyright_text = glimpsebrowser.__copyright__
    trademark_text = ("glimpsebrowser is free software under the GNU General "
                      "Public License")

    # https://www.science.co.il/language/Locale-codes.php#definitions
    # https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756.aspx
    en_us = 1033  # 0x0409
    utf_16 = 1200  # 0x04B0

    ffi = vs.FixedFileInfo(filevers, prodvers)

    kids = [
        vs.StringFileInfo([
            # 0x0409: MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
            # 0x04B0: codepage 1200 (UTF-16LE)
            vs.StringTable('040904B0', [
                vs.StringStruct('Comments', comment_text),
                vs.StringStruct('CompanyName', "glimpsebrowser.org"),
                vs.StringStruct('FileDescription', "glimpsebrowser"),
                vs.StringStruct('FileVersion', str_filevers),
                vs.StringStruct('InternalName', "glimpsebrowser"),
                vs.StringStruct('LegalCopyright', copyright_text),
                vs.StringStruct('LegalTrademarks', trademark_text),
                vs.StringStruct('OriginalFilename', "glimpsebrowser.exe"),
                vs.StringStruct('ProductName', "glimpsebrowser"),
                vs.StringStruct('ProductVersion', str_prodvers)
            ]),
        ]),
        vs.VarFileInfo([vs.VarStruct('Translation', [en_us, utf_16])]),
    ]

    file_version_info = vs.VSVersionInfo(ffi, kids)

    with open(out_filename, 'w', encoding='utf-8') as f:
        f.write(str(file_version_info))
Exemplo n.º 27
0
def main():
    utils.change_cwd()
    out_filename = 'misc/file_version_info.txt'

    filevers = qutebrowser.__version_info__ + (0,)
    prodvers = qutebrowser.__version_info__ + (0,)
    str_filevers = qutebrowser.__version__
    str_prodvers = qutebrowser.__version__

    comment_text = qutebrowser.__doc__
    copyright_text = qutebrowser.__copyright__
    trademark_text = ("qutebrowser is free software under the GNU General "
                      "Public License")

    # https://www.science.co.il/language/Locale-codes.php#definitions
    # https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756.aspx
    en_us = 1033  # 0x0409
    utf_16 = 1200  # 0x04B0

    ffi = vs.FixedFileInfo(filevers, prodvers)

    kids = [
        vs.StringFileInfo([
            # 0x0409: MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)
            # 0x04B0: codepage 1200 (UTF-16LE)
            vs.StringTable('040904B0', [
                vs.StringStruct('Comments', comment_text),
                vs.StringStruct('CompanyName', "qutebrowser.org"),
                vs.StringStruct('FileDescription', "qutebrowser"),
                vs.StringStruct('FileVersion', str_filevers),
                vs.StringStruct('InternalName', "qutebrowser"),
                vs.StringStruct('LegalCopyright', copyright_text),
                vs.StringStruct('LegalTrademarks', trademark_text),
                vs.StringStruct('OriginalFilename', "qutebrowser.exe"),
                vs.StringStruct('ProductName', "qutebrowser"),
                vs.StringStruct('ProductVersion', str_prodvers)
            ]),
        ]),
        vs.VarFileInfo([vs.VarStruct('Translation', [en_us, utf_16])]),
    ]

    file_version_info = vs.VSVersionInfo(ffi, kids)

    with open(out_filename, 'w', encoding='utf-8') as f:
        f.write(str(file_version_info))
Exemplo n.º 28
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    asciidoc_files = [
        ('doc/FAQ.asciidoc', 'qutebrowser/html/doc/FAQ.html'),
        ('doc/quickstart.asciidoc', 'qutebrowser/html/doc/quickstart.html'),
    ]
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass
    for src in glob.glob('doc/help/*.asciidoc'):
        name, _ext = os.path.splitext(os.path.basename(src))
        dst = 'qutebrowser/html/doc/{}.html'.format(name)
        asciidoc_files.append((src, dst))
    for src, dst in asciidoc_files:
        call_asciidoc(src, dst)
Exemplo n.º 29
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    asciidoc_files = [
        ('doc/FAQ.asciidoc', 'qutebrowser/html/doc/FAQ.html'),
        ('doc/quickstart.asciidoc', 'qutebrowser/html/doc/quickstart.html'),
    ]
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass
    for src in glob.glob('doc/help/*.asciidoc'):
        name, _ext = os.path.splitext(os.path.basename(src))
        dst = 'qutebrowser/html/doc/{}.html'.format(name)
        asciidoc_files.append((src, dst))
    for src, dst in asciidoc_files:
        call_asciidoc(src, dst)
Exemplo n.º 30
0
def main():
    """Main entry point.

    Return:
        The return code to return.
    """
    utils.change_cwd()

    for path in PERFECT_FILES:
        assert os.path.exists(os.path.join(*path.split('/'))), path

    with open('coverage.xml', encoding='utf-8') as f:
        tree = ElementTree.parse(f)
    classes = tree.getroot().findall('./packages/package/classes/class')

    status = 0

    for klass in classes:
        filename = klass.attrib['filename']
        line_cov = float(klass.attrib['line-rate']) * 100
        branch_cov = float(klass.attrib['branch-rate']) * 100

        assert 0 <= line_cov <= 100, line_cov
        assert 0 <= branch_cov <= 100, branch_cov
        assert '\\' not in filename, filename
        assert '/' in filename, filename

        # Files without any branches have 0% coverage
        if branch_cov < 100 and klass.find('./lines/line[@branch="true"]'):
            is_bad = True
        else:
            is_bad = line_cov < 100

        if filename in PERFECT_FILES and is_bad:
            status = 1
            print("{} has {}% line and {}% branch coverage!".format(
                filename, line_cov, branch_cov))
        elif filename not in PERFECT_FILES and not is_bad:
            status = 1
            print("{} has 100% coverage but is not in PERFECT_FILES!".format(
                filename))

    return status
Exemplo n.º 31
0
def main():
    """Main entry point.

    Return:
        The pylint exit status.
    """
    utils.change_cwd()
    files = []
    for dirpath, _dirnames, filenames in os.walk('tests'):
        for fn in filenames:
            if os.path.splitext(fn)[1] == '.py':
                files.append(os.path.join(dirpath, fn))

    disabled = [
        # pytest fixtures
        'redefined-outer-name',
        'unused-argument',
        'too-many-arguments',
        # things which are okay in tests
        'missing-docstring',
        'protected-access',
        'len-as-condition',
        # directories without __init__.py...
        'import-error',
    ]

    toxinidir = sys.argv[1]
    pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [
        toxinidir,
    ]

    args = [
        '--disable={}'.format(','.join(disabled)),
        '--ignored-modules=helpers,pytest,PyQt5',
        r'--ignore-long-lines=(<?https?://|^# Copyright 201\d)|^ *def [a-z]',
        r'--method-rgx=[a-z_][A-Za-z0-9_]{1,100}$',
    ] + sys.argv[2:] + files
    env = os.environ.copy()
    env['PYTHONPATH'] = os.pathsep.join(pythonpath)

    ret = subprocess.run(['pylint'] + args, env=env).returncode
    return ret
Exemplo n.º 32
0
def main():
    """Main entry point.

    Return:
        The return code to return.
    """
    utils.change_cwd()

    try:
        with open('coverage.xml', encoding='utf-8') as f:
            messages = check(f, PERFECT_FILES)
    except Skipped as e:
        print(e)
        messages = []

    for msg in messages:
        print(msg)

    os.remove('coverage.xml')
    return 1 if messages else 0
Exemplo n.º 33
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    parser = argparse.ArgumentParser()
    parser.add_argument('--all',
                        help="Build all documentation into a given "
                        "directory.",
                        nargs=1)
    args = parser.parse_args()
    asciidoc_files = [
        ('doc/FAQ.asciidoc', 'qutebrowser/html/doc/FAQ.html'),
        ('doc/quickstart.asciidoc', 'qutebrowser/html/doc/quickstart.html'),
    ]
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass
    if args.all:
        for root, _dirs, files in os.walk(os.getcwd()):
            for filename in files:
                if os.path.splitext(filename)[1] != '.asciidoc':
                    continue
                src = os.path.join(root, filename)
                parts = [args.all[0]]
                dirname = os.path.dirname(src)
                if dirname:
                    parts.append(os.path.relpath(os.path.dirname(src)))
                parts.append(
                    os.extsep.join(
                        (os.path.splitext(os.path.basename(src))[0], 'html')))
                dst = os.path.join(*parts)
                os.makedirs(os.path.dirname(dst), exist_ok=True)
                call_asciidoc(src, dst)
    else:
        for src in glob.glob('doc/help/*.asciidoc'):
            name, _ext = os.path.splitext(os.path.basename(src))
            dst = 'qutebrowser/html/doc/{}.html'.format(name)
            asciidoc_files.append((src, dst))
        for src, dst in asciidoc_files:
            call_asciidoc(src, dst)
Exemplo n.º 34
0
def main():
    """Main entry point.

    Return:
        The pylint exit status.
    """
    utils.change_cwd()
    files = []
    for dirpath, _dirnames, filenames in os.walk('tests'):
        for fn in filenames:
            if os.path.splitext(fn)[1] == '.py':
                files.append(os.path.join(dirpath, fn))

    disabled = [
        'redefined-outer-name',
        'unused-argument',
        'missing-docstring',
        'protected-access',
        # https://bitbucket.org/logilab/pylint/issue/511/
        #'undefined-variable',
        'len-as-condition',
        # directories without __init__.py...
        'import-error',
    ]

    toxinidir = sys.argv[1]
    pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [
        toxinidir,
    ]

    no_docstring_rgx = ['^__.*__$', '^setup$']
    args = ([
        '--disable={}'.format(','.join(disabled)),
        '--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx)),
        '--ignored-modules=helpers,pytest,PyQt5'
    ] + sys.argv[2:] + files)
    env = os.environ.copy()
    env['PYTHONPATH'] = os.pathsep.join(pythonpath)

    ret = subprocess.run(['pylint'] + args, env=env).returncode
    return ret
def main():
    """Main entry point.

    Return:
        The pylint exit status.
    """
    utils.change_cwd()
    files = []
    for dirpath, _dirnames, filenames in os.walk('tests'):
        for fn in filenames:
            if os.path.splitext(fn)[1] == '.py':
                files.append(os.path.join(dirpath, fn))

    disabled = [
        'redefined-outer-name',
        'unused-argument',
        'missing-docstring',
        'protected-access',
        # https://bitbucket.org/logilab/pylint/issue/511/
        #'undefined-variable',
        'len-as-condition',
        # directories without __init__.py...
        'import-error',
    ]

    toxinidir = sys.argv[1]
    pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [
        toxinidir,
    ]

    no_docstring_rgx = ['^__.*__$', '^setup$']
    args = (['--disable={}'.format(','.join(disabled)),
             '--no-docstring-rgx=({})'.format('|'.join(no_docstring_rgx)),
             '--ignored-modules=helpers,pytest,PyQt5'] +
            sys.argv[2:] + files)
    env = os.environ.copy()
    env['PYTHONPATH'] = os.pathsep.join(pythonpath)

    ret = subprocess.call(['pylint'] + args, env=env)
    return ret
Exemplo n.º 36
0
def main():
    """Main entry point."""
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    args = parser.parse_args()
    utils.change_cwd()
    if os.name == 'nt':
        if sys.maxsize > 2**32:
            # WORKAROUND
            print("Due to a python/Windows bug, this script needs to be run ")
            print("with a 32bit Python.")
            print()
            print("See http://bugs.python.org/issue24493 and ")
            print("https://github.com/pypa/virtualenv/issues/774")
            sys.exit(1)
        build_common(args)
        build_windows()
    else:
        print("This script does nothing except on Windows currently.")
Exemplo n.º 37
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--asciidoc', help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2, required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    args = parser.parse_args()
    utils.change_cwd()

    if os.name == 'nt':
        if sys.maxsize > 2**32:
            # WORKAROUND
            print("Due to a python/Windows bug, this script needs to be run ")
            print("with a 32bit Python.")
            print()
            print("See http://bugs.python.org/issue24493 and ")
            print("https://github.com/pypa/virtualenv/issues/774")
            sys.exit(1)
        run_asciidoc2html(args)
        build_windows()
    else:
        build_sdist()
Exemplo n.º 38
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    parser = argparse.ArgumentParser()
    parser.add_argument('--all', help="Build all documentation into a given "
                        "directory.", nargs=1)
    args = parser.parse_args()
    asciidoc_files = [
        ('doc/FAQ.asciidoc', 'qutebrowser/html/doc/FAQ.html'),
        ('doc/quickstart.asciidoc', 'qutebrowser/html/doc/quickstart.html'),
    ]
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass
    if args.all:
        for root, _dirs, files in os.walk(os.getcwd()):
            for filename in files:
                if os.path.splitext(filename)[1] != '.asciidoc':
                    continue
                src = os.path.join(root, filename)
                parts = [args.all[0]]
                dirname = os.path.dirname(src)
                if dirname:
                    parts.append(os.path.relpath(os.path.dirname(src)))
                parts.append(
                    os.extsep.join((os.path.splitext(os.path.basename(src))[0],
                                    'html')))
                dst = os.path.join(*parts)
                os.makedirs(os.path.dirname(dst), exist_ok=True)
                call_asciidoc(src, dst)
    else:
        for src in glob.glob('doc/help/*.asciidoc'):
            name, _ext = os.path.splitext(os.path.basename(src))
            dst = 'qutebrowser/html/doc/{}.html'.format(name)
            asciidoc_files.append((src, dst))
        for src, dst in asciidoc_files:
            call_asciidoc(src, dst)
Exemplo n.º 39
0
def main():
    """Main entry point.

    Return:
        The pylint exit status.
    """
    utils.change_cwd()
    files = []
    for dirpath, _dirnames, filenames in os.walk('tests'):
        for fn in filenames:
            if os.path.splitext(fn)[1] == '.py':
                files.append(os.path.join(dirpath, fn))

    disabled = [
        # pytest fixtures
        'redefined-outer-name',
        'unused-argument',
        # things which are okay in tests
        'missing-docstring',
        'protected-access',
        'len-as-condition',
        # directories without __init__.py...
        'import-error',
    ]

    toxinidir = sys.argv[1]
    pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep) + [
        toxinidir,
    ]

    args = ([
        '--disable={}'.format(','.join(disabled)),
        '--ignored-modules=helpers,pytest,PyQt5'
    ] + sys.argv[2:] + files)
    env = os.environ.copy()
    env['PYTHONPATH'] = os.pathsep.join(pythonpath)

    ret = subprocess.run(['pylint'] + args, env=env).returncode
    return ret
Exemplo n.º 40
0
def main(colors=False):
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    parser = argparse.ArgumentParser()
    parser.add_argument('--website',
                        help="Build website into a given "
                        "directory.",
                        nargs=1)
    parser.add_argument('--asciidoc',
                        help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2,
                        required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--no-authors',
                        help=argparse.SUPPRESS,
                        action='store_true')
    args = parser.parse_args()
    try:
        os.mkdir('qutebrowser/html/doc')
    except FileExistsError:
        pass

    asciidoc = AsciiDoc(args)
    try:
        asciidoc.prepare()
    except FileNotFoundError:
        utils.print_col(
            "Could not find asciidoc! Please install it, or use "
            "the --asciidoc argument to point this script to the "
            "correct python/asciidoc.py location!", 'red')
        sys.exit(1)

    try:
        asciidoc.build()
    finally:
        asciidoc.cleanup()
Exemplo n.º 41
0
def main() -> None:
    """Install qutebrowser in a virtualenv.."""
    args = parse_args()
    venv_dir = pathlib.Path(args.venv_dir)
    utils.change_cwd()

    if args.tox_error:
        show_tox_error(args.pyqt_type)
        sys.exit(1)
    elif args.pyqt_type == 'link' and args.pyqt_version != 'auto':
        utils.print_col(
            'The --pyqt-version option is not available when '
            'linking a system-wide install.', 'red')
        sys.exit(1)

    if not args.keep:
        utils.print_title("Creating virtual environment")
        delete_old_venv(venv_dir)
        create_venv(venv_dir, use_virtualenv=args.virtualenv)

    upgrade_seed_pkgs(venv_dir)

    if args.pyqt_type == 'binary':
        install_pyqt_binary(venv_dir, args.pyqt_version)
    elif args.pyqt_type == 'source':
        install_pyqt_source(venv_dir, args.pyqt_version)
    elif args.pyqt_type == 'link':
        install_pyqt_link(venv_dir)
    else:
        raise AssertionError

    install_requirements(venv_dir)
    install_qutebrowser(venv_dir)
    if args.dev:
        install_dev_requirements(venv_dir)

    regenerate_docs(venv_dir, args.asciidoc)
Exemplo n.º 42
0
# This file is part of qutebrowser.
#
# qutebrowser is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# qutebrowser is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser.  If not, see <http://www.gnu.org/licenses/>.

"""Update 3rd-party files (currently only ez_setup.py)."""

import sys
import os
import os.path
import urllib.request

sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))

from scripts import utils

utils.change_cwd()
urllib.request.urlretrieve(
    'https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py',
    'scripts/ez_setup.py')
Exemplo n.º 43
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--skip-docs',
                        action='store_true',
                        help="Don't generate docs")
    parser.add_argument('--asciidoc',
                        help="Full path to asciidoc.py. "
                        "If not given, it's searched in PATH.",
                        nargs='?')
    parser.add_argument(
        '--asciidoc-python',
        help="Python to use for asciidoc."
        "If not given, the current Python interpreter is used.",
        nargs='?')
    parser.add_argument('--gh-token', help="GitHub token to use.", nargs='?')
    parser.add_argument('--upload',
                        action='store_true',
                        required=False,
                        help="Toggle to upload the release to GitHub.")
    parser.add_argument('--no-confirm',
                        action='store_true',
                        required=False,
                        help="Skip confirmation before uploading.")
    parser.add_argument('--skip-packaging',
                        action='store_true',
                        required=False,
                        help="Skip Windows installer/zip generation.")
    parser.add_argument('--32bit',
                        action='store_true',
                        required=False,
                        help="Skip Windows 64 bit build.",
                        dest='only_32bit')
    parser.add_argument('--64bit',
                        action='store_true',
                        required=False,
                        help="Skip Windows 32 bit build.",
                        dest='only_64bit')
    parser.add_argument('--debug',
                        action='store_true',
                        required=False,
                        help="Build a debug build.")
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-import
        gh_token = read_github_token(args.gh_token)
    else:
        gh_token = read_github_token(args.gh_token, optional=True)

    if not misc_checks.check_git():
        utils.print_error("Refusing to do a release with a dirty git tree")
        sys.exit(1)

    if args.skip_docs:
        os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
    else:
        run_asciidoc2html(args)

    if os.name == 'nt':
        artifacts = build_windows(
            gh_token=gh_token,
            skip_packaging=args.skip_packaging,
            only_32bit=args.only_32bit,
            only_64bit=args.only_64bit,
            debug=args.debug,
        )
    elif sys.platform == 'darwin':
        artifacts = build_mac(gh_token=gh_token, debug=args.debug)
    else:
        test_makefile()
        artifacts = build_sdist()
        twine_check(artifacts)
        upload_to_pypi = True

    if args.upload:
        version_tag = "v" + qutebrowser.__version__

        if not args.no_confirm:
            utils.print_title(
                "Press enter to release {}...".format(version_tag))
            input()

        github_upload(artifacts, version_tag, gh_token=gh_token)
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Exemplo n.º 44
0
def show_commit():
    subprocess.run(['git', 'show'], check=True)


if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Update release version.")
    parser.add_argument('bump',
                        action="store",
                        choices=["major", "minor", "patch"],
                        help="Update release version")
    parser.add_argument('--commands',
                        action="store_true",
                        help="Only show commands to run post-release.")
    args = parser.parse_args()

    utils.change_cwd()

    if not args.commands:
        bump_version(args.bump)
        show_commit()

    import qutebrowser
    version = qutebrowser.__version__
    x_version = '.'.join([str(p)
                          for p in qutebrowser.__version_info__[:-1]] + ['x'])

    print("Run the following commands to create a new release:")
    print("* git push origin; git push origin v{v}".format(v=version))
    if args.bump == 'patch':
        print("* git checkout master && git cherry-pick v{v} && "
              "git push origin".format(v=version))
Exemplo n.º 45
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--no-asciidoc',
                        action='store_true',
                        help="Don't generate docs")
    parser.add_argument('--asciidoc',
                        help="Full path to asciidoc.py. "
                        "If not given, it's searched in PATH.",
                        nargs='?')
    parser.add_argument(
        '--asciidoc-python',
        help="Python to use for asciidoc."
        "If not given, the current Python interpreter is used.",
        nargs='?')
    parser.add_argument('--upload',
                        action='store_true',
                        required=False,
                        help="Toggle to upload the release to GitHub")
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-import
        read_github_token()

    if not misc_checks.check_git():
        utils.print_error("Refusing to do a release with a dirty git tree")
        sys.exit(1)

    if args.no_asciidoc:
        os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
    else:
        run_asciidoc2html(args)

    if os.name == 'nt':
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        artifacts = build_mac()
    else:
        upgrade_sdist_dependencies()
        test_makefile()
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload:
        version_tag = "v" + qutebrowser.__version__
        utils.print_title("Press enter to release {}...".format(version_tag))
        input()

        github_upload(artifacts, version_tag)
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Exemplo n.º 46
0
def main(colors: bool = False) -> None:
    """Generate html files for the online documentation."""
    utils.change_cwd()
    utils.use_color = colors
    args = parse_args()
    run(asciidoc=args.asciidoc, website=args.website)
Exemplo n.º 47
0
def main():
    utils.change_cwd()
    if '--check-all' in sys.argv:
        return main_check_all()
    else:
        return main_check()
def main():
    scriptutils.change_cwd()
    if '--check-all' in sys.argv:
        return main_check_all()
    else:
        return main_check()