Skip to content

Commit

Permalink
Implement fallback for detection of pylon install folder via registry…
Browse files Browse the repository at this point in the history
… on windows platforms.
  • Loading branch information
bjoernrennfanz committed Jul 1, 2024
1 parent ea94907 commit 677f5e7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,22 @@ def __init__(self):

self.PylonDevDir = os.environ.get("PYLON_DEV_DIR")
if not self.PylonDevDir:
raise EnvironmentError("PYLON_DEV_DIR is not set")
# Fallback, try to locate pylon installation via registry key
import winreg
hkey_local_machine_reg = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
try:
pylon_registry_key = winreg.OpenKey(hkey_local_machine_reg, r'SOFTWARE\Basler\pylon')
pylon_install_folder = winreg.QueryValue(pylon_registry_key, "InstallationFolder")
# Check if install folder contain "Development" folder.
pylon_dev_dir = os.path.join(pylon_install_folder, "Development")
if os.path.exists(pylon_dev_dir):
self.PylonDevDir = pylon_dev_dir
except EnvironmentError:
pass
# Throw exception if registry fallback failed.
if not self.PylonDevDir:
raise EnvironmentError("PYLON_DEV_DIR is not set")

self.LibraryDirs = [
os.path.join(
self.PylonDevDir,
Expand Down

0 comments on commit 677f5e7

Please sign in to comment.