forked from mirrors/nixpkgs
88 lines
3.3 KiB
Diff
88 lines
3.3 KiB
Diff
diff --git a/src/sage/env.py b/src/sage/env.py
|
|
index c4953cfa65..47b880f9ad 100644
|
|
--- a/src/sage/env.py
|
|
+++ b/src/sage/env.py
|
|
@@ -244,81 +244,8 @@ os.environ['MPMATH_SAGE'] = '1'
|
|
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<libname>.so`` is found
|
|
- under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
|
|
- extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
|
|
- or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
|
|
-
|
|
- For distributions like Debian that use a multiarch layout, we also try the
|
|
- multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
|
|
-
|
|
- This returns ``None`` if no matching library file could be found.
|
|
-
|
|
- EXAMPLES::
|
|
-
|
|
- sage: from sage.env import _get_shared_lib_path
|
|
- sage: "gap" in _get_shared_lib_path("gap")
|
|
- 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
|
|
- if SAGE_LOCAL:
|
|
- search_directories.append(Path(SAGE_LOCAL) / 'bin')
|
|
- search_directories.append(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'
|
|
-
|
|
- if SAGE_LOCAL:
|
|
- search_directories.append(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 libgap shared object
|
|
-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
|
|
+GAP_SO = var("GAP_SO", '/default')
|
|
|
|
# post process
|
|
if DOT_SAGE is not None and ' ' in DOT_SAGE:
|