Skip to content

Commit

Permalink
Fix _find_python_dll_file
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Oct 24, 2024
1 parent f42fb7e commit 4045833
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions jpyutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('/'):
Expand All @@ -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))
Expand Down

0 comments on commit 4045833

Please sign in to comment.