Skip to content

Commit

Permalink
Evaluate CPU for build
Browse files Browse the repository at this point in the history
  • Loading branch information
pvizeli committed May 1, 2019
1 parent a2fc1a8 commit 8153eb4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion builder/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Hass.io Builder main application."""
from pathlib import Path
from tempfile import TemporaryDirectory
from subprocess import CalledProcessError

import click
import click_pathlib
Expand Down Expand Up @@ -34,7 +35,11 @@ def builder(apk, index, requirement, upload, remote):
wheels_dir = create_wheels_folder(output)
wheels_index = create_wheels_index(index)

build_wheels(requirement, wheels_index, wheels_dir)
try:
build_wheels(requirement, wheels_index, wheels_dir)
except CalledProcessError:
pass

run_upload(upload, output, remote)


Expand Down
9 changes: 8 additions & 1 deletion builder/pip.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
"""Pip build commands."""
from pathlib import Path
import os
import subprocess
import sys


def build_wheels(requirement: Path, index: str, output: Path) -> None:
"""Build wheels from a requirements file into output."""
cpu = os.cpu_count() or 4

# Modify speed
build_env = os.environ.copy()
build_env['MAKEFLAGS'] = f"-j{cpu}"

result = subprocess.run(
f"pip3 wheel --wheel-dir {output} --find-links {index} --requirement {requirement}",
shell=True, stdout=sys.stdout, stderr=sys.stderr
shell=True, stdout=sys.stdout, stderr=sys.stderr, env=build_env
)

# Check result of program
Expand Down

0 comments on commit 8153eb4

Please sign in to comment.