From dff75d20929da786a0a1d1e61302b68d0a614420 Mon Sep 17 00:00:00 2001 From: Victor Nova Date: Sun, 11 Apr 2021 14:07:36 -0700 Subject: [PATCH] do not call find_libpython as Python.Runtime can find it on its own --- pythonnet/__init__.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/pythonnet/__init__.py b/pythonnet/__init__.py index 692fd5700..188980b8b 100644 --- a/pythonnet/__init__.py +++ b/pythonnet/__init__.py @@ -29,7 +29,6 @@ def load(): if _LOADED: return - from .find_libpython import linked_libpython from os.path import join, dirname if _RUNTIME is None: @@ -38,21 +37,11 @@ def load(): set_default_runtime() dll_path = join(dirname(__file__), "runtime", "Python.Runtime.dll") - libpython = linked_libpython() - - if libpython and _FFI is None and sys.platform != "win32": - # Load and leak libpython handle s.t. the .NET runtime doesn't dlcloses - # it - import posix - - import cffi - _FFI = cffi.FFI() - _FFI.dlopen(libpython, posix.RTLD_NODELETE | posix.RTLD_LOCAL) - + _LOADER_ASSEMBLY = _RUNTIME.get_assembly(dll_path) func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"] - if func(f"{libpython or ''}".encode("utf8")) != 0: + if func(''.encode("utf8")) != 0: raise RuntimeError("Failed to initialize Python.Runtime.dll") import atexit