in python/setup.py [0:0]
def build_cmdstan(verbose: bool = False) -> None:
"""Run `make build` in the current directory (must be a cmdstan library).
Parameters
----------
verbose: when ``True``, print build msgs to stdout.
"""
cmd = [MAKE, "build"]
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 build" failed']
if stderr:
msgs.append(stderr.decode("utf-8").strip())
raise RuntimeError("\n".join(msgs))
# Add tbb to the $PATH on Windows
if PLATFORM == "win":
libtbb = os.path.join(os.getcwd(), "stan", "lib", "stan_math", "lib", "tbb")
os.environ["PATH"] = ";".join(
list(OrderedDict.fromkeys([libtbb] + os.environ.get("PATH", "").split(";")))
)