diff --git a/builder/__main__.py b/builder/__main__.py index 781ec31a..aff91813 100644 --- a/builder/__main__.py +++ b/builder/__main__.py @@ -1,8 +1,10 @@ """Hass.io Builder main application.""" -import sys from pathlib import Path +import shutil from subprocess import CalledProcessError +import sys from tempfile import TemporaryDirectory +from typing import Optional import click import click_pathlib @@ -10,11 +12,11 @@ from builder.apk import install_apks from builder.infra import create_wheels_folder, create_wheels_index from builder.pip import ( + build_wheels_local, build_wheels_package, build_wheels_requirement, - build_wheels_local, - write_requirement, extract_packages, + write_requirement, ) from builder.upload import run_upload from builder.utils import check_url, fix_wheels_name @@ -28,15 +30,16 @@ type=click_pathlib.Path(exists=True), help="Python requirement file.", ) -@click.option("--upload", default="rsync", help="Upload plugin to upload wheels.") -@click.option( - "--remote", required=True, type=str, help="Remote URL pass to upload plugin." -) @click.option( "--requirement-diff", type=click_pathlib.Path(exists=True), help="Python requirement file to calc the different for selective builds.", ) +@click.option( + "--prebuild-dir", + type=click_pathlib.Path(exists=True), + help="Folder with include allready builded wheels for upload.", +) @click.option( "--single", is_flag=True, @@ -46,7 +49,21 @@ @click.option( "--local", is_flag=True, default=False, help="Build wheel from local folder setup." ) -def builder(apk, index, requirement, upload, remote, requirement_diff, single, local): +@click.option("--upload", default="rsync", help="Upload plugin to upload wheels.") +@click.option( + "--remote", required=True, type=str, help="Remote URL pass to upload plugin." +) +def builder( + apk: 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) @@ -59,8 +76,14 @@ def builder(apk, index, requirement, upload, remote, requirement_diff, single, l wheels_index = create_wheels_index(index) 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) @@ -69,6 +92,7 @@ def builder(apk, index, requirement, upload, remote, requirement_diff, single, l 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) diff --git a/requirements.txt b/requirements.txt index 2c02026c..4abfbc53 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ click==7.0 click-pathlib==2019.6.13.1 requests==2.22.0 -Cython==0.29.12 -wheel==0.33.4 +Cython==0.29.13 +wheel==0.33.6 diff --git a/setup.py b/setup.py index 9db133d5..42f838a5 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = "1.1" +VERSION = "1.2" setup( name="builder",