Skip to content

Commit

Permalink
fixed ausaxs filename bug
Browse files Browse the repository at this point in the history
  • Loading branch information
klytje committed Oct 21, 2024
1 parent 0b54303 commit b83c074
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
17 changes: 16 additions & 1 deletion src/sas/sascalc/calculator/ausaxs/architecture.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
import platform

class OS(Enum):
WIN = 0
Expand Down Expand Up @@ -31,4 +32,18 @@ def get_shared_lib_extension():
return ".so"
elif _os == OS.MAC:
return ".dylib"
return ""
return ""

def get_ausaxs_filename():
"""
Get the AUSAXS shared library filename for the current operating system.
"""
_os = get_os()
lib = None
if _os == OS.WIN:
lib = "libausaxs.dll"
elif _os == OS.LINUX:
lib = "libausaxs.so"
elif _os == OS.MAC:
lib = "libausaxs-" + platform.machine() + ".dylib"
return lib
8 changes: 4 additions & 4 deletions src/sas/sascalc/calculator/ausaxs/ausaxs_sans_debye.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ class lib_state(Enum):
def _attach_hooks():
ausaxs = None
ausaxs_state = lib_state.UNINITIALIZED
from sas.sascalc.calculator.ausaxs.architecture import get_shared_lib_extension
from sas.sascalc.calculator.ausaxs.architecture import get_ausaxs_filename

# as_file extracts the dll if it is in a zip file and probably deletes it afterwards,
# so we have to do all operations on the dll inside the with statement
with resources.as_file(resources.files("sas.sascalc.calculator.ausaxs.lib")) as loc:
ext = get_shared_lib_extension()
if (ext == ""):
file = get_ausaxs_filename()
if (not file):
logging.log("AUSAXS: Unsupported OS. Using default Debye implementation.")
return None, lib_state.FAILED

path = loc.joinpath("libausaxs" + ext)
loc.joinpath(file)
ausaxs_state = lib_state.READY
try:
# evaluate_sans_debye func
Expand Down

0 comments on commit b83c074

Please sign in to comment.