diff --git a/src/sage/env.py b/src/sage/env.py index 2908f5d04f..81dfd75c0d 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -218,93 +218,12 @@ NTL_LIBDIR = var("NTL_LIBDIR") SAGE_BANNER = var("SAGE_BANNER", "") SAGE_IMPORTALL = var("SAGE_IMPORTALL", "yes") - -def _get_shared_lib_path(*libnames: str) -> Optional[str]: - """ - Return the full path to a shared library file installed in - ``$SAGE_LOCAL/lib`` or the directories associated with the - Python sysconfig. - - This can also be passed more than one library name (e.g. for cases where - some library may have multiple names depending on the platform) in which - case the first one found is returned. - - This supports most *NIX variants (in which ``lib.so`` is found - under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib`` - extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg.dll``, - or ``$SAGE_LOCAL/bin/cyg-*.dll`` for versioned DLLs). - - For distributions like Debian that use a multiarch layout, we also try the - multiarch lib paths (i.e. ``/usr/lib//``). - - This returns ``None`` if no matching library file could be found. - - EXAMPLES:: - - sage: import sys - sage: from fnmatch import fnmatch - sage: from sage.env import _get_shared_lib_path - sage: lib_filename = _get_shared_lib_path("Singular", "singular-Singular") - sage: if sys.platform == 'cygwin': - ....: pattern = "*/cygSingular-*.dll" - ....: elif sys.platform == 'darwin': - ....: pattern = "*/libSingular-*.dylib" - ....: else: - ....: pattern = "*/lib*Singular-*.so" - sage: fnmatch(str(lib_filename), pattern) - True - sage: _get_shared_lib_path("an_absurd_lib") is None - True - """ - - for libname in libnames: - search_directories: List[Path] = [] - patterns: List[str] = [] - if sys.platform == 'cygwin': - # Later down we take the first matching DLL found, so search - # SAGE_LOCAL first so that it takes precedence - search_directories = [ - Path(SAGE_LOCAL) / 'bin', - Path(sysconfig.get_config_var('BINDIR')), - ] - # Note: The following is not very robust, since if there are multible - # versions for the same library this just selects one more or less - # at arbitrary. However, practically speaking, on Cygwin, there - # will only ever be one version - patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll'] - else: - if sys.platform == 'darwin': - ext = 'dylib' - else: - ext = 'so' - - search_directories = [Path(SAGE_LOCAL) / 'lib'] - libdir = sysconfig.get_config_var('LIBDIR') - if libdir is not None: - libdir = Path(libdir) - search_directories.append(libdir) - - multiarchlib = sysconfig.get_config_var('MULTIARCH') - if multiarchlib is not None: - search_directories.append(libdir / multiarchlib), - - patterns = [f'lib{libname}.{ext}'] - - for directory in search_directories: - for pattern in patterns: - path = next(directory.glob(pattern), None) - if path is not None: - return str(path.resolve()) - - # Just return None if no files were found - return None - # locate singular shared object # On Debian it's libsingular-Singular so try that as well -SINGULAR_SO = var("SINGULAR_SO", _get_shared_lib_path("Singular", "singular-Singular")) +SINGULAR_SO = var("SINGULAR_SO", '/default') # locate libgap shared object -GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", "")) +GAP_SO = var("GAP_SO", '/default') # post process if ' ' in DOT_SAGE: