Skip to content
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pysrc/juliacall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,29 @@ def backtrace(self):

def init():
import os
if "CONDA_PREFIX" in os.environ: #It does only when calling from PythonCall
## For Windows and Python 3.8+ we need to add dll search paths
import sys
if os.name == "nt" and sys.hexversion >= 0x308000:
conda_environment_path = os.environ["CONDA_PREFIX"]
dll_search_paths = [
conda_environment_path,
os.path.join(conda_environment_path, "Library", "mingw-w64", "bin"),
os.path.join(conda_environment_path, "Library", "usr", "bin"),
os.path.join(conda_environment_path, "Library", "bin"),
os.path.join(conda_environment_path, "Scripts"),
os.path.join(conda_environment_path, "bin")
]
for path in dll_search_paths:
if os.path.exists(path):
os.add_dll_directory(path)
import ctypes as c
import sys
import subprocess
import warnings



# importing pytorch before juliacall sometimes causes segfaults. TODO: remove
if "torch" in sys.modules:
warnings.warn(
Expand Down