diff --git a/builder/__main__.py b/builder/__main__.py index 553bcaf3..b9ae4d5e 100644 --- a/builder/__main__.py +++ b/builder/__main__.py @@ -10,7 +10,11 @@ import click_pathlib from builder.apk import install_apks -from builder.infra import create_wheels_folder, create_wheels_index +from builder.infra import ( + create_wheels_folder, + create_wheels_index, + check_available_binary, +) from builder.pip import ( build_wheels_local, build_wheels_package, @@ -95,6 +99,7 @@ def builder( 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: @@ -107,6 +112,7 @@ def builder( 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 diff --git a/builder/infra.py b/builder/infra.py index c7a3ffc9..a3bd72d2 100644 --- a/builder/infra.py +++ b/builder/infra.py @@ -1,8 +1,14 @@ """Create folder structure for index.""" from pathlib import Path +import re +from typing import List, Set + +import requests from .utils import alpine_version, build_arch +_RE_REQUIREMENT = re.compile(r"(?P.+)(?:==|>|<|<=|>=|~=)(?P.+)") + def create_wheels_folder(base_folder: Path) -> Path: """Create index structure.""" @@ -15,3 +21,28 @@ def create_wheels_folder(base_folder: Path) -> Path: def create_wheels_index(base_index: str) -> str: """Create wheels specific URL.""" return f"{base_index}/{alpine_version()}/{build_arch()}/" + + +def check_available_binary(index: str, skip_binary: str, packages: List[str]) -> str: + """Check if binary exists and ignore this skip.""" + if skip_binary == ":none:": + return skip_binary + + list_binary = skip_binary.split(",") + available_data = requests.get(index).text + + list_needed: Set[str] = set() + for binary in list_binary: + for package in packages: + if not package.startswith(binary): + continue + find = _RE_REQUIREMENT.fullmatch(package) + name = f"{binary}-{find['version']}" + if available_data.find(name) != -1: + continue + list_needed.add(binary) + + # Generate needed list of skip binary + if not list_needed: + return ":none:" + return ",".join(list_needed) diff --git a/setup.py b/setup.py index d703376a..c6e15646 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup -VERSION = "1.8.0" +VERSION = "1.9.0" setup( name="builder",