Skip to content

Commit

Permalink
Merge pull request #13 from home-assistant/dev
Browse files Browse the repository at this point in the history
Release 0.6
  • Loading branch information
pvizeli authored Jun 2, 2019
2 parents b44e90b + cdb2357 commit a67077a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
15 changes: 10 additions & 5 deletions builder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from builder.apk import install_apks
from builder.infra import create_wheels_folder, create_wheels_index
from builder.pip import build_wheels, parse_requirements
from builder.pip import build_wheels, extract_packages
from builder.upload import run_upload
from builder.utils import check_url

Expand All @@ -28,7 +28,12 @@
@click.option(
"--remote", required=True, type=str, help="Remote URL pass to upload plugin."
)
def builder(apk, index, requirement, upload, remote):
@click.option(
"--requirement-diff",
type=click_pathlib.Path(exists=True),
help="Python requirement file to calc the different for selective builds.",
)
def builder(apk, index, requirement, upload, remote, requirement_diff):
"""Build wheels precompiled for Home Assistant container."""
install_apks(apk)
check_url(index)
Expand All @@ -40,10 +45,10 @@ def builder(apk, index, requirement, upload, remote):

wheels_dir = create_wheels_folder(output)
wheels_index = create_wheels_index(index)
requirements = parse_requirements(requirement)
packages = extract_packages(requirement, requirement_diff)

for package in requirements:
print(f"Process package: {package}")
for package in packages:
print(f"Process package: {package}", flush=True)
try:
build_wheels(package, wheels_index, wheels_dir)
except CalledProcessError:
Expand Down
19 changes: 17 additions & 2 deletions builder/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import subprocess
import sys
from pathlib import Path
from typing import List
from typing import List, Optional


def build_wheels(package: str, index: str, output: Path) -> None:
Expand Down Expand Up @@ -34,5 +34,20 @@ def parse_requirements(requirement: Path) -> List[str]:
line = line.strip()
if not line or line.startswith("#"):
continue
requirement_list.append(line)
requirement_list.append(line.split(" ")[-1])
return requirement_list


def extract_packages(
requirement: Path, requirement_diff: Optional[Path] = None
) -> List[str]:
"""Extract packages they need build."""
packages = parse_requirements(requirement)

# Without diff
if requirement_diff is None:
return packages

packages_diff = parse_requirements(requirement_diff)

return list(set(packages) - set(packages_diff))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

VERSION = 0.5
VERSION = 0.6

setup(
name="builder",
Expand Down

0 comments on commit a67077a

Please sign in to comment.