Skip to content

Commit

Permalink
Check skip binary with remote index (#76)
Browse files Browse the repository at this point in the history
* Check skip binary with remote index

* Fix fork names
  • Loading branch information
pvizeli authored Mar 23, 2020
1 parent 373fc5d commit 829ca7b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
8 changes: 7 additions & 1 deletion builder/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
31 changes: 31 additions & 0 deletions builder/infra.py
Original file line number Diff line number Diff line change
@@ -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<package>.+)(?:==|>|<|<=|>=|~=)(?P<version>.+)")


def create_wheels_folder(base_folder: Path) -> Path:
"""Create index structure."""
Expand All @@ -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)
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 = "1.8.0"
VERSION = "1.9.0"

setup(
name="builder",
Expand Down

0 comments on commit 829ca7b

Please sign in to comment.