From c4b3e874de3f179baef0eede1f72de4d57d9a7b9 Mon Sep 17 00:00:00 2001
From: JohannesGaessler <johannesg@5d6.de>
Date: Tue, 11 Jul 2023 11:34:11 +0200
Subject: [PATCH] Skip nlojet++ checks if no Python extension

---
 .../nlojet++/interface/check/compare-table-helper.py       | 6 +++++-
 .../nlojet++/interface/check/fnlo-compare-tables.py        | 7 ++++++-
 .../nlojet++/interface/check/fnlo-nj-lotest.pl.in          | 4 ++++
 .../nlojet++/interface/check/fnlo-nj-nlotest.pl.in         | 4 ++++
 4 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/v2.5/generators/nlojet++/interface/check/compare-table-helper.py b/v2.5/generators/nlojet++/interface/check/compare-table-helper.py
index 095ab0dd..0f40493b 100755
--- a/v2.5/generators/nlojet++/interface/check/compare-table-helper.py
+++ b/v2.5/generators/nlojet++/interface/check/compare-table-helper.py
@@ -3,7 +3,11 @@
 import os
 import sys
 
-import fastnlo as fnlo
+try:
+    import fastnlo as fnlo
+except ModuleNotFoundError:
+    print("compare-table-helper: fastNLO Python extension not found")
+    sys.exit(77)
 
 LIBDIR = os.environ["LIBDIR"]
 
diff --git a/v2.5/generators/nlojet++/interface/check/fnlo-compare-tables.py b/v2.5/generators/nlojet++/interface/check/fnlo-compare-tables.py
index 3a17694a..7d2e6ba8 100755
--- a/v2.5/generators/nlojet++/interface/check/fnlo-compare-tables.py
+++ b/v2.5/generators/nlojet++/interface/check/fnlo-compare-tables.py
@@ -1,8 +1,13 @@
 #!/usr/bin/env python3
 
+import sys
 import os
 
-import fastnlo as fnlo
+try:
+    import fastnlo as fnlo
+except ModuleNotFoundError:
+    print("fastNLO Python extension not found")
+    sys.exit(77)
 
 LIBDIR = os.environ["LIBDIR"]
 
diff --git a/v2.5/generators/nlojet++/interface/check/fnlo-nj-lotest.pl.in b/v2.5/generators/nlojet++/interface/check/fnlo-nj-lotest.pl.in
index 98119c88..105bbc19 100755
--- a/v2.5/generators/nlojet++/interface/check/fnlo-nj-lotest.pl.in
+++ b/v2.5/generators/nlojet++/interface/check/fnlo-nj-lotest.pl.in
@@ -72,6 +72,10 @@ if ( $ret ) {die "fnlo-tk-nlotest: Ungzipping test table ${tabgz} failed: $ret,
 $cmd = "./compare-table-helper.py ./${tabl} output/${tabl} > lodiff.log";
 print "Executing command: $cmd\n";
 $ret = system("$cmd");
+if ( $ret == 77 ) {
+    print "fnlo-nj-lotest: Skipping LO production unit test.";
+    exit 77;
+}
 if ( $ret ) {die "fnlo-nj-lotest: LO table production unit test failed, results are different!\n";}
 
 print "fnlo-nj-lotest: LO table production unit test passed.\n";
diff --git a/v2.5/generators/nlojet++/interface/check/fnlo-nj-nlotest.pl.in b/v2.5/generators/nlojet++/interface/check/fnlo-nj-nlotest.pl.in
index 3d6a1304..2018db42 100755
--- a/v2.5/generators/nlojet++/interface/check/fnlo-nj-nlotest.pl.in
+++ b/v2.5/generators/nlojet++/interface/check/fnlo-nj-nlotest.pl.in
@@ -72,6 +72,10 @@ if ( $ret ) {die "fnlo-tk-nlotest: Ungzipping test table ${tabgz} failed: $ret,
 $cmd = "./compare-table-helper.py ./${tabn} output/${tabn} > lodiff.log";
 print "Executing command: $cmd\n";
 $ret = system("$cmd");
+if ( $ret == 77 ) {
+    print "fnlo-nj-lotest: Skipping LO production unit test.";
+    exit 77;
+}
 if ( $ret ) {die "fnlo-nj-lotest: NLO table production unit test failed, results are different!\n";}
 
 print "fnlo-nj-nlotest: NLO table production unit test passed.\n";
-- 
GitLab