# HG changeset patch
# User Raphaël Gomès <rgomes@octobus.net>
# Date 1679503960 -3600
#      Wed Mar 22 17:52:40 2023 +0100
# Node ID 57277c04b2ac48f194c34bfbd28c893932189854
# Parent  c9f9380fe665f98862644935f44f1581658fa632
scripts: add script to setup base dir for easy benchmarking

This is all too manual, but it will help bootstrap a user.

diff --git a/suites/hg/scheduling/setup-base-dir b/suites/hg/scheduling/setup-base-dir
new file mode 100755
--- /dev/null
+++ b/suites/hg/scheduling/setup-base-dir
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+
+import os
+import subprocess
+import click
+import pathlib
+
+POULPE_DIR = pathlib.Path(__file__).parent.parent.parent.parent
+
+RESULT_DIR = "results"
+BIN_ENV_DIR = "bin-envs"
+DATA_ENV_DIR = "data-envs"
+BENCHMARK_DIR = "benchmarks"
+SUITE_DIR = "suites"
+
+
+def install_poulpe():
+    click.secho("Installing poulpe (editable) into a new venv", fg="green")
+    install_venv = ["/usr/bin/env", "python3", "-m", "venv", ".venv"]
+    update_pip = [
+        str(pathlib.Path(".venv") / "bin" / "pip"),
+        "install",
+        "-U",
+        "pip",
+    ]
+    install_poulpe = [
+        str(pathlib.Path(".venv") / "bin" / "pip"),
+        "install",
+        "-e",
+        str(POULPE_DIR),
+    ]
+
+    commands = [install_venv, update_pip, install_poulpe]
+
+    for command in commands:
+        subprocess.run(command, check=True)
+
+
+@click.command()
+@click.argument("path", type=click.Path())
+def setup_base_dir(path):
+    base_path = pathlib.Path(path)
+    click.secho("Creating folders", fg="green")
+    base_path.mkdir(parents=True)
+    base_path.joinpath(RESULT_DIR).mkdir()
+    base_path.joinpath(BIN_ENV_DIR).mkdir()
+    base_path.joinpath(DATA_ENV_DIR).mkdir()
+    install_poulpe()
+
+    click.secho(
+        "Create symlinks to development Poulpe for suites",
+        fg="green",
+    )
+    source = (POULPE_DIR / SUITE_DIR).resolve()
+    old_dir = os.curdir
+    os.chdir(base_path)
+    try:
+        os.symlink(source, SUITE_DIR)
+    finally:
+        os.chdir(old_dir)
+
+    # TODO HGPERFPATH
+
+
+if __name__ == "__main__":
+    setup_base_dir()