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

Commit 904a494

Browse files
author
Matthias Koeppe
committed
Merge branch 't/31365/add_ntl_to_cython_aliases' into t/31377/__configure___enable_editable
2 parents edbe3d5 + 4d2828d commit 904a494

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+328
-81
lines changed

build/pkgs/ntl/spkg-configure.m4

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ SAGE_SPKG_CONFIGURE([ntl], [
4949
AC_SUBST(SAGE_NTL_PREFIX, ['$SAGE_LOCAL'])
5050
else
5151
AC_SUBST(SAGE_NTL_PREFIX, [''])
52+
AX_ABSOLUTE_HEADER([NTL/ZZ.h])
53+
AC_SUBST(NTL_INCDIR, [`AS_DIRNAME(AS_DIRNAME($gl_cv_absolute_NTL_ZZ_h))`])
54+
AC_SUBST(NTL_LIBDIR, [`AS_DIRNAME($NTL_INCDIR)/lib`])
5255
fi
5356
])
5457

build/pkgs/sage_conf/src/sage_conf.py.in

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ MAXIMA = "@prefix@/bin/maxima"
66

77
ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
88

9+
NTL_INCDIR = "@NTL_INCDIR@"
10+
NTL_LIBDIR = "@NTL_LIBDIR@"
11+
912
# Path to the ecl-config script
1013
# TODO: At the moment this is hard-coded, needs to be set during the configure phase if we want to support system-installed ecl.
1114
ECL_CONFIG = "@prefix@/bin/ecl-config"

src/sage/algebras/quatalg/quaternion_algebra_cython.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# distutils: language = c++
2-
# distutils: libraries = gmp m ntl
2+
# distutils: libraries = gmp m NTL_LIBRARIES
3+
# distutils: extra_compile_args = NTL_CFLAGS
4+
# distutils: include_dirs = NTL_INCDIR
5+
# distutils: library_dirs = NTL_LIBDIR
6+
# distutils: extra_link_args = NTL_LIBEXTRA
37
"""
48
Optimized Cython code needed by quaternion algebras
59

src/sage/algebras/quatalg/quaternion_algebra_element.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# distutils: language = c++
2-
# distutils: libraries = gmp m ntl
2+
# distutils: libraries = gmp m NTL_LIBRARIES
3+
# distutils: extra_compile_args = NTL_CFLAGS
4+
# distutils: include_dirs = NTL_INCDIR
5+
# distutils: library_dirs = NTL_LIBDIR
6+
# distutils: extra_link_args = NTL_LIBEXTRA
37
"""
48
Elements of Quaternion Algebras
59

src/sage/env.py

+9
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
211211
ARB_LIBRARY = var("ARB_LIBRARY", "arb")
212212
CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
213213
ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
214+
NTL_INCDIR = var("NTL_INCDIR")
215+
NTL_LIBDIR = var("NTL_LIBDIR")
214216

215217
# misc
216218
SAGE_BANNER = var("SAGE_BANNER", "")
@@ -473,4 +475,11 @@ def uname_specific(name, value, alternative):
473475
aliases["ECL_LIBRARIES"] = list(map(lambda s: s[2:], filter(lambda s: s.startswith('-l'), ecl_libs)))
474476
aliases["ECL_LIBEXTRA"] = list(filter(lambda s: not s.startswith(('-l','-L')), ecl_libs))
475477

478+
# NTL
479+
aliases["NTL_CFLAGS"] = ['-std=c++11']
480+
aliases["NTL_INCDIR"] = [NTL_INCDIR] if NTL_INCDIR else []
481+
aliases["NTL_LIBDIR"] = [NTL_LIBDIR] if NTL_LIBDIR else []
482+
aliases["NTL_LIBRARIES"] = ['ntl']
483+
aliases["NTL_LIBEXTRA"] = []
484+
476485
return aliases

src/sage/libs/eclib/__init__.pxd

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# distutils: language = c++
2-
# distutils: libraries = ec ntl pari gmp m
2+
# distutils: libraries = ec NTL_LIBRARIES pari gmp m
3+
# distutils: extra_compile_args = NTL_CFLAGS
4+
# distutils: include_dirs = NTL_INCDIR
5+
# distutils: library_dirs = NTL_LIBDIR
6+
# distutils: extra_link_args = NTL_LIBEXTRA
37

48

59
from libcpp.map cimport map

src/sage/libs/lcalc/lcalc_Lfunction.pyx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# distutils: libraries = m ntl Lfunction
2-
# distutils: extra_compile_args = -O3 -ffast-math
1+
# distutils: libraries = m NTL_LIBRARIES Lfunction
2+
# distutils: extra_compile_args = NTL_CFLAGS -O3 -ffast-math
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
36
# distutils: language = c++
47
r"""
58
Rubinstein's lcalc library

src/sage/libs/ntl/convert.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# distutils: depends = NTL/ZZ.h
2-
# distutils: libraries = ntl gmp
2+
# distutils: libraries = NTL_LIBRARIES gmp
3+
# distutils: extra_compile_args = NTL_CFLAGS
4+
# distutils: include_dirs = NTL_INCDIR
5+
# distutils: library_dirs = NTL_LIBDIR
6+
# distutils: extra_link_args = NTL_LIBEXTRA
37
# distutils: language = c++
48

59
"""

src/sage/libs/ntl/error.pyx

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# distutils: libraries = ntl gmp
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: libraries = NTL_LIBRARIES
5+
# distutils: library_dirs = NTL_LIBDIR
6+
# distutils: extra_link_args = NTL_LIBEXTRA
27
# distutils: language = c++
38

