diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index ed62f68..3b60a14 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -90,15 +90,12 @@ jobs: - run: ls lib - run: zip -r ${{ matrix.container }}-${{ matrix.name }} lib share - - run: pip3 install -r test/requirements.txt - # - run: pip3 install -r cython/requirements.txt - # - run: | - # cd cython/ - # cp -r ../lib lib - # cp -r ../share share - # python3 setup.py build_ext --inplace - # pip3 install . - # cd .. + - name: Install Requirements + run: | + pip3 install -r test/requirements.txt + cd pymodule + python3 setup.py build_ext --inplace + - run: python3 -m pytest - name: Upload Debug Spectrum diff --git a/pymodule/libtools.py b/pymodule/libtools.py new file mode 100644 index 0000000..16ad0db --- /dev/null +++ b/pymodule/libtools.py @@ -0,0 +1,34 @@ +from os.path import dirname, join, abspath +import platform + +def get_lib_name(): + """Get the name of the sme C library""" + system = platform.system().lower() + + if system == "windows": + return "libsme-5.dll" + + arch = platform.machine() + bits = 64 # platform.architecture()[0][:-3] + + return "sme_synth.so.{system}.{arch}.{bits}".format( + system=system, arch=arch, bits=bits + ) + + +def get_lib_directory(): + if platform.system() in ["Windows"]: + dirpath = "bin" + else: + # For Linux/MacOS + dirpath = "lib" + return dirpath + + +def get_full_libfile(): + """Get the full path to the sme C library""" + localdir = dirname(dirname(__file__)) + libfile = get_lib_name() + dirpath = get_lib_directory() + libfile = join(localdir, dirpath, libfile) + return libfile \ No newline at end of file diff --git a/pymodule/smelib.py b/pymodule/smelib.py index 1aa3e3b..64b054f 100644 --- a/pymodule/smelib.py +++ b/pymodule/smelib.py @@ -6,15 +6,11 @@ import logging from ctypes import cdll +from .libtools import get_full_libfile # Load the library -libdir = abspath(join(dirname(__file__), "../lib")) -libfile = join(libdir, "libsme.so") - -try: - os.add_dll_directory(libdir) -except AttributeError: - cdll.LoadLibrary(libfile) +libfile = get_full_libfile() +cdll.LoadLibrary(libfile) from . import _smelib