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

Commit

Permalink
Merge branch 't/31365/add_ntl_to_cython_aliases' into t/31377/__confi…
Browse files Browse the repository at this point in the history
…gure___enable_editable
  • Loading branch information
Matthias Koeppe committed Feb 11, 2021
2 parents edbe3d5 + 4d2828d commit 904a494
Show file tree
Hide file tree
Showing 60 changed files with 328 additions and 81 deletions.
3 changes: 3 additions & 0 deletions build/pkgs/ntl/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ SAGE_SPKG_CONFIGURE([ntl], [
AC_SUBST(SAGE_NTL_PREFIX, ['$SAGE_LOCAL'])
else
AC_SUBST(SAGE_NTL_PREFIX, [''])
AX_ABSOLUTE_HEADER([NTL/ZZ.h])
AC_SUBST(NTL_INCDIR, [`AS_DIRNAME(AS_DIRNAME($gl_cv_absolute_NTL_ZZ_h))`])
AC_SUBST(NTL_LIBDIR, [`AS_DIRNAME($NTL_INCDIR)/lib`])
fi
])

3 changes: 3 additions & 0 deletions build/pkgs/sage_conf/src/sage_conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ MAXIMA = "@prefix@/bin/maxima"

ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"

NTL_INCDIR = "@NTL_INCDIR@"
NTL_LIBDIR = "@NTL_LIBDIR@"

# Path to the ecl-config script
# TODO: At the moment this is hard-coded, needs to be set during the configure phase if we want to support system-installed ecl.
ECL_CONFIG = "@prefix@/bin/ecl-config"
Expand Down
6 changes: 5 additions & 1 deletion src/sage/algebras/quatalg/quaternion_algebra_cython.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# distutils: language = c++
# distutils: libraries = gmp m ntl
# distutils: libraries = gmp m NTL_LIBRARIES
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
"""
Optimized Cython code needed by quaternion algebras
Expand Down
6 changes: 5 additions & 1 deletion src/sage/algebras/quatalg/quaternion_algebra_element.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# distutils: language = c++
# distutils: libraries = gmp m ntl
# distutils: libraries = gmp m NTL_LIBRARIES
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
"""
Elements of Quaternion Algebras
Expand Down
9 changes: 9 additions & 0 deletions src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
ARB_LIBRARY = var("ARB_LIBRARY", "arb")
CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
NTL_INCDIR = var("NTL_INCDIR")
NTL_LIBDIR = var("NTL_LIBDIR")

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

# NTL
aliases["NTL_CFLAGS"] = ['-std=c++11']
aliases["NTL_INCDIR"] = [NTL_INCDIR] if NTL_INCDIR else []
aliases["NTL_LIBDIR"] = [NTL_LIBDIR] if NTL_LIBDIR else []
aliases["NTL_LIBRARIES"] = ['ntl']
aliases["NTL_LIBEXTRA"] = []

return aliases
6 changes: 5 additions & 1 deletion src/sage/libs/eclib/__init__.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# distutils: language = c++
# distutils: libraries = ec ntl pari gmp m
# distutils: libraries = ec NTL_LIBRARIES pari gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA


from libcpp.map cimport map
Expand Down
7 changes: 5 additions & 2 deletions src/sage/libs/lcalc/lcalc_Lfunction.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# distutils: libraries = m ntl Lfunction
# distutils: extra_compile_args = -O3 -ffast-math
# distutils: libraries = m NTL_LIBRARIES Lfunction
# distutils: extra_compile_args = NTL_CFLAGS -O3 -ffast-math
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++
r"""
Rubinstein's lcalc library
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/convert.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# distutils: depends = NTL/ZZ.h
# distutils: libraries = ntl gmp
# distutils: libraries = NTL_LIBRARIES gmp
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

"""
Expand Down
5 changes: 5 additions & 0 deletions src/sage/libs/ntl/error.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# distutils: libraries = ntl gmp
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: libraries = NTL_LIBRARIES
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