49
"""

src/sage/libs/ntl/ntl_GF2.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp
1+
# distutils: libraries = NTL_LIBRARIES gmp
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_GF2E.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_GF2EContext.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_GF2EX.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_GF2X.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
# ****************************************************************************

src/sage/libs/ntl/ntl_ZZ.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_ZZX.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_ZZ_p.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_ZZ_pContext.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_ZZ_pE.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_ZZ_pEContext.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_ZZ_pEX.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
"""

src/sage/libs/ntl/ntl_ZZ_pX.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
# ****************************************************************************

src/sage/libs/ntl/ntl_lzz_p.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
"""

src/sage/libs/ntl/ntl_lzz_pContext.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_lzz_pX.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
"""

src/sage/libs/ntl/ntl_mat_GF2.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
"""

src/sage/libs/ntl/ntl_mat_GF2E.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/libs/ntl/ntl_mat_ZZ.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# distutils: libraries = ntl gmp m
1+
# distutils: libraries = NTL_LIBRARIES gmp m
2+
# distutils: extra_compile_args = NTL_CFLAGS
3+
# distutils: include_dirs = NTL_INCDIR
4+
# distutils: library_dirs = NTL_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
26
# distutils: language = c++
37

48
#*****************************************************************************

src/sage/matrix/matrix_cyclo_dense.pyx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# distutils: language = c++
2-
# distutils: libraries = ntl
2+
# distutils: libraries = NTL_LIBRARIES
3+
# distutils: extra_compile_args = NTL_CFLAGS
4+
# distutils: include_dirs = NTL_INCDIR
5+
# distutils: library_dirs = NTL_LIBDIR
6+
# distutils: extra_link_args = NTL_LIBEXTRA
37
"""
48
Matrices over Cyclotomic Fields
59

src/sage/matrix/matrix_integer_dense.pyx

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
2-
# distutils: extra_compile_args = M4RI_CFLAGS
3-
# distutils: libraries = iml ntl gmp m CBLAS_LIBRARIES
4-
# distutils: library_dirs = CBLAS_LIBDIR
5-
# distutils: include_dirs = M4RI_INCDIR CBLAS_INCDIR
2+
# distutils: extra_compile_args = NTL_CFLAGS M4RI_CFLAGS
3+
# distutils: libraries = iml NTL_LIBRARIES gmp m CBLAS_LIBRARIES
4+
# distutils: library_dirs = NTL_LIBDIR CBLAS_LIBDIR
5+
# distutils: extra_link_args = NTL_LIBEXTRA
6+
# distutils: include_dirs = NTL_INCDIR M4RI_INCDIR CBLAS_INCDIR
67
"""
78
Dense matrices over the integer ring
89

src/sage/matrix/matrix_rational_dense.pyx

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# distutils: extra_compile_args = -D_XPG6 M4RI_CFLAGS
2-
# distutils: libraries = iml ntl m CBLAS_LIBRARIES
3-
# distutils: library_dirs = CBLAS_LIBDIR
4-
# distutils: include_dirs = M4RI_INCDIR CBLAS_INCDIR
5-
1+
# distutils: extra_compile_args = -D_XPG6 NTL_CFLAGS M4RI_CFLAGS
2+
# distutils: extra_link_args = NTL_LIBEXTRA
3+
# distutils: libraries = iml NTL_LIBRARIES m CBLAS_LIBRARIES
4+
# distutils: library_dirs = NTL_LIBDIR CBLAS_LIBDIR
5+
# distutils: include_dirs = NTL_INCDIR M4RI_INCDIR CBLAS_INCDIR
6+
# distutils: language = c++
67
"""
78
Dense matrices over the rational field
89

src/sage/misc/cython.py

+25-13
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_incdirs_aliases():
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_incdirs_aliases
44+
sage: _standard_libs_libdirs_incdirs_aliases()
45+
(['mpfr', 'gmp', 'gmpxx', 'pari', ...],
46+
[...],
47+
[...],
48+
{...})
49+
"""
50+
aliases = cython_aliases()
51+
standard_libs = [
52+
'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
53+
'ec', 'gsl',
54+
] + aliases["CBLAS_LIBRARIES"] + [
55+
'ntl']
56+
standard_libdirs = [os.path.join(SAGE_LOCAL, "lib")] + aliases["CBLAS_LIBDIR"] + aliases["NTL_LIBDIR"]
57+
standard_incdirs = sage_include_directories() + aliases["CBLAS_INCDIR"] + aliases["NTL_INCDIR"]
58+
return standard_libs, standard_libdirs, standard_incdirs, aliases
4859

4960
################################################################
5061
# If the user attaches a .spyx file and changes it, we have
@@ -266,7 +277,8 @@ def cython(filename, verbose=0, compile_message=False,
266277

267278
# Add current working directory to includes. This is needed because
268279
# we cythonize from a different directory. See Trac #24764.
269-
includes = [os.getcwd()] + sage_include_directories()
280+
standard_libs, standard_libdirs, standard_includes, aliases = _standard_libs_libdirs_incdirs_aliases()
281+
includes = [os.getcwd()] + standard_includes
270282

271283
# Now do the actual build, directly calling Cython and distutils
272284
from Cython.Build import cythonize
@@ -325,7 +337,7 @@ def cython(filename, verbose=0, compile_message=False,
325337
with restore_cwd(target_dir):
326338
try:
327339
ext, = cythonize([ext],
328-
aliases=cython_aliases(),
340+
aliases=aliases,
329341
include_path=includes,
330342
compiler_directives=directives,
331343
quiet=(verbose <= 0),

0 commit comments

Comments
 (0)