From 40458339c225668027f6531237065120c27720e9 Mon Sep 17 00:00:00 2001 From: jianfengmao Date: Thu, 24 Oct 2024 13:25:22 -0600 Subject: [PATCH] Fix _find_python_dll_file --- jpyutil.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/jpyutil.py b/jpyutil.py index ee098b1..7763207 100644 --- a/jpyutil.py +++ b/jpyutil.py @@ -304,18 +304,16 @@ def _find_python_dll_file(fail=False): logger.debug("Searching for Python shared library file") # Prepare list of search directories - search_dirs = [sys.prefix] + if installed_base := sysconfig.get_config_var('installed_base'): + search_dirs.append(os.path.join(installed_base, "lib")) + extra_search_dirs = [sysconfig.get_config_var(name) for name in PYTHON_LIB_DIR_CONFIG_VAR_NAMES] for extra_dir in extra_search_dirs: if extra_dir and extra_dir not in search_dirs and os.path.exists(extra_dir): search_dirs.append(extra_dir) - if platform.system() == 'Windows': - extra_search_dirs = _get_existing_subdirs(search_dirs, "DLLs") - search_dirs = extra_search_dirs + search_dirs - multi_arch_sub_dir = sysconfig.get_config_var('multiarchsubdir') if multi_arch_sub_dir: while multi_arch_sub_dir.startswith('/'): @@ -341,14 +339,14 @@ def _find_python_dll_file(fail=False): vmin = str(sys.version_info.minor) if platform.system() == 'Windows': - versions = (vmaj + vmin, vmaj, vmaj + vmin + dll_free_threaded_suffix, vmaj + dll_free_threaded_suffix, '') + versions = (vmaj + vmin, vmaj, vmaj + vmin + dll_free_threaded_suffix, '') file_names = ['python' + v + '.dll' for v in versions] elif platform.system() == 'Darwin': - versions = (vmaj + "." + vmin, vmaj, vmaj + "." + vmin + dll_free_threaded_suffix, vmaj + dll_free_threaded_suffix, '') + versions = (vmaj + "." + vmin, vmaj, vmaj + "." + vmin + dll_free_threaded_suffix, '') file_names = ['libpython' + v + '.dylib' for v in versions] + \ ['libpython' + v + '.so' for v in versions] else: - versions = (vmaj + "." + vmin, vmaj, vmaj + "." + vmin + dll_free_threaded_suffix, vmaj + dll_free_threaded_suffix, '') + versions = (vmaj + "." + vmin, vmaj, vmaj + "." + vmin + dll_free_threaded_suffix, '') file_names = ['libpython' + v + '.so' for v in versions] logger.debug("Potential Python shared library file names: %s" % repr(file_names))