From 7780a7deb1775edd00db2ed5cf161ee03b8752f4 Mon Sep 17 00:00:00 2001
From: Michele Alberti <michele.alberti@cea.fr>
Date: Fri, 24 May 2024 20:14:01 +0200
Subject: [PATCH] [prover] Ensure maraboupy and Marabou binary have the same
 version.

It may not be the case if the user has in the PATH a local version of Marabou.
---
 bin/runMarabou.py | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/bin/runMarabou.py b/bin/runMarabou.py
index 9e5ae83..b116827 100755
--- a/bin/runMarabou.py
+++ b/bin/runMarabou.py
@@ -45,6 +45,22 @@ sys.path.insert(
 )
 
 
+def maraboupy_version(marabou_binary: str):
+    result = subprocess.run(
+        [marabou_binary, "--version"], capture_output=True, text=True
+    )
+    if result.returncode != 0:
+        print(f"Error running {marabou_binary} --version")
+        sys.exit(1)
+
+    maraboupy_version = version("maraboupy")
+    output = result.stdout.strip()
+    if maraboupy_version in output:
+        return f"Maraboupy {maraboupy_version}"
+
+    return sys.exit(1)
+
+
 def arguments():
     parser = argparse.ArgumentParser(
         description="Thin wrapper around Maraboupy executable"
@@ -92,7 +108,7 @@ def main():
         )
     else:
         if args.version:
-            print(f"Maraboupy {version('maraboupy')}")
+            print(f"{maraboupy_version(marabou_binary)}")
         else:
             assert args.network != None
             assert args.prop != None
-- 
GitLab