"""
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_GF2.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp
# distutils: libraries = NTL_LIBRARIES gmp
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_GF2E.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_GF2EContext.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_GF2EX.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_GF2X.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

# ****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZX.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ_p.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ_pContext.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ_pE.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ_pEContext.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ_pEX.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

"""
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_ZZ_pX.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

# ****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_lzz_p.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

"""
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_lzz_pContext.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_lzz_pX.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

"""
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_mat_GF2.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

"""
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_mat_GF2E.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/libs/ntl/ntl_mat_ZZ.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# distutils: libraries = ntl gmp m
# distutils: libraries = NTL_LIBRARIES gmp m
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: language = c++

#*****************************************************************************
Expand Down
6 changes: 5 additions & 1 deletion src/sage/matrix/matrix_cyclo_dense.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# distutils: language = c++
# distutils: libraries = ntl
# distutils: libraries = NTL_LIBRARIES
# distutils: extra_compile_args = NTL_CFLAGS
# distutils: include_dirs = NTL_INCDIR
# distutils: library_dirs = NTL_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
"""
Matrices over Cyclotomic Fields
Expand Down
9 changes: 5 additions & 4 deletions src/sage/matrix/matrix_integer_dense.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
# distutils: extra_compile_args = M4RI_CFLAGS
# distutils: libraries = iml ntl gmp m CBLAS_LIBRARIES
# distutils: library_dirs = CBLAS_LIBDIR
# distutils: include_dirs = M4RI_INCDIR CBLAS_INCDIR
# distutils: extra_compile_args = NTL_CFLAGS M4RI_CFLAGS
# distutils: libraries = iml NTL_LIBRARIES gmp m CBLAS_LIBRARIES
# distutils: library_dirs = NTL_LIBDIR CBLAS_LIBDIR
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: include_dirs = NTL_INCDIR M4RI_INCDIR CBLAS_INCDIR
"""
Dense matrices over the integer ring
Expand Down
11 changes: 6 additions & 5 deletions src/sage/matrix/matrix_rational_dense.pyx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# distutils: extra_compile_args = -D_XPG6 M4RI_CFLAGS
# distutils: libraries = iml ntl m CBLAS_LIBRARIES
# distutils: library_dirs = CBLAS_LIBDIR
# distutils: include_dirs = M4RI_INCDIR CBLAS_INCDIR

# distutils: extra_compile_args = -D_XPG6 NTL_CFLAGS M4RI_CFLAGS
# distutils: extra_link_args = NTL_LIBEXTRA
# distutils: libraries = iml NTL_LIBRARIES m CBLAS_LIBRARIES
# distutils: library_dirs = NTL_LIBDIR CBLAS_LIBDIR
# distutils: include_dirs = NTL_INCDIR M4RI_INCDIR CBLAS_INCDIR
# distutils: language = c++
"""
Dense matrices over the rational field
Expand Down
38 changes: 25 additions & 13 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_incdirs_aliases():
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_incdirs_aliases
sage: _standard_libs_libdirs_incdirs_aliases()
(['mpfr', 'gmp', 'gmpxx', 'pari', ...],
[...],
[...],
{...})
"""
aliases = cython_aliases()
standard_libs = [
'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
'ec', 'gsl',
] + aliases["CBLAS_LIBRARIES"] + [
'ntl']
standard_libdirs = [os.path.join(SAGE_LOCAL, "lib")] + aliases["CBLAS_LIBDIR"] + aliases["NTL_LIBDIR"]
standard_incdirs = sage_include_directories() + aliases["CBLAS_INCDIR"] + aliases["NTL_INCDIR"]
return standard_libs, standard_libdirs, standard_incdirs, aliases

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

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

# Now do the actual build, directly calling Cython and distutils
from Cython.Build import cythonize
Expand Down Expand Up @@ -325,7 +337,7 @@ def cython(filename, verbose=0, compile_message=False,
with restore_cwd(target_dir):
try:
ext, = cythonize([ext],
aliases=cython_aliases(),
aliases=aliases,
include_path=includes,
compiler_directives=directives,
quiet=(verbose <= 0),
Expand Down
Loading

0 comments on commit 904a494

Please sign in to comment.