Changeset 1083 for framspy


Ignore:
Timestamp:
02/18/21 18:58:55 (4 years ago)
Author:
Maciej Komosinski
Message:

Allowed to override the default name of frams-objects.dll/so

Location:
framspy
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • framspy/frams-test.py

    r1081 r1083  
    22import frams
    33
    4 framspath = sys.argv[1] # set to the directory where Framsticks binaries and libraries exist
    5 frams.init(framspath, "-Ddata")  # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is
     4frams_path = sys.argv[1] # set to the directory where Framsticks binaries and libraries exist
     5frams.init(frams_path, sys.argv[2] if len(sys.argv) > 2 else None, "-Ddata")  # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is
    66
    77print('Available objects:', dir(frams))
  • framspy/frams.py

    r1081 r1083  
    2020
    2121class ExtValue(object):
    22         """All Framsticks objects and values are instances of this class."""
     22        """All Framsticks objects and values are instances of this class. Read the documentation of the 'frams' module for more information."""
    2323
    2424        _reInsideParens = re.compile('\((.*)\)')
     
    248248
    249249
    250 def init(lib_path, *args):
     250def init(lib_path, lib_name, *args):
     251        """
     252        Initializes the connection to Framsticks dll/so.
     253
     254        :param lib_path: the path where the dll/so file can be found
     255        :param lib_name: the name of the dll/so (a complete name including file name extension) or None if you want to use the default name
     256        :param args: optional arguments to pass to Framsticks initialization (try "-h")
     257        """
    251258        original_dir = os.getcwd()
    252         os.chdir(lib_path)  # because under Windows, frams.dll requires other dll's which reside in the same directory, so we must change current dir for them to be found while loading the main dll
    253         global c_api  # access global variable
    254         c_api = ctypes.CDLL('frams-objects.so' if os.name == 'posix' else 'frams-objects.dll')
     259        os.chdir(lib_path)  # because under Windows, frams-objects.dll requires other dll's which reside in the same directory, so we must change current dir for them to be found while loading the main dll
     260        global c_api  # access global variable to initialize it
     261        c_api = ctypes.CDLL(lib_name if lib_name is not None else 'frams-objects.so' if os.name == 'posix' else 'frams-objects.dll')
    255262        os.chdir(original_dir)
    256263
Note: See TracChangeset for help on using the changeset viewer.