Skip to content

Commit

Permalink
chore: allow for all os' we support for python
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Dec 7, 2023
1 parent 8e263a6 commit 5c36b30
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions flipt-client-python/flipt_client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ctypes
import os
import platform

from .models import (
BooleanResult,
Expand All @@ -15,16 +16,23 @@ def __init__(self, namespace: str = "default", engine_opts: EngineOpts = {}):
engine_library_path = os.environ.get("FLIPT_ENGINE_LIB_PATH")

if engine_library_path is None:
# get dynamic library extension for the current platform

if platform.system() == "Windows":
libfile = "fliptengine.dll"
elif platform.system() == "Darwin":
libfile = "libfliptengine.dylib"
else:
libfile = "libfliptengine.so"

# if not set, get the absolute path to the engine library from the ../ext directory
engine_library_path = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "../ext/libfliptengine.so"
os.path.dirname(os.path.abspath(__file__)), f"../ext/{libfile}"
)

if not os.path.exists(engine_library_path):
raise Exception(
"The engine library could not be found at the path: {}".format(
engine_library_path
)
f"The engine library could not be found at the path: {engine_library_path}"
)

self.namespace_key = namespace
Expand Down

0 comments on commit 5c36b30

Please sign in to comment.