Skip to content

Commit

Permalink
🚸 improve DLL patch for Z3 on Windows
Browse files Browse the repository at this point in the history
the patch will now also check for Z3 in site-packages similar to how this is done for mqt-core.
Furthermore, the condition on the Python version is dropped as it was obsolete.

Signed-off-by: burgholzer <[email protected]>
  • Loading branch information
burgholzer committed Jan 22, 2025
1 parent b71219e commit b73cdf3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/mqt/qmap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@ def _dll_patch() -> None:
import sysconfig
from pathlib import Path

bin_dir = Path(sysconfig.get_paths()["purelib"]) / "mqt" / "core" / "bin"
site_packages = Path(sysconfig.get_paths()["purelib"])
bin_dir = site_packages / "mqt" / "core" / "bin"
os.add_dll_directory(str(bin_dir))

if sys.version_info >= (3, 9, 0) and "Z3_ROOT" in os.environ:
if "Z3_ROOT" in os.environ:
lib_path = Path(os.environ["Z3_ROOT"]) / "lib"
if lib_path.exists():
os.add_dll_directory(str(lib_path))
bin_path = Path(os.environ["Z3_ROOT"]) / "bin"
if bin_path.exists():
os.add_dll_directory(str(bin_path))

z3_dir = site_packages / "z3"
if z3_dir.exists():
lib_path = z3_dir / "lib"
if lib_path.exists():
os.add_dll_directory(str(lib_path))
bin_path = z3_dir / "bin"
if bin_path.exists():
os.add_dll_directory(str(bin_path))

_dll_patch()
del _dll_patch

Expand Down

0 comments on commit b73cdf3

Please sign in to comment.