Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 7369a3e

Browse files
author
Matthias Koeppe
committed
Merge branch 't/31344/homebrew__docbuild_crashes__libtcl_atforkprepare' into t/31365/add_ntl_to_cython_aliases
2 parents 0d278e1 + b4ceee5 commit 7369a3e

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

src/sage/misc/cython.py

+23-11
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,31 @@
3131
from sage.repl.user_globals import get_globals
3232
from sage.misc.sage_ostools import restore_cwd, redirection
3333
from sage.cpython.string import str_to_bytes
34+
from sage.misc.cachefunc import cached_function
3435

35-
cblas_pc = pkgconfig.parse(get_cblas_pc_module_name())
36-
cblas_libs = list(cblas_pc['libraries'])
37-
cblas_library_dirs = list(cblas_pc['library_dirs'])
38-
cblas_include_dirs = list(cblas_pc['include_dirs'])
39-
40-
standard_libs = [
41-
'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
42-
'ec', 'gsl',
43-
] + cblas_libs + [
44-
'ntl']
36+
@cached_function
37+
def _standard_libs_libdirs():
38+
r"""
39+
Return the list of libraries and library directories.
4540
46-
standard_libdirs = [os.path.join(SAGE_LOCAL, "lib")] + cblas_library_dirs
41+
EXAMPLES::
4742
43+
sage: from sage.misc.cython import _standard_libs_libdirs
44+
sage: _standard_libs_libdirs()
45+
(['mpfr', 'gmp', 'gmpxx', 'pari', ...],
46+
[...])
47+
"""
48+
cblas_pc = pkgconfig.parse(get_cblas_pc_module_name())
49+
cblas_libs = list(cblas_pc['libraries'])
50+
cblas_library_dirs = list(cblas_pc['library_dirs'])
51+
cblas_include_dirs = list(cblas_pc['include_dirs'])
52+
standard_libs = [
53+
'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
54+
'ec', 'gsl',
55+
] + cblas_libs + [
56+
'ntl']
57+
standard_libdirs = [os.path.join(SAGE_LOCAL, "lib")] + cblas_library_dirs
58+
return standard_libs, standard_libdirs
4859

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

324+
standard_libs, standard_libdirs = _standard_libs_libdirs()
313325
ext = Extension(name,
314326
sources=[pyxfile],
315327
extra_compile_args=extra_compile_args,

src/sage_setup/docbuild/__init__.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,15 @@ def clean(self, *args):
286286

287287
from .utils import build_many as _build_many
288288

289-
def build_many(target, args):
289+
def build_many(target, args, processes=None):
290290
"""
291291
Thin wrapper around `sage_setup.docbuild.utils.build_many` which uses the
292292
docbuild settings ``NUM_THREADS`` and ``ABORT_ON_ERROR``.
293293
"""
294+
if processes is None:
295+
processes = NUM_THREADS
294296
try:
295-
_build_many(target, args, processes=NUM_THREADS)
297+
_build_many(target, args, processes=processes)
296298
except BaseException as exc:
297299
if ABORT_ON_ERROR:
298300
raise
@@ -349,7 +351,13 @@ def _wrapper(self, name, *args, **kwds):
349351

350352
# build the other documents in parallel
351353
L = [(doc, name, kwds) + args for doc in others]
352-
build_many(build_other_doc, L)
354+
355+
# Trac #31344: Work around crashes from multiprocessing
356+
if sys.platform == 'darwin':
357+
for target in L:
358+
build_other_doc(target)
359+
else:
360+
build_many(build_other_doc, L)
353361
logger.warning("Elapsed time: %.1f seconds."%(time.time()-start))
354362
logger.warning("Done building the documentation!")
355363

0 commit comments

Comments
 (0)