nixpkgs-suyu/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch
Mauricio Collares 46c3703ec1 sage: 9.3 -> 9.4
2021-08-22 09:53:12 -03:00

100 lines
3.9 KiB
Diff

diff --git a/src/sage/env.py b/src/sage/env.py
index 95980cc2df..37107a30e1 100644
--- a/src/sage/env.py
+++ b/src/sage/env.py
@@ -227,93 +227,12 @@ OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "")
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: 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
- 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 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 DOT_SAGE is not None and ' ' in DOT_SAGE: