Skip to content

Commit

Permalink
ENH - import pylsl in a function and call it from an isolated subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoostenveld committed Apr 27, 2023
1 parent 20fdd6e commit ae02cee
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-pylsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@
# ------------------------------------------------------------------

import os
from PyInstaller.utils.hooks import logger
from PyInstaller.utils.hooks import logger, isolated

try:
# the import will fail it the library cannot be found
from pylsl import pylsl

# the find_liblsl_libraries() is a generator function that yields multiple possibilities
for libfile in pylsl.find_liblsl_libraries():
if libfile:
break
except:
libfile = None
def find_library():
try:
# the import will fail it the library cannot be found
from pylsl import pylsl

# the find_liblsl_libraries() is a generator function that yields multiple possibilities
for libfile in pylsl.find_liblsl_libraries():
if libfile:
break
except:
libfile = None
return libfile

# whenever a hook needs to load a 3rd party library, it needs to be done in an isolated subprocess
libfile = isolated.call(find_library)

if libfile:
# add the liblsl library to the binaries
Expand Down

0 comments on commit ae02cee

Please sign in to comment.