@@ -250,81 +250,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
250
250
SAGE_GAP_COMMAND = var ('SAGE_GAP_COMMAND' , _gap_cmd )
251
251
252
252
253
- def _get_shared_lib_path (* libnames : str ) -> Optional [str ]:
254
- """
255
- Return the full path to a shared library file installed in
256
- ``$SAGE_LOCAL/lib`` or the directories associated with the
257
- Python sysconfig.
258
-
259
- This can also be passed more than one library name (e.g. for cases where
260
- some library may have multiple names depending on the platform) in which
261
- case the first one found is returned.
262
-
263
- This supports most *NIX variants (in which ``lib<libname>.so`` is found
264
- under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
265
- extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
266
- or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
267
-
268
- For distributions like Debian that use a multiarch layout, we also try the
269
- multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
270
-
271
- This returns ``None`` if no matching library file could be found.
272
-
273
- EXAMPLES::
274
-
275
- sage: from sage.env import _get_shared_lib_path
276
- sage: "gap" in _get_shared_lib_path("gap")
277
- True
278
- sage: _get_shared_lib_path("an_absurd_lib") is None
279
- True
280
-
281
- """
282
-
283
- for libname in libnames :
284
- search_directories : List [Path ] = []
285
- patterns : List [str ] = []
286
- if sys .platform == 'cygwin' :
287
- # Later down we take the first matching DLL found, so search
288
- # SAGE_LOCAL first so that it takes precedence
289
- if SAGE_LOCAL :
290
- search_directories .append (Path (SAGE_LOCAL ) / 'bin' )
291
- search_directories .append (Path (sysconfig .get_config_var ('BINDIR' )))
292
- # Note: The following is not very robust, since if there are multible
293
- # versions for the same library this just selects one more or less
294
- # at arbitrary. However, practically speaking, on Cygwin, there
295
- # will only ever be one version
296
- patterns = [f'cyg{ libname } .dll' , f'cyg{ libname } -*.dll' ]
297
- else :
298
- if sys .platform == 'darwin' :
299
- ext = 'dylib'
300
- else :
301
- ext = 'so'
302
-
303
- if SAGE_LOCAL :
304
- search_directories .append (Path (SAGE_LOCAL ) / 'lib' )
305
- libdir = sysconfig .get_config_var ('LIBDIR' )
306
- if libdir is not None :
307
- libdir = Path (libdir )
308
- search_directories .append (libdir )
309
-
310
- multiarchlib = sysconfig .get_config_var ('MULTIARCH' )
311
- if multiarchlib is not None :
312
- search_directories .append (libdir / multiarchlib ),
313
-
314
- patterns = [f'lib{ libname } .{ ext } ' ]
315
-
316
- for directory in search_directories :
317
- for pattern in patterns :
318
- path = next (directory .glob (pattern ), None )
319
- if path is not None :
320
- return str (path .resolve ())
321
-
322
- # Just return None if no files were found
323
- return None
324
-
325
- # locate libgap shared object
326
- GAP_SO = var ("GAP_SO" , _get_shared_lib_path ("gap" , "" ))
327
-
328
253
# post process
329
254
if DOT_SAGE is not None and ' ' in DOT_SAGE :
330
255
if UNAME [:6 ] == 'CYGWIN' :
0 commit comments