Skip to content
Snippets Groups Projects
Commit 99b476b4 authored by David Hendriks's avatar David Hendriks
Browse files

making fix for file xtension

parent a010cef2
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ import os
import uuid
import ctypes
import socket
import platform
import textwrap
import subprocess
......@@ -14,6 +15,28 @@ from typing import Tuple, Optional
from binarycpython.utils.functions import temp_dir, remove_file, verbose_print
def get_dynamic_library_file_extension():
"""
Function to find the correct file extension
It will return .so except for exceptions based on platform.platform()
"""
current_platform = platform.platform()
# Set up exception list
exception_dict = {
'macOS-12.4': 'dylib'
}
# Check in the exception dict, to see if the current platform starts with any of the keys in there.
for exception_platform_key in exception_dict.keys():
if current_platform.startswith(exception_platform_key):
return exception_dict[exception_platform_key]
# Otherwise return .so
return 'so'
def autogen_C_logging_code(logging_dict: dict, verbosity: int = 0) -> Optional[str]:
"""
......@@ -410,9 +433,12 @@ def create_and_load_logging_function(
# Create the sub dir for the custom_logging code
os.makedirs(custom_logging_dir, exist_ok=True)
# Get the correct filename extension (can depend per system)
extension = get_dynamic_library_file_extension()
#
library_name = os.path.join(
custom_logging_dir, "libcustom_logging_{}.so".format(uuid.uuid4().hex)
custom_logging_dir, "libcustom_logging_{}.{}".format(uuid.uuid4().hex, extension)
)
compile_shared_lib(
......@@ -429,9 +455,9 @@ def create_and_load_logging_function(
)
# Loading library
_ = ctypes.CDLL("libgslcblas.so", mode=ctypes.RTLD_GLOBAL)
_ = ctypes.CDLL("libgsl.so", mode=ctypes.RTLD_GLOBAL)
_ = ctypes.CDLL("libbinary_c.so", mode=ctypes.RTLD_GLOBAL)
_ = ctypes.CDLL("libgslcblas.{}".format(extension), mode=ctypes.RTLD_GLOBAL)
_ = ctypes.CDLL("libgsl.{}".format(extension), mode=ctypes.RTLD_GLOBAL)
_ = ctypes.CDLL("libbinary_c.{}".format(extension), mode=ctypes.RTLD_GLOBAL)
libcustom_logging = ctypes.CDLL(
library_name,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment