From 9940f9163792911119aabee05c4731fffa334d17 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Tue, 30 May 2023 14:19:46 +0200
Subject: [PATCH] [jupyter] Install pip packages from requirements.txt

---
 .envrc                       | 2 +-
 ogscm/cli.py                 | 1 +
 ogscm/recipes/ogs.py         | 8 ++++++++
 ogscm/recipes/ogs_jupyter.py | 4 +---
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/.envrc b/.envrc
index 56de242..ee97dba 100644
--- a/.envrc
+++ b/.envrc
@@ -1,2 +1,2 @@
-layout python python3.9
+layout python python3.11
 export PS1=
diff --git a/ogscm/cli.py b/ogscm/cli.py
index 942e604..63c3cec 100644
--- a/ogscm/cli.py
+++ b/ogscm/cli.py
@@ -217,6 +217,7 @@ def main():  # pragma: no cover
     out_dir = f"{args.out}/{args.format}"
     toolchain = None
     versions = None  # versions.json
+    pip_requirements = None
 
     for recipe in recipe_args_parser.parse_known_args()[0].recipe:
         import importlib.resources as pkg_resources
diff --git a/ogscm/recipes/ogs.py b/ogscm/recipes/ogs.py
index 50058bb..f3b44a2 100644
--- a/ogscm/recipes/ogs.py
+++ b/ogscm/recipes/ogs.py
@@ -189,6 +189,8 @@ if local_args.ogs not in ["off", "clean"]:  # != "off" and local_args.ogs != "cl
         ).stdout.rstrip()
         with open(f"{local_args.ogs}/web/data/versions.json") as fp:
             versions = json.load(fp)
+        with open(f"{local_args.ogs}/Tests/Data/requirements.txt") as fp:
+            pip_requirements = fp.readlines()
         if "GITLAB_CI" in os.environ:
             if "CI_COMMIT_TAG" in os.environ:
                 branch = "master"
@@ -227,6 +229,9 @@ if local_args.ogs not in ["off", "clean"]:  # != "off" and local_args.ogs != "cl
                     f"https://gitlab.opengeosys.org/{repo}/-/raw/{commit_hash}/web/data/versions.json"
                 ).text
             )
+            pip_requirements = requests.get(
+                f"https://gitlab.opengeosys.org/{repo}/-/raw/{commit_hash}/Tests/Data/requirements.txt"
+            ).text
         else:
             if re.search(r"[\d.]+", branch):
                 branch_is_release = True
@@ -242,6 +247,9 @@ if local_args.ogs not in ["off", "clean"]:  # != "off" and local_args.ogs != "cl
                     f"https://gitlab.opengeosys.org/{repo}/-/raw/{branch}/web/data/versions.json"
                 ).text
             )
+            pip_requirements = requests.get(
+                f"https://gitlab.opengeosys.org/{repo}/-/raw/{branch}/Tests/Data/requirements.txt"
+            ).text
 
         if branch_is_release:
             name_start = f"ogs-{branch}"
diff --git a/ogscm/recipes/ogs_jupyter.py b/ogscm/recipes/ogs_jupyter.py
index 8703ac1..efbbd12 100644
--- a/ogscm/recipes/ogs_jupyter.py
+++ b/ogscm/recipes/ogs_jupyter.py
@@ -41,9 +41,7 @@ conda_packages = []
 for package in versions["python"]["jupyter_image"]["conda_packages"]:
     conda_packages.append(package)
 
-pip_packages = []
-for package in versions["python"]["jupyter_image"]["pip_packages"]:
-    pip_packages.append(package)
+pip_packages = pip_requirements
 
 vtk_rendering_backend = "osmesa"
 if local_args.pyvista_gpu:
-- 
GitLab