Example #1
0
def builder(
    apk: str,
    pip: str,
    index: str,
    requirement: Optional[Path],
    requirement_diff: Optional[Path],
    prebuild_dir: Optional[Path],
    single: bool,
    local: bool,
    upload: str,
    remote: str,
):
    """Build wheels precompiled for Home Assistant container."""
    install_apks(apk)
    check_url(index)

    exit_code = 0
    with TemporaryDirectory() as temp_dir:
        output = Path(temp_dir)

        wheels_dir = create_wheels_folder(output)
        wheels_index = create_wheels_index(index)

        # Setup build helper
        install_pips(wheels_index, pip)

        if local:
            # Build wheels in a local folder/src
            build_wheels_local(wheels_index, wheels_dir)
        elif prebuild_dir:
            # Prepare allready builded wheels for upload
            for whl_file in prebuild_dir.glob("*.whl"):
                shutil.copy(whl_file, Path(wheels_dir, whl_file.name))
        elif single:
            # Build every wheel like a single installation
            packages = extract_packages(requirement, requirement_diff)
            for package in packages:
                print(f"Process package: {package}", flush=True)
                try:
                    build_wheels_package(package, wheels_index, wheels_dir)
                except CalledProcessError:
                    exit_code = 109
        else:
            # Build all needed wheels at once
            packages = extract_packages(requirement, requirement_diff)
            temp_requirement = Path("/tmp/wheels_requirement.txt")
            write_requirement(temp_requirement, packages)

            try:
                build_wheels_requirement(temp_requirement, wheels_index, wheels_dir)
            except CalledProcessError:
                exit_code = 109

        fix_wheels_name(wheels_dir)
        run_upload(upload, output, remote)

    sys.exit(exit_code)
Example #2
0
def builder(apk, index, requirement, upload, remote, requirement_diff, single,
            local):
    """Build wheels precompiled for Home Assistant container."""
    install_apks(apk)
    check_url(index)

    exit_code = 0
    with TemporaryDirectory() as temp_dir:
        output = Path(temp_dir)

        wheels_dir = create_wheels_folder(output)
        wheels_index = create_wheels_index(index)

        if local:
            build_wheels_local(wheels_index, wheels_dir)
        elif single:
            packages = extract_packages(requirement, requirement_diff)
            for package in packages:
                print(f"Process package: {package}", flush=True)
                try:
                    build_wheels_package(package, wheels_index, wheels_dir)
                except CalledProcessError:
                    exit_code = 109
        else:
            packages = extract_packages(requirement, requirement_diff)
            temp_requirement = Path("/tmp/wheels_requirement.txt")
            write_requirement(temp_requirement, packages)

            try:
                build_wheels_requirement(temp_requirement, wheels_index,
                                         wheels_dir)
            except CalledProcessError:
                exit_code = 109

        fix_wheels_name(wheels_dir)
        run_upload(upload, output, remote)

    sys.exit(exit_code)
Example #3
0
def builder(
    apk: str,
    pip: str,
    index: str,
    skip_binary: str,
    requirement: Optional[Path],
    requirement_diff: Optional[Path],
    constraint: Optional[Path],
    prebuild_dir: Optional[Path],
    single: bool,
    auditwheel: bool,
    local: bool,
    test: bool,
    upload: str,
    tag: str,
    arch: str,
    remote: str,
    timeout: int,
):
    """Build wheels precompiled for Home Assistant container."""
    install_apks(apk)
    check_url(index)

    alpine_version = AwesomeVersion(tag.split("alpine")[-1])

    exit_code = 0
    with TemporaryDirectory() as temp_dir:
        output = Path(temp_dir)

        wheels_dir = create_wheels_folder(output)
        wheels_index = create_wheels_index(index)

        # Setup build helper
        install_pips(wheels_index, pip)
        timeout = timeout * 60

        if local:
            # Build wheels in a local folder/src
            build_wheels_local(wheels_index, wheels_dir, alpine_version)
        elif prebuild_dir:
            # Prepare allready builded wheels for upload
            for whl_file in prebuild_dir.glob("*.whl"):
                shutil.copy(whl_file, Path(wheels_dir, whl_file.name))
        elif single:
            # Build every wheel like a single installation
            packages = extract_packages(requirement, requirement_diff)
            skip_binary = check_available_binary(wheels_index, skip_binary,
                                                 packages)
            for package in packages:
                print(f"Process package: {package}", flush=True)
                try:
                    build_wheels_package(
                        package,
                        wheels_index,
                        wheels_dir,
                        skip_binary,
                        timeout,
                        alpine_version,
                        constraint,
                    )
                except CalledProcessError:
                    exit_code = 109
                except TimeoutExpired:
                    exit_code = 80
                    copy_wheels_from_cache(Path("/root/.cache/pip/wheels"),
                                           wheels_dir)
        else:
            # Build all needed wheels at once
            packages = extract_packages(requirement, requirement_diff)
            temp_requirement = Path("/tmp/wheels_requirement.txt")
            write_requirement(temp_requirement, packages)

            skip_binary = check_available_binary(wheels_index, skip_binary,
                                                 packages)
            try:
                build_wheels_requirement(
                    temp_requirement,
                    wheels_index,
                    wheels_dir,
                    skip_binary,
                    timeout,
                    alpine_version,
                    constraint,
                )
            except CalledProcessError:
                exit_code = 109
            except TimeoutExpired:
                exit_code = 80
                copy_wheels_from_cache(Path("/root/.cache/pip/wheels"),
                                       wheels_dir)

        if auditwheel:
            run_auditwheel(wheels_dir)

        fix_wheels_name(wheels_dir)
        if not test:
            run_upload(upload, output, remote)

    sys.exit(exit_code)