Date: Monday, May 16, 2016 @ 09:36:45 Author: arojas Revision: 175468
Update to 7.2 Added: sagemath-doc/trunk/linbox-1.4.patch Modified: sagemath-doc/trunk/PKGBUILD Deleted: sagemath-doc/trunk/gap-4.8.patch ------------------+ PKGBUILD | 28 +-- gap-4.8.patch | 378 ------------------------------------------ linbox-1.4.patch | 470 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 484 insertions(+), 392 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2016-05-16 06:59:07 UTC (rev 175467) +++ PKGBUILD 2016-05-16 07:36:45 UTC (rev 175468) @@ -3,22 +3,20 @@ pkgbase=sagemath-doc pkgname=(sagemath-doc sagemath-src) -pkgver=7.1 -pkgrel=2 +pkgver=7.2 +pkgrel=1 arch=(any) url="http://www.sagemath.org" license=(GPL) -makedepends=(sagemath sage-notebook python2-pyzmq python2-pillow python2-docutils ipython2-notebook python2-pkgconfig cython2) +makedepends=(sagemath sage-notebook python2-pyzmq python2-pillow python2-docutils ipython2-notebook python2-pkgconfig cython2 python2-sphinx) source=("$pkgbase-$pkgver.tar.gz::https://github.com/sagemath/sage/archive/$pkgver.tar.gz" - "https://pypi.python.org/packages/source/S/Sphinx/Sphinx-1.2.3.tar.gz" - package.patch paths.patch disable-fes.patch docbuild_main.patch gap-4.8.patch) -md5sums=('c68e846444b9370fe79f43395cdc2725' - 'a98c93124035b4cd7183604aec656cb3' + package.patch paths.patch disable-fes.patch docbuild_main.patch linbox-1.4.patch) +md5sums=('2afeb8f75a33107fef5d509698c0eabc' '9ba81f717ffd4e20b8b2f2a318307488' '1a60304525ac5a5f45114cc704807894' '4eb23a3c7363258bc9ba764d6e5512ba' 'f3bf3fa4e11e5af2bd0573cf2620e1f8' - '8f631f4132d3a97dade07e4c60044aed') + '9f1cef3e477bafebe2ad301db56db8a2') prepare() { cd sage-$pkgver @@ -33,6 +31,9 @@ # fix Cremona database detection sed -e "s|is_package_installed('database_cremona_ellcurve')|os.path.exists('/usr/share/sage/cremona/cremona.db')|" \ -i src/sage/databases/cremona.py +# fix lrs detection + sed -e "s|is_package_installed('lrslib')|os.path.exists('/usr/bin/lrs')|g" -i src/sage/geometry/polyhedron/base.py \ + -i src/sage/game_theory/normal_form_game.py # find bliss headers sed -e 's|graph.hh|bliss/graph.hh|' -i src/sage/graphs/bliss.pyx @@ -41,8 +42,8 @@ # patch -p0 -i ../fes02.patch # disable fes module, fails to build patch -p0 -i ../disable-fes.patch -# port to GAP 4.8 http://trac.sagemath.org/ticket/19911 - patch -p1 -i ../gap-4.8.patch +# port to new fflas-ffpack/givaro/linbox http://trac.sagemath.org/ticket/17635 + patch -p1 -i ../linbox-1.4.patch # fix relative imports patch -p0 -i ../docbuild_main.patch @@ -50,9 +51,8 @@ # use python2 sed -e 's|cython %s %s|cython2 %s %s|' -e 's|python setup.py|python2 setup.py|' -i src/sage/misc/cython.py - mkdir -p local-python - cp -r "$srcdir"/Sphinx-1.2.3/* local-python - cp -r src/sage_setup local-python + mkdir local-python + ln -sr src/sage_setup local-python } build() { @@ -63,7 +63,7 @@ export SAGE_DOC_SRC="$SAGE_SRC"/doc export SAGE_DOC="$SAGE_SRC"/doc export SAGE_DOC_MATHJAX=yes - export PYTHONPATH="$srcdir/sage-$pkgver/local-python" # Sphinx 1.2 is needed + export PYTHONPATH="$srcdir/sage-$pkgver/local-python" python2 sage_setup/docbuild --no-pdf-links -k all html } Deleted: gap-4.8.patch =================================================================== --- gap-4.8.patch 2016-05-16 06:59:07 UTC (rev 175467) +++ gap-4.8.patch 2016-05-16 07:36:45 UTC (rev 175468) @@ -1,378 +0,0 @@ -diff --git a/src/ext/gap/console.g b/src/ext/gap/console.g -index 57043ff..db8b925 100644 ---- a/src/ext/gap/console.g -+++ b/src/ext/gap/console.g -@@ -1,6 +1,6 @@ --# If we are loaded with a workspace then $SAGE will be defined and in -+# If we are loaded with a workspace then \$SAGE will be defined and in - # that case we need to call StartInteract so that the pager will be - # set correctly. See trac #5043. --if IsBound($SAGE) then -- $SAGE.StartInteract(); -+if IsBound(\$SAGE) then -+ \$SAGE.StartInteract(); - fi; -diff --git a/src/ext/gap/sage.g b/src/ext/gap/sage.g -index 8535b7d..2216fda 100644 ---- a/src/ext/gap/sage.g -+++ b/src/ext/gap/sage.g -@@ -2,15 +2,15 @@ - # - # SAGE support utilities to read into the GAP session. - # --$SAGE := rec(); -+\$SAGE := rec(); - --$SAGE.OldPager := Pager; -+\$SAGE.OldPager := Pager; - - --$SAGE.NewPager := -+\$SAGE.NewPager := - function( data ) - local str, lines, line, fn, start; -- str := OutputTextFile($SAGE.tempfile,false); -+ str := OutputTextFile(\$SAGE.tempfile,false); - start := 1; - if IsRecord(data) then - lines := data.lines; -@@ -30,38 +30,38 @@ $SAGE.NewPager := - Print("Page from ",start,"\n"); - end; - --$SAGE.StartInteract := function() -+\$SAGE.StartInteract := function() - MakeReadWriteGlobal("Pager"); -- Pager := $SAGE.OldPager; -- HELP_VIEWER_INFO.screen.show := $SAGE.OldPager; -+ Pager := \$SAGE.OldPager; -+ HELP_VIEWER_INFO.screen.show := \$SAGE.OldPager; - MakeReadOnlyGlobal("Pager"); - end; - - --$SAGE.StopInteract := function() -+\$SAGE.StopInteract := function() - MakeReadWriteGlobal("Pager"); -- Pager := $SAGE.NewPager; -- HELP_VIEWER_INFO.screen.show := $SAGE.NewPager; -+ Pager := \$SAGE.NewPager; -+ HELP_VIEWER_INFO.screen.show := \$SAGE.NewPager; - MakeReadOnlyGlobal("Pager"); - end; - - --$SAGE.StopInteract(); -+\$SAGE.StopInteract(); - --#$SAGE.ErrorHandler := function(m,a,m2,mode) -+#\$SAGE.ErrorHandler := function(m,a,m2,mode) - # PrintTo("*errout*", m); - # if a <> fail then - # PrintTo("*errout*",a); - # fi; --# SetErrorHandler($SAGE.ErrorHandler); -+# SetErrorHandler(\$SAGE.ErrorHandler); - # return true; - #end; - --#SetErrorHandler($SAGE.ErrorHandler); -+#SetErrorHandler(\$SAGE.ErrorHandler); - - SetAllInfoLevels(0); - --$SAGE.OperationsAdmittingFirstArgument := function(obj) -+\$SAGE.OperationsAdmittingFirstArgument := function(obj) - local hits, myflags, i, flagss, flags; - hits := []; - myflags := FlagsType(TypeObj(obj)); -@@ -78,7 +78,7 @@ $SAGE.OperationsAdmittingFirstArgument := function(obj) - end; - - --$SAGE.CleanOperationName := function(name) -+\$SAGE.CleanOperationName := function(name) - local lt, ls; - lt := Length("Tester("); - if Length(name) > lt and name{[1..lt]} = "Tester(" then -@@ -91,7 +91,7 @@ $SAGE.CleanOperationName := function(name) - return name; - end; - --$SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj) -+\$SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj) - local t, f, n, meths, i; - t := TypeObj(obj); - f := FlagsType(t); -@@ -107,11 +107,11 @@ $SAGE.HasAtLeastOneMethodAsFirstArgument := function(op,obj) - end; - - --$SAGE.PlausibleTabCompletionsForSage := function(o) -+\$SAGE.PlausibleTabCompletionsForSage := function(o) - local ops, opnames; -- ops := Filtered($SAGE.OperationsAdmittingFirstArgument(o), op -> -- $SAGE.HasAtLeastOneMethodAsFirstArgument(op,o)); -- opnames := List(ops, op -> $SAGE.CleanOperationName(NameFunction(op))); -+ ops := Filtered(\$SAGE.OperationsAdmittingFirstArgument(o), op -> -+ \$SAGE.HasAtLeastOneMethodAsFirstArgument(op,o)); -+ opnames := List(ops, op -> \$SAGE.CleanOperationName(NameFunction(op))); - return Concatenation(opnames, GLOBAL_FUNCTION_NAMES); - end; - -diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py -index 92a4393..fd856ef 100644 ---- a/src/sage/groups/finitely_presented.py -+++ b/src/sage/groups/finitely_presented.py -@@ -1168,9 +1168,7 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation, - You can attempt to reduce the presentation of the output group:: - - sage: D = C2.semidirect_product(C8, hom); D -- Finitely presented group < a, b, c, d | -- a^2, b^-1*a^-1*b*a*d^-1*c^-1, c^-1*a^-1*c*a*d^-1, d^-1*a^-1*d*a, -- b^2*c^-1, c^-1*b^-1*c*b, d^-1*b^-1*d*b, c^2*d^-1, d^-1*c^-1*d*c, d^2 > -+ Finitely presented group < a, b | a^2, b^8, a^-1*b*a*b > - sage: D = C2.semidirect_product(C8, hom, reduced=True); D - Finitely presented group < a, b | a^2, (a*b)^2, b^8 > - -@@ -1178,10 +1176,9 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation, - sage: C4 = groups.presentation.Cyclic(4) - sage: hom = (C3.gens(), [(C4.gens(), C4.gens())]) - sage: C3.semidirect_product(C4, hom) -- Finitely presented group < a, b, c | -- a^3, b^-1*a^-1*b*a, c^-1*a^-1*c*a, b^2*c^-1, c^-1*b^-1*c*b, c^2 > -+ Finitely presented group < a, b | a^3, b^4, a^-1*b*a*b^-1 > - sage: D = C3.semidirect_product(C4, hom, reduced=True); D -- Finitely presented group < a, b | a^3, b^4, b^-1*a^-1*b*a > -+ Finitely presented group < a, b | a^3, b^4, a^-1*b*a*b^-1 > - sage: D.as_permutation_group().is_cyclic() - True - -@@ -1193,9 +1190,7 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation, - sage: C12 = groups.presentation.Cyclic(12) - sage: hom = (C5.gens(), [(C12.gens(), C12.gens())]) - sage: sp = C5.semidirect_product(C12, hom, check=False); sp -- Finitely presented group < a, b, c, d | -- a^5, b^-1*a^-1*b*a, c^-1*a^-1*c*a, d^-1*a^-1*d*a, b^2*d^-1, -- c^-1*b^-1*c*b, d^-1*b^-1*d*b, c^3, d^-1*c^-1*d*c, d^2 > -+ Finitely presented group < a, b | a^5, b^12, a^-1*b*a*b^-1 > - sage: sp.as_permutation_group().is_cyclic(), sp.order() - (True, 60) - -diff --git a/src/sage/groups/matrix_gps/matrix_group.py b/src/sage/groups/matrix_gps/matrix_group.py -index 698a587..3e200e6 100644 ---- a/src/sage/groups/matrix_gps/matrix_group.py -+++ b/src/sage/groups/matrix_gps/matrix_group.py -@@ -584,19 +584,19 @@ class MatrixGroup_gap(GroupMixinLibGAP, MatrixGroup_generic, ParentLibGAP): - sage: i = iter(GL(6,5)) - sage: [ next(i) for j in range(8) ] - [ -- [1 0 0 0 0 0] [4 0 0 0 0 1] [0 4 0 0 0 0] [0 4 0 0 0 0] -- [0 1 0 0 0 0] [4 0 0 0 0 0] [0 0 4 0 0 0] [0 0 4 0 0 0] -- [0 0 1 0 0 0] [0 4 0 0 0 0] [0 0 0 4 0 0] [0 0 0 4 0 0] -- [0 0 0 1 0 0] [0 0 4 0 0 0] [0 0 0 0 4 0] [0 0 0 0 4 0] -- [0 0 0 0 1 0] [0 0 0 4 0 0] [0 0 0 0 0 4] [0 0 0 0 0 4] -- [0 0 0 0 0 1], [0 0 0 0 4 0], [1 4 0 0 0 0], [2 4 0 0 0 0], -+ [1 0 0 0 0 0] [2 0 0 0 0 0] [3 0 0 0 0 0] [3 2 0 0 0 0] -+ [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] -+ [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] -+ [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] -+ [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] -+ [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1], - <BLANKLINE> -- [3 0 0 0 0 1] [4 0 0 1 3 3] [0 0 0 2 0 0] [1 0 0 0 4 4] -- [3 0 0 0 0 0] [4 0 0 0 3 3] [0 0 0 0 4 0] [1 0 0 0 0 4] -- [0 4 0 0 0 0] [3 0 0 0 0 1] [2 2 0 0 0 2] [1 0 0 0 0 0] -- [0 0 4 0 0 0] [3 0 0 0 0 0] [1 4 0 0 0 0] [0 1 0 0 0 0] -- [0 0 0 4 0 0] [0 4 0 0 0 0] [0 2 4 0 0 0] [0 0 1 0 0 0] -- [4 0 0 0 2 3], [2 0 3 4 4 4], [0 0 1 4 0 0], [0 0 0 1 0 0] -+ [2 1 0 0 0 0] [3 3 0 2 3 0] [2 4 0 1 4 0] [1 2 4 1 0 3] -+ [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] [0 1 0 0 0 0] -+ [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] [0 0 1 0 0 0] -+ [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] [0 0 0 1 0 0] -+ [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] [0 0 0 0 1 0] -+ [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1], [0 0 0 0 0 1] - ] - - This is the direct computation in GAP, which will just run -diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py -index 2a426f1..5295949 100644 ---- a/src/sage/groups/perm_gps/permgroup.py -+++ b/src/sage/groups/perm_gps/permgroup.py -@@ -1548,18 +1548,23 @@ class PermutationGroup_generic(group.FiniteGroup): - - EXAMPLES:: - -- sage: SymmetricGroup(10).stabilizer(4)._order() -+ sage: G = SymmetricGroup(10).subgroup([(i, 10) for i in range(1, 10) if i != 4]) -+ sage: G._order() - 362880 -- sage: SymmetricGroup(10).stabilizer(4).stabilizer(5)._order() -- 40320 -- sage: SymmetricGroup(200).stabilizer(100)._order() == factorial(199) # this should be very fast -- True - - TESTS:: - - sage: [SymmetricGroup(n).stabilizer(1)._gap_().Size() for n in [4..10]] - [6, 24, 120, 720, 5040, 40320, 362880] -- sage: [SymmetricGroup(n).stabilizer(1)._order() for n in [4..10]] -+ sage: special_gens = [ -+ ....: [(3,4), (2,4)], -+ ....: [(4,5), (3,5), (2,5)], -+ ....: [(5,6), (4,6), (3,6), (2,6)], -+ ....: [(6,7), (5,7), (4,7), (3,7), (2,7)], -+ ....: [(7,8), (6,8), (5,8), (4,8), (3,8), (2,8)], -+ ....: [(8,9), (7,9), (6,9), (5,9), (4,9), (3,9), (2,9)], -+ ....: [(9,10), (8,10), (7,10), (6,10), (5,10), (4,10), (3,10), (2,10)]] -+ sage: [SymmetricGroup(n).subgroup(gen)._order() for gen in special_gens] - [6, 24, 120, 720, 5040, 40320, 362880] - """ - gens = self.gens() -diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py -index 756f701..88dbf82 100644 ---- a/src/sage/interfaces/expect.py -+++ b/src/sage/interfaces/expect.py -@@ -1423,13 +1423,13 @@ class StdOutContext: - return self.interface - - def __exit__(self, typ, value, tb): -- """ -+ r""" - EXAMPLE:: - - sage: from sage.interfaces.expect import StdOutContext - sage: with StdOutContext(gap): - ....: gap('1+1') -- $sage... -+ \$sage... - """ - if self.silent: - return -diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py -index 1f446aa..198fe84 100644 ---- a/src/sage/interfaces/gap.py -+++ b/src/sage/interfaces/gap.py -@@ -716,7 +716,7 @@ class Gap_generic(ExtraTabCompletion, Expect): - sage: gap.eval('quit;') - '' - sage: a = gap(3) -- ** Gap crashed or quit executing '$sage...:=3;;' ** -+ ** Gap crashed or quit executing '\$sage...:=3;;' ** - Restarting Gap and trying again - sage: a - 3 -@@ -858,7 +858,7 @@ class Gap_generic(ExtraTabCompletion, Expect): - EXAMPLES:: - - sage: print gap.version() -- 4.7... -+ 4.8... - """ - return self.eval('VERSION')[1:-1] - -@@ -1162,25 +1162,29 @@ class Gap(Gap_generic): - return reduce_load_GAP, tuple([]) - - def _next_var_name(self): -- """ -+ r""" - Returns the next unused variable name. - -+ Note that names starting with dollar signs are valid GAP -+ identifiers, but need to be escaped with a backslash starting -+ with GAP-4.8. -+ - EXAMPLES:: - - sage: g = Gap() - sage: g._next_var_name() -- '$sage1' -+ '\\$sage1' - sage: g(2)^2 - 4 - sage: g._next_var_name() -- '$sage...' -+ '\\$sage...' - """ - if len(self._available_vars) != 0: - v = self._available_vars[0] - del self._available_vars[0] - return v - self.__seq += 1 -- return '$sage%s'%self.__seq -+ return r'\$sage%s'%self.__seq - - def _start(self): - """ -@@ -1324,7 +1328,7 @@ class Gap(Gap_generic): - else: - tmp_to_use = self._local_tmpfile() - self.eval('SetGAPDocTextTheme("none")') -- self.eval('$SAGE.tempfile := "%s";'%tmp_to_use) -+ self.eval(r'\$SAGE.tempfile := "%s";'%tmp_to_use) - line = Expect.eval(self, "? %s"%s) - Expect.eval(self, "? 1") - match = re.search("Page from (\d+)", line) -@@ -1384,7 +1388,7 @@ class Gap(Gap_generic): - sage: gap._pre_interact() - sage: gap._post_interact() - """ -- self._eval_line("$SAGE.StartInteract();") -+ self._eval_line(r'\$SAGE.StartInteract();') - - def _post_interact(self): - """ -@@ -1393,7 +1397,7 @@ class Gap(Gap_generic): - sage: gap._pre_interact() - sage: gap._post_interact() - """ -- self._eval_line("$SAGE.StopInteract();") -+ self._eval_line(r'\$SAGE.StopInteract();') - - def _eval_line_using_file(self, line): - i = line.find(':=') -@@ -1641,7 +1645,7 @@ class GapElement(GapElement_generic): - """ - from sage.misc.misc import uniq - P = self.parent() -- v = P.eval('$SAGE.OperationsAdmittingFirstArgument(%s)'%self.name()) -+ v = P.eval(r'\$SAGE.OperationsAdmittingFirstArgument(%s)'%self.name()) - v = v.replace('Tester(','').replace('Setter(','').replace(')','').replace('\n', '') - v = v.split(',') - v = [ oper.split('"')[1] for oper in v ] -diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd -index bd945c7..fa23ba5 100644 ---- a/src/sage/libs/gap/gap_includes.pxd -+++ b/src/sage/libs/gap/gap_includes.pxd -@@ -131,7 +131,7 @@ cdef extern from "gap/objects.h": - cdef int libGAP_LAST_TESTING_TNUM - - cdef extern from "gap/read.h": -- void* libGAP_ReadEvalCommand(libGAP_Obj context) -+ void* libGAP_ReadEvalCommand(libGAP_Obj context, libGAP_UInt *dualSemicolon) - void* libGAP_ReadEvalFile() - void* libGAP_ReadEvalResult - bint libGAP_READ_ERROR() -diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx -index 52a75be..d62b8e9 100644 ---- a/src/sage/libs/gap/util.pyx -+++ b/src/sage/libs/gap/util.pyx -@@ -280,7 +280,7 @@ cdef libGAP_Obj gap_eval(str gap_string) except? NULL: - libgap_start_interaction(cmd) - try: - sig_on() -- status = libGAP_ReadEvalCommand(libGAP_BottomLVars) -+ status = libGAP_ReadEvalCommand(libGAP_BottomLVars, NULL) - if status != libGAP_STATUS_END: - libgap_call_error_handler() - sig_off() -@@ -464,7 +464,7 @@ def command(command_string): - libgap_start_interaction(cmd) - try: - sig_on() -- status = libGAP_ReadEvalCommand(libGAP_BottomLVars) -+ status = libGAP_ReadEvalCommand(libGAP_BottomLVars, NULL) - if status != libGAP_STATUS_END: - libgap_call_error_handler() - sig_off() Added: linbox-1.4.patch =================================================================== --- linbox-1.4.patch (rev 0) +++ linbox-1.4.patch 2016-05-16 07:36:45 UTC (rev 175468) @@ -0,0 +1,470 @@ +diff --git a/src/module_list.py b/src/module_list.py +index a49ed36..7798cb8 100644 +--- a/src/module_list.py ++++ b/src/module_list.py +@@ -27,6 +27,18 @@ lapack_libs = list(lapack_pc['libraries']) + lapack_library_dirs = list(lapack_pc['library_dirs']) + lapack_include_dirs = list(lapack_pc['include_dirs']) + ++# FFLAS-FFPACK ++fflas_ffpack_pc = pkgconfig.parse('fflas-ffpack') ++fflas_ffpack_libs = list(fflas_ffpack_pc['libraries']) ++fflas_ffpack_library_dirs = list(fflas_ffpack_pc['library_dirs']) ++fflas_ffpack_cflags = pkgconfig.cflags('fflas-ffpack').split() ++ ++# Givaro ++givaro_pc = pkgconfig.parse('givaro') ++givaro_libs = list(givaro_pc['libraries']) ++givaro_library_dirs = list(givaro_pc['library_dirs']) ++givaro_cflags = pkgconfig.cflags('givaro').split() ++ + # GNU Scientific Library + # Note we replace the built-in gslcblas with the above cblas + gsl_pc = pkgconfig.parse('gsl') +@@ -40,6 +52,12 @@ gd_libs = list(gd_pc['libraries']) + gd_library_dirs = list(gd_pc['library_dirs']) + gd_include_dirs = list(gd_pc['include_dirs']) + ++# LinBox ++linbox_pc = pkgconfig.parse('linbox') ++linbox_libs = list(linbox_pc['libraries']) ++linbox_library_dirs = list(linbox_pc['library_dirs']) ++linbox_cflags = pkgconfig.cflags('linbox').split() ++ + # PNG image library + png_pc = pkgconfig.parse('libpng') + png_libs = list(png_pc['libraries']) +@@ -58,9 +76,18 @@ zlib_include_dirs = list(zlib_pc['include_dirs']) + ######################################################### + + aliases = dict( ++ FFLASFFPACK_CFLAGS=fflas_ffpack_cflags, ++ FFLASFFPACK_LIBRARIES=fflas_ffpack_libs, ++ FFLASFFPACK_LIBDIR=fflas_ffpack_library_dirs, ++ GIVARO_CFLAGS=givaro_cflags, ++ GIVARO_LIBRARIES=givaro_libs, ++ GIVARO_LIBDIR=givaro_library_dirs, + GSL_LIBRARIES=gsl_libs, + GSL_LIBDIR=gsl_library_dirs, + GSL_INCDIR=gsl_include_dirs, ++ LINBOX_CFLAGS=linbox_cflags, ++ LINBOX_LIBRARIES=linbox_libs, ++ LINBOX_LIBDIR=linbox_library_dirs, + ) + + ######################################################### +@@ -85,12 +112,6 @@ except ValueError: + singular_libs = ['singular', 'flint', 'ntl', 'gmpxx', 'gmp', 'readline', 'm'] + + ######################################################### +-### Givaro flags +-######################################################### +- +-givaro_extra_compile_args =['-D__STDC_LIMIT_MACROS'] +- +-######################################################### + ### Library order + ######################################################### + +@@ -105,8 +126,7 @@ givaro_extra_compile_args =['-D__STDC_LIMIT_MACROS'] + # at the very end of the list. + library_order_list = [ + "singular", "ec", "ecm", +- "linboxsage", "ntl", "iml", "linbox", "givaro", +-] + gsl_libs + [ ++] + linbox_libs + gsl_libs + [ + "pari", "flint", "ratpoints", "ecl", "glpk", "ppl", + "arb", "fplll", "mpfi", "mpfr", "mpc", "gmp", "gmpxx", + "polybori", +@@ -593,13 +613,10 @@ ext_modules = [ + + Extension('sage.libs.linbox.linbox', + sources = ['sage/libs/linbox/linbox.pyx'], +- libraries = ['linboxsage', 'ntl', 'iml', 'linbox', +- 'givaro', 'mpfr', 'gmp', 'gmpxx'] + cblas_libs, ++ libraries = linbox_libs, + language = 'c++', + library_dirs = cblas_library_dirs, +- include_dirs = cblas_include_dirs, +- extra_compile_args = givaro_extra_compile_args, +- depends = [os.path.join(SAGE_INC, 'givaro', 'givconfig.h')]), ++ include_dirs = cblas_include_dirs), + + Extension('sage.libs.lcalc.lcalc_Lfunction', + sources = ['sage/libs/lcalc/lcalc_Lfunction.pyx'], +@@ -645,9 +662,8 @@ ext_modules = [ + + Extension('sage.libs.singular.singular', + sources = ['sage/libs/singular/singular.pyx'], +- libraries = ['givaro'] + singular_libs, +- language="c++", +- extra_compile_args = givaro_extra_compile_args), ++ libraries = singular_libs, ++ language="c++"), + + Extension('sage.libs.singular.polynomial', + sources = ['sage/libs/singular/polynomial.pyx'], +@@ -667,8 +683,7 @@ ext_modules = [ + Extension('sage.libs.singular.function', + sources = ['sage/libs/singular/function.pyx'], + libraries = singular_libs, +- language="c++", +- extra_compile_args = givaro_extra_compile_args), ++ language="c++"), + + Extension('sage.libs.singular.option', + sources = ['sage/libs/singular/option.pyx'], +@@ -923,19 +938,17 @@ ext_modules = [ + Extension('sage.matrix.matrix_modn_dense_float', + sources = ['sage/matrix/matrix_modn_dense_float.pyx'], + language="c++", +- libraries = ['ntl', 'linbox', 'givaro', 'mpfr', 'gmpxx', 'gmp'] + cblas_libs, ++ libraries = linbox_libs + cblas_libs, + library_dirs = cblas_library_dirs, +- include_dirs = cblas_include_dirs, +- extra_compile_args = ['-DDISABLE_COMMENTATOR'] + givaro_extra_compile_args), ++ include_dirs = cblas_include_dirs), + + Extension('sage.matrix.matrix_modn_dense_double', + sources = ['sage/matrix/matrix_modn_dense_double.pyx'], + language="c++", +- libraries = ['ntl', 'linbox', 'givaro', 'mpfr', 'gmpxx', 'gmp'] + cblas_libs, ++ libraries = linbox_libs + cblas_libs, + library_dirs = cblas_library_dirs, + include_dirs = cblas_include_dirs, +- extra_compile_args = ["-D_XPG6", "-DDISABLE_COMMENTATOR"] +- + m4ri_extra_compile_args + givaro_extra_compile_args), ++ extra_compile_args = ["-D_XPG6"]), + + Extension('sage.matrix.matrix_modn_sparse', + sources = ['sage/matrix/matrix_modn_sparse.pyx']), +@@ -1374,8 +1387,7 @@ ext_modules = [ + Extension('sage.rings.finite_rings.element_givaro', + sources = ["sage/rings/finite_rings/element_givaro.pyx"], + libraries = ['givaro', 'ntl', 'gmpxx', 'gmp', 'm'], +- language='c++', +- extra_compile_args = givaro_extra_compile_args), ++ language='c++'), + + Extension('sage.rings.finite_rings.element_ntl_gf2e', + sources = ['sage/rings/finite_rings/element_ntl_gf2e.pyx'], +@@ -1395,8 +1407,7 @@ ext_modules = [ + sources = ["sage/rings/finite_rings/hom_finite_field_givaro.pyx"], + # this order is needed to compile under windows. + libraries = ['givaro', 'ntl', 'gmpxx', 'gmp', 'm'], +- language='c++', +- extra_compile_args = givaro_extra_compile_args), ++ language='c++'), + + ################################ + ## +@@ -1548,8 +1559,7 @@ ext_modules = [ + Extension('sage.rings.polynomial.plural', + sources = ['sage/rings/polynomial/plural.pyx'], + libraries = ['m', 'readline', 'singular', 'givaro', 'gmpxx', 'gmp'], +- language="c++", +- extra_compile_args = givaro_extra_compile_args), ++ language="c++"), + + Extension('sage.rings.polynomial.multi_polynomial_libsingular', + sources = ['sage/rings/polynomial/multi_polynomial_libsingular.pyx'], +diff --git a/src/sage/libs/linbox/echelonform.pxd b/src/sage/libs/linbox/echelonform.pxd +index 3097c8b..cf4902d 100644 +--- a/src/sage/libs/linbox/echelonform.pxd ++++ b/src/sage/libs/linbox/echelonform.pxd +@@ -1,23 +1,27 @@ ++# distutils: extra_compile_args = LINBOX_CFLAGS ++# distutils: libraries = LINBOX_LIBRARIES ++# distutils: library_dirs = LINBOX_LIBDIR ++ + from sage.libs.linbox.modular cimport ModDoubleField, ModDoubleFieldElement, ModFloatField, ModFloatFieldElement + from libc.stdint cimport uint64_t + +-cdef extern from "linbox/matrix/blas-matrix.h" namespace "LinBox": +- cdef cppclass BlasMatrixDouble "LinBox::BlasMatrix<LinBox::Modular<double> >": ++cdef extern from "linbox/matrix/dense-matrix.h" namespace "LinBox": ++ cdef cppclass BlasMatrixDouble "LinBox::DenseMatrix<Givaro::Modular<double> >": + BlasMatrixDouble(ModDoubleField F, uint64_t nrows, uint64_t ncols) + void setEntry(size_t i, size_t j, ModDoubleFieldElement t) + ModDoubleFieldElement &getEntry(size_t i, size_t j) + +- cdef cppclass BlasMatrixFloat "LinBox::BlasMatrix<LinBox::Modular<float> >": ++ cdef cppclass BlasMatrixFloat "LinBox::DenseMatrix<Givaro::Modular<float> >": + BlasMatrixFloat(ModFloatField F, uint64_t nrows, uint64_t ncols) + void setEntry(size_t i, size_t j, ModFloatFieldElement t) + ModFloatFieldElement &getEntry(size_t i, size_t j) + + cdef extern from "linbox/algorithms/echelon-form.h": +- cdef cppclass EchelonFormDomainDouble "LinBox::EchelonFormDomain<LinBox::Modular<double> >": ++ cdef cppclass EchelonFormDomainDouble "LinBox::EchelonFormDomain<Givaro::Modular<double> >": + EchelonFormDomainDouble(ModDoubleField) + int rowReducedEchelon(BlasMatrixDouble, BlasMatrixDouble) + +- cdef cppclass EchelonFormDomainFloat "LinBox::EchelonFormDomain<LinBox::Modular<float> >": ++ cdef cppclass EchelonFormDomainFloat "LinBox::EchelonFormDomain<Givaro::Modular<float> >": + EchelonFormDomainFloat(ModFloatField) + int rowReducedEchelon(BlasMatrixFloat, BlasMatrixFloat) + +diff --git a/src/sage/libs/linbox/fflas.pxd b/src/sage/libs/linbox/fflas.pxd +index e102004..01ab1b1 100644 +--- a/src/sage/libs/linbox/fflas.pxd ++++ b/src/sage/libs/linbox/fflas.pxd +@@ -1,3 +1,7 @@ ++# distutils: extra_compile_args = FFLASFFPACK_CFLAGS ++# distutils: libraries = FFLASFFPACK_LIBRARIES ++# distutils: library_dirs = FFLASFFPACK_LIBDIR ++ + from modular cimport ModDoubleField, ModFloatField, ModDoubleFieldElement, ModFloatFieldElement + + cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "std": +diff --git a/src/sage/libs/linbox/linbox.pyx b/src/sage/libs/linbox/linbox.pyx +index e932347..a9bd6d1 100644 +--- a/src/sage/libs/linbox/linbox.pyx ++++ b/src/sage/libs/linbox/linbox.pyx +@@ -1,3 +1,7 @@ ++# distutils: extra_compile_args = LINBOX_CFLAGS ++# distutils: libraries = LINBOX_LIBRARIES ++# distutils: library_dirs = LINBOX_LIBDIR ++ + r""" + Linbox interface + """ +diff --git a/src/sage/libs/linbox/modular.pxd b/src/sage/libs/linbox/modular.pxd +index 7ef204c..ea5fb29 100644 +--- a/src/sage/libs/linbox/modular.pxd ++++ b/src/sage/libs/linbox/modular.pxd +@@ -1,10 +1,10 @@ +-cdef extern from "linbox/field/modular.h": ++cdef extern from "givaro/modular.h": + # double + +- cdef cppclass ModDoubleFieldElement "LinBox::Modular<double>::Element": ++ cdef cppclass ModDoubleFieldElement "Givaro::Modular<double>::Element": + pass + +- cdef cppclass ModDoubleField "LinBox::Modular<double>": ++ cdef cppclass ModDoubleField "Givaro::Modular<double>": + ModDoubleField(int modulus) + ModDoubleFieldElement init(ModDoubleFieldElement res, int v) + ModDoubleFieldElement init(ModDoubleFieldElement res, double v) +@@ -20,10 +20,10 @@ cdef extern from "linbox/field/modular.h": + + + # float +- cdef cppclass ModFloatFieldElement "LinBox::Modular<float>::Element": ++ cdef cppclass ModFloatFieldElement "Givaro::Modular<float>::Element": + pass + +- cdef cppclass ModFloatField "LinBox::Modular<float>": ++ cdef cppclass ModFloatField "Givaro::Modular<float>": + ModFloatField(int modulus) + ModFloatFieldElement init(ModFloatFieldElement res, int v) + ModFloatFieldElement init(ModFloatFieldElement res, double v) +diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx +index 33d7f7ec..77f6e0a 100644 +--- a/src/sage/libs/singular/singular.pyx ++++ b/src/sage/libs/singular/singular.pyx +@@ -22,6 +22,7 @@ cdef extern from "limits.h": + + import os + ++from libc.stdint cimport int64_t + from sage.libs.singular.decl cimport intvec + from sage.libs.singular.decl cimport SR_HDL, SR_INT, SR_TO_INT + from sage.libs.singular.decl cimport singular_options, singular_verbose_options +@@ -155,7 +156,7 @@ cdef FFgivE si2sa_GFqGivaro(number *n, ring *_ring, Cache_givaro cache): + order = cache.objectptr.cardinality() - 1 + + while z: +- c = cache.objectptr.initi(c, <long>napGetCoeff(z)) ++ c = cache.objectptr.initi(c, <int64_t>napGetCoeff(z)) + e = napGetExpFrom(z,1, _ring) + if e == 0: + ret = cache.objectptr.add(ret, c, ret) +diff --git a/src/sage/rings/finite_rings/element_givaro.pxd b/src/sage/rings/finite_rings/element_givaro.pxd +index 68def46..91c4ed7 100644 +--- a/src/sage/rings/finite_rings/element_givaro.pxd ++++ b/src/sage/rings/finite_rings/element_givaro.pxd +@@ -1,9 +1,15 @@ +-from sage.structure.element cimport Element, RingElement, ModuleElement +-from sage.rings.finite_rings.element_base cimport FinitePolyExtElement ++# distutils: extra_compile_args = GIVARO_CFLAGS ++ ++from libcpp.vector cimport vector ++ctypedef vector[int] intvec ++ ++from libc.stdint cimport int64_t + +-from sage.structure.parent cimport Parent ++from sage.rings.finite_rings.element_base cimport FinitePolyExtElement ++from sage.structure.parent cimport Parent + from sage.structure.sage_object cimport SageObject + ++ + cdef extern from "givaro/givconfig.h": + pass + +@@ -13,16 +19,7 @@ cdef extern from "givaro/givrandom.h": + + GivRandom GivRandomSeeded "Givaro::GivRandom"(unsigned long seed) + +-cdef extern from "givaro/givgfq.h": +- ctypedef struct intvec "std::vector<unsigned int>": +- void (* push_back)(int elem) +- +- ctypedef struct constintvec "const std::vector<unsigned int>" +- +- intvec intvec_factory "std::vector<unsigned int>"(int len) +- +-cdef extern from "givaro/givgfq.h": +- ++cdef extern from "givaro/gfq.h": + ctypedef struct GivaroGfq "Givaro::GFqDom<int>": + #attributes + unsigned int one +@@ -40,10 +37,10 @@ cdef extern from "givaro/givgfq.h": + unsigned int (* cardinality)() + int (* exponent)() + int (* random)(GivRandom gen, int res) +- int (* initi "init")(int res, int e) ++ int (* initi "init")(int res, int64_t e) + int (* initd "init")(int res, double e) + int (* indeterminate)() +- int (* convert)(int r, int p) ++ int (* convert)(int64_t r, int p) + int (* read)(int r, int p) + int (* axpyin)(int r, int a, int x) + int (* axpy)(int r, int a, int b, int c) +@@ -60,7 +57,12 @@ cdef extern from "givaro/givgfq.h": + void delete "delete "(void *o) + int gfq_element_factory "Givaro::GFqDom<int>::Element"() + +-cdef class FiniteField_givaroElement(FinitePolyExtElement) #forward declaration ++ ++cdef class FiniteField_givaroElement(FinitePolyExtElement): ++ cdef int element ++ cdef Cache_givaro _cache ++ cdef object _multiplicative_order ++ cdef FiniteField_givaroElement _new_c(self, int value) + + cdef class Cache_givaro(SageObject): + cdef GivaroGfq *objectptr # C++ object +@@ -85,11 +87,4 @@ cdef class FiniteField_givaro_iterator: + cdef int iterator + cdef Cache_givaro _cache + +-cdef class FiniteField_givaroElement(FinitePolyExtElement): +- cdef int element +- cdef Cache_givaro _cache +- cdef object _multiplicative_order +- cdef FiniteField_givaroElement _new_c(self, int value) +- +- + cdef inline FiniteField_givaroElement make_FiniteField_givaroElement(Cache_givaro cache, int x) +diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx +index d32b5cf..f2afa44 100644 +--- a/src/sage/rings/finite_rings/element_givaro.pyx ++++ b/src/sage/rings/finite_rings/element_givaro.pyx +@@ -58,8 +58,9 @@ from sage.misc.randstate cimport randstate, current_randstate + from sage.rings.finite_rings.finite_field_base cimport FiniteField + from sage.rings.ring cimport Ring + from element_ext_pari import FiniteField_ext_pariElement +-from element_pari_ffelt import FiniteFieldElement_pari_ffelt ++from element_pari_ffelt cimport FiniteFieldElement_pari_ffelt + from sage.structure.sage_object cimport SageObject ++from sage.structure.element cimport Element, ModuleElement, RingElement + import operator + import sage.arith.all + import finite_field_constructor as finite_field +@@ -373,18 +374,16 @@ cdef class Cache_givaro(SageObject): + elif isinstance(e, int) or \ + isinstance(e, Integer) or \ + isinstance(e, long) or is_IntegerMod(e): +- try: +- e_int = e +- except OverflowError: +- e_int = e % self.characteristic() ++ e_int = e % self.characteristic() + res = self.objectptr.initi(res, e_int) + + elif e is None: + e_int = 0 +- res = self.objectptr.initi(res,e_int) ++ res = self.objectptr.initi(res, e_int) + + elif isinstance(e, float): +- res = self.objectptr.initd(res,e) ++ e_int = int(e) % self.characteristic() ++ res = self.objectptr.initd(res, e_int) + + elif isinstance(e, str): + return self.parent(eval(e.replace("^","**"),self.parent.gens_dict())) +@@ -394,8 +393,8 @@ cdef class Cache_givaro(SageObject): + raise TypeError, "e.parent must match self.vector_space" + ret = self._zero_element + for i in range(len(e)): +- e_entry = e[i] % self.characteristic() +- res = self.objectptr.initi(res, int(e_entry)) ++ e_int = e[i] % self.characteristic() ++ res = self.objectptr.initi(res, e_int) + to_add = make_FiniteField_givaroElement(self, res) + ret = ret + to_add*self.parent.gen()**i + return ret +@@ -434,8 +433,8 @@ cdef class Cache_givaro(SageObject): + raise ValueError, "list is too long" + ret = self._zero_element + for i in range(len(e)): +- e_entry = e[i] % self.characteristic() +- res = self.objectptr.initi(res, int(e_entry)) ++ e_int = e[i] % self.characteristic() ++ res = self.objectptr.initi(res, e_int) + to_add = make_FiniteField_givaroElement(self, res) + ret = ret + to_add*self.parent.gen()**i + return ret +@@ -572,19 +571,17 @@ cdef class Cache_givaro(SageObject): + cdef int ret = k.zero + cdef int a = k.indeterminate() + cdef int at = k.one +- cdef unsigned int ch = k.characteristic() +- cdef int _n, t, i ++ cdef int ch = k.characteristic() ++ cdef int t, i + + if n<0 or n>k.cardinality(): + raise TypeError, "n must be between 0 and self.order()" + +- _n = n +- + for i from 0 <= i < k.exponent(): +- t = k.initi(t, _n%ch) ++ t = k.initi(t, n % ch) + ret = k.axpy(ret, t, at, ret) + at = k.mul(at,at,a) +- _n = _n/ch ++ n //= ch + return make_FiniteField_givaroElement(self, ret) + + def _element_repr(self, FiniteField_givaroElement e): +diff --git a/src/sage/rings/finite_rings/finite_field_givaro.py b/src/sage/rings/finite_rings/finite_field_givaro.py +index adbaab3..c431f6d 100644 +--- a/src/sage/rings/finite_rings/finite_field_givaro.py ++++ b/src/sage/rings/finite_rings/finite_field_givaro.py +@@ -269,7 +269,8 @@ class FiniteField_givaro(FiniteField): + sage: k(2) # indirect doctest + 0 + +- Floats coerce in: ++ Floats are converted like integers:: ++ + sage: k(float(2.0)) + 0 + +@@ -343,7 +344,7 @@ class FiniteField_givaro(FiniteField): + sage: k(pari('Mod(1,2)')) + 1 + sage: k(pari('Mod(2,3)')) +- 0 ++ a + sage: k(pari('Mod(1,3)*a^20')) + a^7 + a^5 + a^4 + a^2 +
