From 80ca03c99e0f1199bd12b04ca8101249790f6077 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Mon, 8 Jun 2020 17:06:05 -0500 Subject: [PATCH 1/3] Re-raise exception when NumPy/SciPy imports fail --- setup.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 3fa7c7063..dc0fd7e40 100644 --- a/setup.py +++ b/setup.py @@ -15,11 +15,13 @@ try: import numpy import scipy -except ImportError: - print("Error importing numpy and scipy but these are required to install ForceBalance") - print("Please make sure the numpy and scipy modules are installed and try again") - exit() - +except ImportError as e: + msg = ( + "Error importing numpy and scipy but these are required to install ForceBalance" + "Please make sure the numpy and scipy modules are installed and try again" + ) + raise ImportError(msg) from e + #===================================# #| ForceBalance version number |# #| Make sure to update the version |# From c995e2aa87c4a08a042d4da947cac7a410cc4b19 Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Mon, 8 Jun 2020 17:20:58 -0500 Subject: [PATCH 2/3] Fix error msg --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index dc0fd7e40..0b2b6a2de 100644 --- a/setup.py +++ b/setup.py @@ -16,9 +16,9 @@ import numpy import scipy except ImportError as e: - msg = ( - "Error importing numpy and scipy but these are required to install ForceBalance" - "Please make sure the numpy and scipy modules are installed and try again" + msg = ("\n" + "Error importing numpy and scipy but these are required to install ForceBalance.\n" + "Please make sure the numpy and scipy modules are installed and try again.\n" ) raise ImportError(msg) from e From e943626bc955dda4ef0320a9d974db9e802c950a Mon Sep 17 00:00:00 2001 From: "Matthew W. Thompson" Date: Tue, 9 Jun 2020 11:05:42 -0500 Subject: [PATCH 3/3] Drop from e logic for Python 2.7 compatibility --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0b2b6a2de..08afac21a 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ "Error importing numpy and scipy but these are required to install ForceBalance.\n" "Please make sure the numpy and scipy modules are installed and try again.\n" ) - raise ImportError(msg) from e + raise ImportError(msg) #===================================# #| ForceBalance version number |#