Skip to content

Commit

Permalink
Trac #31344: homebrew: docbuild crashes, libtcl AtForkPrepare - from …
Browse files Browse the repository at this point in the history
…sage.misc.cython globals / multiprocessing

(from #31335, reported in https://groups.google.com/g/sage-
devel/c/9EMs9h2i_H4)

URL: https://trac.sagemath.org/31344
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe, John Palmieri
Reviewer(s): John Palmieri
  • Loading branch information
Release Manager committed Feb 20, 2021
2 parents 1159ab4 + b4ceee5 commit f2fea77
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
34 changes: 23 additions & 11 deletions src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,31 @@
from sage.repl.user_globals import get_globals
from sage.misc.sage_ostools import restore_cwd, redirection
from sage.cpython.string import str_to_bytes
from sage.misc.cachefunc import cached_function

cblas_pc = pkgconfig.parse(get_cblas_pc_module_name())
cblas_libs = list(cblas_pc['libraries'])
cblas_library_dirs = list(cblas_pc['library_dirs'])
cblas_include_dirs = list(cblas_pc['include_dirs'])

standard_libs = [
'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
'ec', 'gsl',
] + cblas_libs + [
'ntl']
@cached_function
def _standard_libs_libdirs():
r"""
Return the list of libraries and library directories.
standard_libdirs = [os.path.join(SAGE_LOCAL, "lib")] + cblas_library_dirs
EXAMPLES::
sage: from sage.misc.cython import _standard_libs_libdirs
sage: _standard_libs_libdirs()
(['mpfr', 'gmp', 'gmpxx', 'pari', ...],
[...])
"""
cblas_pc = pkgconfig.parse(get_cblas_pc_module_name())
cblas_libs = list(cblas_pc['libraries'])
cblas_library_dirs = list(cblas_pc['library_dirs'])
cblas_include_dirs = list(cblas_pc['include_dirs'])
standard_libs = [
'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
'ec', 'gsl',
] + cblas_libs + [
'ntl']
standard_libdirs = [os.path.join(SAGE_LOCAL, "lib")] + cblas_library_dirs
return standard_libs, standard_libdirs

################################################################
# If the user attaches a .spyx file and changes it, we have
Expand Down Expand Up @@ -310,6 +321,7 @@ def cython(filename, verbose=0, compile_message=False,
'-Wl,--image-base=0x{:x}'.format(image_base)
])

standard_libs, standard_libdirs = _standard_libs_libdirs()
ext = Extension(name,
sources=[pyxfile],
extra_compile_args=extra_compile_args,
Expand Down
14 changes: 11 additions & 3 deletions src/sage_setup/docbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,15 @@ def clean(self, *args):

from .utils import build_many as _build_many

def build_many(target, args):
def build_many(target, args, processes=None):
"""
Thin wrapper around `sage_setup.docbuild.utils.build_many` which uses the
docbuild settings ``NUM_THREADS`` and ``ABORT_ON_ERROR``.
"""
if processes is None:
processes = NUM_THREADS
try:
_build_many(target, args, processes=NUM_THREADS)
_build_many(target, args, processes=processes)
except BaseException as exc:
if ABORT_ON_ERROR:
raise
Expand Down Expand Up @@ -349,7 +351,13 @@ def _wrapper(self, name, *args, **kwds):

# build the other documents in parallel
L = [(doc, name, kwds) + args for doc in others]
build_many(build_other_doc, L)

# Trac #31344: Work around crashes from multiprocessing
if sys.platform == 'darwin':
for target in L:
build_other_doc(target)
else:
build_many(build_other_doc, L)
logger.warning("Elapsed time: %.1f seconds."%(time.time()-start))
logger.warning("Done building the documentation!")

Expand Down

0 comments on commit f2fea77

Please sign in to comment.