From cfc003fb691602ae22e622f64fc023467ef1f3eb Mon Sep 17 00:00:00 2001 From: Rudolf Date: Thu, 13 Oct 2022 10:48:36 +0200 Subject: [PATCH 1/3] implement custom PYFMODEX_DLL_PATH --- pyfmodex/fmodex.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/pyfmodex/fmodex.py b/pyfmodex/fmodex.py index 9e0b162..12dd3bd 100644 --- a/pyfmodex/fmodex.py +++ b/pyfmodex/fmodex.py @@ -12,26 +12,29 @@ import os import platform import sys -from ctypes import * - -arch = platform.architecture()[0] -if platform.system() == "Windows": - try: - _dll = windll.fmod - except Exception as exc: - current_directory = os.path.dirname(os.path.realpath(sys.argv[0])) - try: - _dll = CDLL(os.path.join(current_directory, "fmod")) - except: - raise RuntimeError("Pyfmodex could not find the fmod library") from exc - -elif platform.system() == "Linux": - _dll = CDLL("libfmod.so") +from ctypes import CDLL, windll -elif platform.system() == "Darwin": - if arch == "32bit": - raise RuntimeError("No 32-bit fmod library for Mac Os exists") - _dll = CDLL("libfmod.dylib") +if os.environ.get("PYFMODEX_DLL_PATH") is not None: + _dll = CDLL(os.environ.get("PYFMODEX_DLL_PATH")) +else: + arch = platform.architecture()[0] + if platform.system() == "Windows": + try: + _dll = windll.fmod + except Exception as exc: + current_directory = os.path.dirname(os.path.realpath(sys.argv[0])) + try: + _dll = CDLL(os.path.join(current_directory, "fmod")) + except: + raise RuntimeError("Pyfmodex could not find the fmod library") from exc + + elif platform.system() == "Linux": + _dll = CDLL("libfmod.so") + + elif platform.system() == "Darwin": + if arch == "32bit": + raise RuntimeError("No 32-bit fmod library for Mac Os exists") + _dll = CDLL("libfmod.dylib") from . import globalvars globalvars.DLL = _dll From eb14d447750456d88a3fa27cac42e69e9a22532c Mon Sep 17 00:00:00 2001 From: Rudolf Date: Thu, 13 Oct 2022 10:52:23 +0200 Subject: [PATCH 2/3] Update readme.md --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 54e10cd..152da3f 100644 --- a/readme.md +++ b/readme.md @@ -6,6 +6,7 @@ Installation ------------ To install, first make sure that you have the FMOD Engine library for you platform somewhere in your path, so Python will be able to find it. On Linux, libraries are searched for in `LD_LIBRARY_PATH`. +Alternatively you can set ``PYFMODEX_DLL_PATH`` as environment variable to specify the library path. This can also be done inside Python setting ``os.environ["PYFMODEX_DLL_PATH"]`` before importing pyfmodex. To download the FMOD Engine library, visit http://www.fmod.org/download. The library is free to download, but requires a free account to be made first. Then, install pyfmodex via `pip`, `easy_install` or the `setup.py` way. Note that the minimum supported Python version is Python 3.6. From 467a87f4e29c1c32655244ae3ffc5492a4d9eecc Mon Sep 17 00:00:00 2001 From: Rudolf Date: Thu, 13 Oct 2022 10:54:28 +0200 Subject: [PATCH 3/3] Update installation.rst --- docs/usage/installation.rst | 1 + readme.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/usage/installation.rst b/docs/usage/installation.rst index b3d88c9..1517945 100644 --- a/docs/usage/installation.rst +++ b/docs/usage/installation.rst @@ -3,6 +3,7 @@ Installation To install, first make sure that you have the FMOD Engine library for you platform somewhere in your path, so Python will be able to find it. On Linux, libraries are searched for in `LD_LIBRARY_PATH`. +Alternatively, you can set ``PYFMODEX_DLL_PATH`` as an environment variable to specify the library path. This can also be done inside Python setting ``os.environ["PYFMODEX_DLL_PATH"]`` before importing pyfmodex. .. todo:: Add instructions for library paths on Mac OS X and Windows diff --git a/readme.md b/readme.md index 152da3f..27cd385 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ Installation ------------ To install, first make sure that you have the FMOD Engine library for you platform somewhere in your path, so Python will be able to find it. On Linux, libraries are searched for in `LD_LIBRARY_PATH`. -Alternatively you can set ``PYFMODEX_DLL_PATH`` as environment variable to specify the library path. This can also be done inside Python setting ``os.environ["PYFMODEX_DLL_PATH"]`` before importing pyfmodex. +Alternatively, you can set ``PYFMODEX_DLL_PATH`` as an environment variable to specify the library path. This can also be done inside Python setting ``os.environ["PYFMODEX_DLL_PATH"]`` before importing pyfmodex. To download the FMOD Engine library, visit http://www.fmod.org/download. The library is free to download, but requires a free account to be made first. Then, install pyfmodex via `pip`, `easy_install` or the `setup.py` way. Note that the minimum supported Python version is Python 3.6.