From 8865338cb4ce7e718bab0516bb681e5bec9c66b2 Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Tue, 5 Oct 2021 16:00:12 +0200
Subject: [PATCH] Update pins with macos versions

---
 bob/devtools/data/conda_build_config.yaml |  2 +-
 bob/devtools/scripts/update_pins.py       | 53 +++++++++++++++--------
 2 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/bob/devtools/data/conda_build_config.yaml b/bob/devtools/data/conda_build_config.yaml
index 8f29ab56..9ca48020 100644
--- a/bob/devtools/data/conda_build_config.yaml
+++ b/bob/devtools/data/conda_build_config.yaml
@@ -380,7 +380,7 @@ numba:
 numpy:
   - 1.19.5
 opencv:
-  - 4.5.2
+  - 4.5.1
 pandas:
   - 1.3.3
 pillow:
diff --git a/bob/devtools/scripts/update_pins.py b/bob/devtools/scripts/update_pins.py
index d494346a..7f73a764 100644
--- a/bob/devtools/scripts/update_pins.py
+++ b/bob/devtools/scripts/update_pins.py
@@ -3,10 +3,20 @@
 import click
 
 
-@click.command()
+@click.command(
+    epilog="""Example:
+
+python bob/devtools/scripts/update_pins.py --python 3.8
+
+Force specific version of packages:
+
+python bob/devtools/scripts/update_pins.py --python 3.8 opencv=4.5.1 pytorch=1.9
+"""
+)
+@click.argument("manual_pins", nargs=-1)
 @click.option("--python", required=True, help="Python version to pin, e.g. 3.8")
-def update_pins(python):
-    from subprocess import check_output
+def update_pins(manual_pins, python):
+    import subprocess
 
     from bob.devtools.build import load_packages_from_conda_build_config
 
@@ -18,20 +28,29 @@ def update_pins(python):
     reversed_package_names_map = {v: k for k, v in package_names_map.items()}
 
     # ask mamba to create an environment with the packages
-    env_text = check_output(
-        [
-            "mamba",
-            "create",
-            "--dry-run",
-            "--override-channels",
-            "-c",
-            "conda-forge",
-            "-n",
-            "temp_env",
-            f"python={python}",
-        ]
-        + packages
-    ).decode("utf-8")
+    try:
+        output = subprocess.run(
+            [
+                "mamba",
+                "create",
+                "--dry-run",
+                "--override-channels",
+                "-c",
+                "conda-forge",
+                "-n",
+                "temp_env",
+                f"python={python}",
+            ]
+            + packages
+            + list(manual_pins),
+            capture_output=True,
+            check=True,
+        )
+    except subprocess.CalledProcessError as e:
+        print(e.output.decode())
+        raise e
+
+    env_text = output.stdout.decode("utf-8")
     print(env_text)
 
     resolved_packages = []
-- 
GitLab