Skip to content

Commit

Permalink
Exclude the dynamic loading trick from Windows.
Browse files Browse the repository at this point in the history
Fix of #28
  • Loading branch information
ateska committed Mar 22, 2022
1 parent e01ec21 commit 17ffb20
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cysimdjson/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
# If the environment variable CYSIMDJSON_GLOBAL_DL is set to "1"
# then the compiled cysimdjson library is imported into a global symbol table
# It is needed to enable third party component to access cysimdjson C API
prev = sys.getdlopenflags()

if sys.platform != 'win32':
prev = sys.getdlopenflags()

try:
if os.environ.get("CYSIMDJSON_GLOBAL_DL") == "1":
sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)
if sys.platform != 'win32':
sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_NOW)

from .cysimdjson import (
JSONParser,
Expand All @@ -20,7 +24,8 @@
PADDING,
)
finally:
sys.setdlopenflags(prev)
if sys.platform != 'win32':
sys.setdlopenflags(prev)

__all__ = [
"JSONParser",
Expand Down

0 comments on commit 17ffb20

Please sign in to comment.