diff --git a/build_tools/get_external_dependencies.py b/build_tools/get_external_dependencies.py index ead159b9ea..965a92d6af 100644 --- a/build_tools/get_external_dependencies.py +++ b/build_tools/get_external_dependencies.py @@ -1,4 +1,5 @@ import requests +import platform from enum import Enum class OS(Enum): @@ -11,7 +12,6 @@ def get_os(): """ Get the operating system of the current machine. """ - import platform if platform.system() == "Windows": return OS.WIN elif platform.system() == "Linux": @@ -23,25 +23,20 @@ def get_os(): def get_ausaxs(): _os = get_os() url = "https://github.com/SasView/AUSAXS/releases/latest/download/" - libs = None + lib = None if _os == OS.WIN: - libs = ["libausaxs.dll"] + lib = "libausaxs.dll" elif _os == OS.LINUX: - libs = ["libausaxs.so"] + lib = "libausaxs.so" elif _os == OS.MAC: - libs = ["libausaxs.dylib"] - if libs is not None: + lib = "libausaxs.dylib" + if lib is not None: # we have to use a relative path since the package is not installed yet base_loc = "src/sas/sascalc/calculator/ausaxs/lib/" - for lib in libs: - response = requests.get(url+lib) + response = requests.get(url+lib) - # disable macos for now by renaming the local file - if _os is OS.MAC: - lib = "libausaxs.dylib" - - with open(base_loc+lib, "wb") as f: - f.write(response.content) + with open(base_loc+lib, "wb") as f: + f.write(response.content) def fetch_external_dependencies(): #surround with try/except to avoid breaking the build if the download fails diff --git a/installers/sasview.spec b/installers/sasview.spec index 782c0c532b..2e5933101c 100644 --- a/installers/sasview.spec +++ b/installers/sasview.spec @@ -14,7 +14,6 @@ datas = [ ('../src/sas/qtgui/images', "sas/qtgui/images"), ('../src/sas/sasview/media', 'media'), ('../src/sas/example_data', 'example_data'), - ('../src/sas/sascalc/calculator/ausaxs/lib', 'sas/sascalc/calculator/ausaxs/lib'), ('../src/sas/qtgui/Utilities/Reports/report_style.css', 'sas/qtgui/Utilities/Reports'), ('../src/sas/qtgui/Perspectives/Fitting/plugin_models', 'plugin_models'), ('../src/sas/qtgui/Utilities/WhatsNew/messages', 'sas/qtgui/Utilities/WhatsNew/messages'), @@ -81,7 +80,7 @@ if platform.system() == 'Windows': a = Analysis( ['sasview.py'], pathex=[], - binaries=[], + binaries=[('../src/sas/sascalc/calculator/ausaxs/lib', 'sas/sascalc/calculator/ausaxs/lib')], datas=datas, hiddenimports=hiddenimports, hookspath=[], diff --git a/src/sas/sascalc/calculator/ausaxs/ausaxs_sans_debye.py b/src/sas/sascalc/calculator/ausaxs/ausaxs_sans_debye.py index 42ec2ce668..206f4dc2b4 100644 --- a/src/sas/sascalc/calculator/ausaxs/ausaxs_sans_debye.py +++ b/src/sas/sascalc/calculator/ausaxs/ausaxs_sans_debye.py @@ -22,7 +22,7 @@ def _attach_hooks(): with resources.as_file(resources.files("sas.sascalc.calculator.ausaxs.lib")) as loc: ext = get_shared_lib_extension() if (ext == ""): - logging.log("AUSAXS: Unsupported OS. Using default Debye implementation.") + logging.info("AUSAXS: Unsupported OS. Using default Debye implementation.") return None, lib_state.FAILED path = loc.joinpath("libausaxs" + ext) @@ -45,7 +45,7 @@ def _attach_hooks(): ausaxs_state = lib_state.READY except Exception as e: ausaxs_state = lib_state.FAILED - logging.warning("Failed to hook into AUSAXS library, using default Debye implementation") + logging.warning("AUSAXS: Failed to hook into external library; using default Debye implementation") print(e) return ausaxs, ausaxs_state @@ -118,7 +118,7 @@ def evaluate_sans_debye(q, coords, w): status = queue.get_nowait() first_time = False else: - logging.warning(f"AUSAXS calculator seems to have crashed (exit code \"{p.exitcode}\"). Using default Debye implementation instead.") + logging.warning(f"AUSAXS: External library seems to have crashed (exit code \"{p.exitcode}\"). Using default Debye implementation instead.") ausaxs_state = lib_state.FAILED return sasview_sans_debye(q, coords, w) @@ -132,7 +132,7 @@ def evaluate_sans_debye(q, coords, w): Iq, status = _invoke(q, coords, w) if (status != 0): - logging.warning(f"AUSAXS calculator terminated unexpectedly (error code \"{status}\"). Using default Debye implementation instead.") + logging.warning(f"AUSAXS: External library evaluation terminated unexpectedly (error code \"{status}\"). Using default Debye implementation instead.") return sasview_sans_debye(q, coords, w) return Iq \ No newline at end of file diff --git a/test/sascalculator/utest_sas_gen.py b/test/sascalculator/utest_sas_gen.py index a4af19ecf9..7cb571e94e 100644 --- a/test/sascalculator/utest_sas_gen.py +++ b/test/sascalculator/utest_sas_gen.py @@ -230,11 +230,6 @@ def test_debye_impl(self): rng = np.random.default_rng(1984) - from sas.sascalc.calculator.ausaxs.architecture import get_os, OS - if get_os() is OS.MAC: - self.assertTrue(True, "AUSAXS library is currently not available for MacOS. Skipping test.") - return - if not ausaxs_sans_debye.ausaxs_available(): self.assertTrue(False, "AUSAXS library not found, test cannot be run.") return @@ -257,7 +252,7 @@ def test_debye_impl(self): errs = (external - analytical)/analytical different_entries = 0 for val in np.abs(errs): - self.assertLessEqual(val, 0.01, "Ensure that the error is acceptable.") + self.assertLessEqual(val, 0.02, "Ensure that the error is acceptable.") if val != 0: different_entries += 1 self.assertTrue(different_entries > len(q)*0.5, "Check that two different algorithms were actually run.") @@ -273,7 +268,7 @@ def test_debye_impl(self): errs = (external - analytical)/analytical for val in np.abs(errs): - self.assertLessEqual(val, 0.01) + self.assertLessEqual(val, 0.02) def test_calculator_elements(self): """