Open tornaria opened 2 years ago
We have another version of find_library
in sage.misc.compat
, could you take a look at that?
I recompiled sage with musl libc, using the bundled python and without musl-find_library.patch
so I can be more detailed about the situation:
src/sage/misc/gperftools.py
sage -t --random-seed=78105796188891934420135729057135667648 src/sage/misc/gperftools.py
**********************************************************************
File "src/sage/misc/gperftools.py", line 118, in sage.misc.gperftools.Profiler._libc
Failed example:
Profiler()._libc()
Exception raised:
Traceback (most recent call last):
File "/usr/lib/sage-9.5.beta8/local/var/lib/sage/venv-python3.9.7/lib/python3.9/site-packages/sage/doctest/forker.py", line 694, in _run
self.compile_and_execute(example, compiler, test.globs)
File "/usr/lib/sage-9.5.beta8/local/var/lib/sage/venv-python3.9.7/lib/python3.9/site-packages/sage/doctest/forker.py", line 1088, in compile_and_execute
exec(compiled, globs)
File "<doctest sage.misc.gperftools.Profiler._libc[1]>", line 1, in <module>
Profiler()._libc()
File "/usr/lib/sage-9.5.beta8/local/var/lib/sage/venv-python3.9.7/lib/python3.9/site-packages/sage/misc/gperftools.py", line 129, in _libc
raise ImportError('failed to open libc')
ImportError: failed to open libc
**********************************************************************
Explicitly:
sage: from sage.misc.gperftools import Profiler
sage: Profiler()._libc()
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-8776de42ff63> in <module>
----> 1 Profiler()._libc()
/usr/lib/sage-9.5.beta8/local/var/lib/sage/venv-python3.9.7/lib/python3.9/site-packages/sage/misc/gperftools.py in _libc(self)
127 return libc
128 else:
--> 129 raise ImportError('failed to open libc')
130
131 def _libprofiler(self):
ImportError: failed to open libc
This can be traced to
sage: import sage.misc.compat
sage: sage.misc.compat.find_library('c') is None
True
But on sys.platform == linux
the functionsage.misc.compat.find_library
is just a proxy for the python function ctypes.util.find_library
and
sage: import ctypes.util
sage: ctypes.util.find_library('c') is None
True
The patch I included fixes ctypes.util.find_library
by patching python source, fixing all three above.
Are you suggesting instead to patch sage.misc.compat.find_library
?
Set milestone to sage-9.6 after Sage 9.5 release.
Replying to @tornaria:
The patch I included fixes
ctypes.util.find_library
by patching python source, fixing all three above.Are you suggesting instead to patch
sage.misc.compat.find_library
?
If possible, working around the issue in sage would be preferable. For example we aim to support musl in Gentoo as well and would like everyone to be able to use the system python without patching it.
What is this line of code in gperftools.py
doing, anyway? To me it looks like a circuitous way of setting the OS handler for SIGPROF
to SIG_DFL
. Doesn't cysignals do that without having to guess the path to my libc.so?
And naturally, this file hasn't worked since we switched to python3.
Should be fixed in https://github.com/sagemath/sage/pull/38675
More precisely,
ctypes.util.find_library('c')
is broken which causes a failuredoctesting src/sage/misc/gperftools.py
.The current commit adds a patch that I took from void linux, which in turn it's taken from alpine linux.
See: https://git.alpinelinux.org/aports/plain/main/python3/musl-find_library.patch.
CC: @orlitzky
Component: packages: standard
Author: Gonzalo Tornaría
Branch/Commit: u/tornaria/python3-musl-find_library @
dc1a0e8
Issue created by migration from https://trac.sagemath.org/ticket/33047