Improved spinner
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 8s
Some checks failed
Test before pr merge / test-lint (pull_request) Failing after 8s
This commit is contained in:
@@ -5,6 +5,7 @@ from pathlib import Path
|
||||
import click
|
||||
|
||||
from cpl.cli.cli import cli
|
||||
from cpl.cli.model.project import Project
|
||||
from cpl.cli.utils.structure import get_project_by_name_or_path
|
||||
from cpl.cli.utils.venv import ensure_venv, get_venv_python
|
||||
from cpl.core.configuration import Configuration
|
||||
@@ -42,23 +43,33 @@ def build(project: str, dist: str = None, skip_py_build: bool = None, verbose: b
|
||||
create_pyproject_toml(project, dist_path / project.name)
|
||||
python = str(get_venv_python(venv))
|
||||
|
||||
Console.spinner(
|
||||
result = Console.spinner(
|
||||
"Building python package...",
|
||||
lambda: (
|
||||
subprocess.run(
|
||||
[
|
||||
python,
|
||||
"-m",
|
||||
"build",
|
||||
"--outdir",
|
||||
str(dist_path / project.name),
|
||||
str(dist_path / project.name),
|
||||
],
|
||||
check=True,
|
||||
stdin=subprocess.DEVNULL if not verbose else None,
|
||||
stdout=subprocess.DEVNULL if not verbose else None,
|
||||
stderr=subprocess.DEVNULL if not verbose else None,
|
||||
)
|
||||
lambda: subprocess.run(
|
||||
[
|
||||
python,
|
||||
"-m",
|
||||
"build",
|
||||
"--outdir",
|
||||
str(dist_path / project.name),
|
||||
str(dist_path / project.name),
|
||||
],
|
||||
check=True,
|
||||
stdin=subprocess.DEVNULL if not verbose else None,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
),
|
||||
)
|
||||
|
||||
if result is None:
|
||||
raise RuntimeError("Build process did not run")
|
||||
|
||||
if verbose and result.stdout is not None:
|
||||
Console.write_line(result.stdout.decode())
|
||||
|
||||
if result.returncode != 0 and result.stderr is not None:
|
||||
if result.stderr is not None:
|
||||
Console.error(str(result.stderr.decode()))
|
||||
raise RuntimeError(f"Build process failed with exit code {result.returncode}")
|
||||
|
||||
Console.write_line(" Done!")
|
||||
|
||||
Reference in New Issue
Block a user