in python/setup.py [0:0]
def clean_all_cmdstan(verbose: bool = False) -> None:
"""Run `make clean-all` in the current directory (must be a cmdstan library).
Parameters
----------
verbose: when ``True``, print build msgs to stdout.
"""
cmd = [MAKE, "clean-all"]
proc = subprocess.Popen(
cmd,
cwd=None,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=os.environ,
)
while proc.poll() is None:
if proc.stdout:
output = proc.stdout.readline().decode("utf-8").strip()
if verbose and output:
print(output, flush=True)
_, stderr = proc.communicate()
if proc.returncode:
msgs = ['Command "make clean-all" failed']
if stderr:
msgs.append(stderr.decode("utf-8").strip())
raise RuntimeError("\n".join(msgs))