2019-01-27 10:28:39 +00:00
|
|
|
diff --git a/src/sage/env.py b/src/sage/env.py
|
2021-09-14 02:56:34 +01:00
|
|
|
index c4953cfa65..47b880f9ad 100644
|
2019-01-27 10:28:39 +00:00
|
|
|
--- a/src/sage/env.py
|
|
|
|
+++ b/src/sage/env.py
|
2021-09-14 02:56:34 +01:00
|
|
|
@@ -244,81 +244,8 @@ os.environ['MPMATH_SAGE'] = '1'
|
2021-04-02 22:10:36 +01:00
|
|
|
SAGE_BANNER = var("SAGE_BANNER", "")
|
|
|
|
SAGE_IMPORTALL = var("SAGE_IMPORTALL", "yes")
|
2019-01-27 10:28:39 +00:00
|
|
|
|
|
|
|
-
|
2021-04-02 22:10:36 +01:00
|
|
|
-def _get_shared_lib_path(*libnames: str) -> Optional[str]:
|
2019-01-27 10:28:39 +00:00
|
|
|
- """
|
2020-10-22 09:20:17 +01:00
|
|
|
- Return the full path to a shared library file installed in
|
|
|
|
- ``$SAGE_LOCAL/lib`` or the directories associated with the
|
|
|
|
- Python sysconfig.
|
2019-01-27 10:28:39 +00:00
|
|
|
-
|
|
|
|
- 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>/``).
|
|
|
|
-
|
2021-04-02 22:10:36 +01:00
|
|
|
- This returns ``None`` if no matching library file could be found.
|
2019-01-27 10:28:39 +00:00
|
|
|
-
|
|
|
|
- EXAMPLES::
|
|
|
|
-
|
2021-04-02 22:10:36 +01:00
|
|
|
- sage: from sage.env import _get_shared_lib_path
|
2021-09-14 02:56:34 +01:00
|
|
|
- sage: "gap" in _get_shared_lib_path("gap")
|
2019-01-27 10:28:39 +00:00
|
|
|
- True
|
2021-04-02 22:10:36 +01:00
|
|
|
- sage: _get_shared_lib_path("an_absurd_lib") is None
|
2019-01-27 10:28:39 +00:00
|
|
|
- True
|
2021-09-14 02:56:34 +01:00
|
|
|
-
|
2019-01-27 10:28:39 +00:00
|
|
|
- """
|
|
|
|
-
|
2021-04-02 22:10:36 +01:00
|
|
|
- for libname in libnames:
|
|
|
|
- search_directories: List[Path] = []
|
|
|
|
- patterns: List[str] = []
|
2019-01-27 10:28:39 +00:00
|
|
|
- if sys.platform == 'cygwin':
|
2021-04-02 22:10:36 +01:00
|
|
|
- # Later down we take the first matching DLL found, so search
|
|
|
|
- # SAGE_LOCAL first so that it takes precedence
|
2021-07-16 21:13:01 +01:00
|
|
|
- if SAGE_LOCAL:
|
|
|
|
- search_directories.append(Path(SAGE_LOCAL) / 'bin')
|
|
|
|
- search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
|
2021-04-02 22:10:36 +01:00
|
|
|
- # Note: The following is not very robust, since if there are multible
|
2019-01-27 10:28:39 +00:00
|
|
|
- # versions for the same library this just selects one more or less
|
2021-04-02 22:10:36 +01:00
|
|
|
- # at arbitrary. However, practically speaking, on Cygwin, there
|
2019-01-27 10:28:39 +00:00
|
|
|
- # will only ever be one version
|
2021-04-02 22:10:36 +01:00
|
|
|
- patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
|
2019-01-27 10:28:39 +00:00
|
|
|
- else:
|
|
|
|
- if sys.platform == 'darwin':
|
|
|
|
- ext = 'dylib'
|
|
|
|
- else:
|
|
|
|
- ext = 'so'
|
|
|
|
-
|
2021-07-16 21:13:01 +01:00
|
|
|
- if SAGE_LOCAL:
|
|
|
|
- search_directories.append(Path(SAGE_LOCAL) / 'lib')
|
2021-04-02 22:10:36 +01:00
|
|
|
- libdir = sysconfig.get_config_var('LIBDIR')
|
|
|
|
- if libdir is not None:
|
|
|
|
- libdir = Path(libdir)
|
|
|
|
- search_directories.append(libdir)
|
|
|
|
-
|
|
|
|
- multiarchlib = sysconfig.get_config_var('MULTIARCH')
|
2021-07-16 21:13:01 +01:00
|
|
|
- if multiarchlib is not None:
|
2021-04-02 22:10:36 +01:00
|
|
|
- search_directories.append(libdir / multiarchlib),
|
2019-01-27 10:28:39 +00:00
|
|
|
-
|
2021-04-02 22:10:36 +01:00
|
|
|
- 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())
|
2019-01-27 10:28:39 +00:00
|
|
|
-
|
|
|
|
- # Just return None if no files were found
|
|
|
|
- return None
|
|
|
|
-
|
|
|
|
# locate libgap shared object
|
2021-04-02 22:10:36 +01:00
|
|
|
-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
|
|
|
|
+GAP_SO = var("GAP_SO", '/default')
|
2019-01-27 10:28:39 +00:00
|
|
|
|
|
|
|
# post process
|
2021-07-16 21:13:01 +01:00
|
|
|
if DOT_SAGE is not None and ' ' in DOT_SAGE:
|