[arch-commits] Commit in sagemath/trunk (is-package-installed.patch)

Antonio Rojas arojas at archlinux.org
Tue May 17 19:19:26 UTC 2016


    Date: Tuesday, May 17, 2016 @ 21:19:25
  Author: arojas
Revision: 175567

Add patch

Added:
  sagemath/trunk/is-package-installed.patch

----------------------------+
 is-package-installed.patch |  387 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 387 insertions(+)

Added: is-package-installed.patch
===================================================================
--- is-package-installed.patch	                        (rev 0)
+++ is-package-installed.patch	2016-05-17 19:19:25 UTC (rev 175567)
@@ -0,0 +1,387 @@
+diff --git a/src/sage/databases/cremona.py b/src/sage/databases/cremona.py
+index 0a5f794..2969d92 100644
+--- a/src/sage/databases/cremona.py
++++ b/src/sage/databases/cremona.py
+@@ -52,7 +52,6 @@ from sage.misc.prandom import randint
+ 
+ import sage.schemes.elliptic_curves.constructor as elliptic
+ from sql_db import SQLDatabase, verify_column
+-from sage.misc.package import is_package_installed
+ from sage.env import SAGE_SHARE
+ from sage.misc.all import walltime
+ 
+@@ -827,7 +826,7 @@ class MiniCremonaDatabase(SQLDatabase):
+             if N < self.largest_conductor():
+                 message = "There is no elliptic curve with label " + label \
+                     + " in the database"
+-            elif is_package_installed('database_cremona_ellcurve'):
++            elif os.path.isfile(os.path.join(SAGE_SHARE, "cremona", "cremona.db")):
+                 message = "There is no elliptic curve with label " + label \
+                     + " in the currently available databases"
+             else:
+@@ -1676,7 +1675,7 @@ def CremonaDatabase(name=None,mini=None,set_global=None):
+     if name is None and not set_global:
+         return _db
+     if set_global and name is None:
+-        if is_package_installed('database_cremona_ellcurve'):
++        if os.path.isfile(os.path.join(SAGE_SHARE, "cremona", "cremona.db")):
+             name = 'cremona'
+         else:
+             name = 'cremona mini'
+diff --git a/src/sage/game_theory/normal_form_game.py b/src/sage/game_theory/normal_form_game.py
+index b917d2a..80fb20c 100644
+--- a/src/sage/game_theory/normal_form_game.py
++++ b/src/sage/game_theory/normal_form_game.py
+@@ -612,8 +612,9 @@ from sage.rings.all import QQ
+ from sage.structure.sage_object import SageObject
+ from sage.matrix.constructor import matrix
+ from sage.matrix.constructor import vector
+-from sage.misc.package import is_package_installed
+ from sage.misc.temporary_file import tmp_filename
++import os
++from sage.env import SAGE_LOCAL
+ 
+ try:
+     from gambit import Game
+@@ -1315,13 +1316,13 @@ class NormalFormGame(SageObject, MutableMapping):
+             raise ValueError("utilities have not been populated")
+ 
+         if not algorithm:
+-            if is_package_installed('lrslib'):
++            if os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'lrs')):
+                 algorithm = "lrs"
+             else:
+                 algorithm = "enumeration"
+ 
+         if algorithm == "lrs":
+-            if not is_package_installed('lrslib'):
++            if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'lrs')):
+                 raise NotImplementedError("lrslib is not installed")
+ 
+             return self._solve_lrs(maximization)
+diff --git a/src/sage/geometry/polyhedron/base.py b/src/sage/geometry/polyhedron/base.py
+index 2f58d8b..eb519a2 100644
+--- a/src/sage/geometry/polyhedron/base.py
++++ b/src/sage/geometry/polyhedron/base.py
+@@ -20,7 +20,6 @@ import six
+ from sage.structure.element import Element, coerce_binop, is_Vector
+ 
+ from sage.misc.all import cached_method, prod
+-from sage.misc.package import is_package_installed
+ 
+ from sage.rings.all import QQ, ZZ
+ from sage.rings.real_double import RDF
+@@ -3690,7 +3689,9 @@ class Polyhedron_base(Element):
+ 
+              David Avis's lrs program.
+         """
+-        if not is_package_installed('lrslib'):
++        import os
++        from sage.env import SAGE_LOCAL
++        if os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'lrs')) != True:
+             raise NotImplementedError('You must install the optional lrslib package '
+                                        'for this function to work')
+ 
+diff --git a/src/sage/graphs/generators/classical_geometries.py b/src/sage/graphs/generators/classical_geometries.py
+index e80f2a5..04cd9ce 100644
+--- a/src/sage/graphs/generators/classical_geometries.py
++++ b/src/sage/graphs/generators/classical_geometries.py
+@@ -1287,10 +1287,9 @@ def CossidentePenttilaGraph(q):
+         raise ValueError('q(={}) must be an odd prime power'.format(q))
+ 
+     from sage.libs.gap.libgap import libgap
+-    from sage.misc.package import is_package_installed, PackageNotFoundError
++    from sage.interfaces.gap import gap
+ 
+-    if not is_package_installed('gap_packages'):
+-        raise PackageNotFoundError('gap_packages')
++    gap.load_package("grape")
+ 
+     adj_list=libgap.function_factory("""function(q)
+         local z, e, so, G, nu, G1, G0, B, T, s, O1, O2, x;
+diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
+index 252984f..ce19682 100644
+--- a/src/sage/graphs/generic_graph.py
++++ b/src/sage/graphs/generic_graph.py
+@@ -7833,7 +7833,6 @@ class GenericGraph(GenericGraph_pyx):
+            sage: abs(flow_ff-flow_igraph) < 0.00001         # optional python_igraph
+            True
+         """
+-        from sage.misc.package import is_package_installed
+         self._scream_if_not_simple(allow_loops=True)
+         if vertex_bound and algorithm in ["FF", "igraph"]:
+             raise ValueError("This method does not support both " +
+@@ -7851,10 +7850,12 @@ class GenericGraph(GenericGraph_pyx):
+         if algorithm is None:
+             if vertex_bound:
+                 algorithm = "LP"
+-            elif is_package_installed("python_igraph"):
+-                algorithm = "igraph"
+             else:
+-                algorithm = "FF"
++                algorithm = "igraph"
++                try:
++                    import igraph
++                except ImportError:
++                    algorithm = "FF"
+ 
+         if (algorithm == "FF"):
+             return self._ford_fulkerson(x,y, value_only=value_only, integer=integer, use_edge_labels=use_edge_labels)
+@@ -20134,17 +20135,22 @@ class GenericGraph(GenericGraph_pyx):
+             Subgroup of (Permutation Group with generators [(0,7)(1,4)(2,3)(6,8)]) generated by [(0,7)(1,4)(2,3)(6,8)]]
+ 
+         """
+-        from sage.misc.package import is_package_installed
++        has_bliss=True
++        try:
++            from sage.graphs.bliss import automorphism_group
++        except ImportError:
++            has_bliss=False
++
+         if (algorithm == 'bliss'           or   # explicit choice from the user; or
+             (algorithm is None             and  # by default
+              not edge_labels               and
+-             is_package_installed('bliss'))):
++             has_bliss)):
++
++            if (not has_bliss):
++                raise NotImplementedError("you need to install bliss or set algorithm=sage to use this command")
++
+             if edge_labels:
+                 raise ValueError("bliss cannot be used when edge_labels is True")
+-            try:
+-                from sage.graphs.bliss import automorphism_group
+-            except ImportError:
+-                raise ImportError("You must install the 'bliss' package to run this command.")
+ 
+             A = automorphism_group(self, partition)
+ 
+@@ -20786,17 +20792,22 @@ class GenericGraph(GenericGraph_pyx):
+             True
+ 
+         """
+-        from sage.misc.package import is_package_installed
++        has_bliss=True
++        try:
++            from sage.graphs.bliss import canonical_form
++        except ImportError:
++            has_bliss=False
++
+         if (algorithm == 'bliss'           or  # explicit request; or
+             (algorithm is None             and # default choice
+-             is_package_installed('bliss') and
++	     has_bliss                     and
+              not edge_labels)):
++
++            if (not has_bliss):
++                raise NotImplementedError("you need to install bliss or set algorithm=sage to use this command")
++
+             if edge_labels:
+                 raise ValueError("bliss cannot be used when edge_labels is True")
+-            try:
+-                from sage.graphs.bliss import canonical_form
+-            except ImportError:
+-                raise ImportError("You must install the 'bliss' package to run this command.")
+             return canonical_form(self, partition, return_graph, certify)
+ 
+         if (algorithm is not None and
+diff --git a/src/sage/graphs/graph_generators.py b/src/sage/graphs/graph_generators.py
+index 5919ab3..1766796 100644
+--- a/src/sage/graphs/graph_generators.py
++++ b/src/sage/graphs/graph_generators.py
+@@ -1192,8 +1192,9 @@ class GraphGenerators():
+         .. [buckygen] \G. Brinkmann, J. Goedgebeur and B.D. McKay, Generation of Fullerenes,
+           Journal of Chemical Information and Modeling, 52(11):2910-2918, 2012.
+         """
+-        from sage.misc.package import is_package_installed
+-        if not is_package_installed("buckygen"):
++        import os
++        from sage.env import SAGE_LOCAL
++        if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'buckygen')):
+             raise TypeError("the optional buckygen package is not installed")
+ 
+         # number of vertices should be positive
+@@ -1277,8 +1278,9 @@ class GraphGenerators():
+         .. [benzene] \G. Brinkmann, G. Caporossi and P. Hansen, A Constructive Enumeration of Fusenes and Benzenoids,
+           Journal of Algorithms, 45:155-166, 2002.
+         """
+-        from sage.misc.package import is_package_installed
+-        if not is_package_installed("benzene"):
++        import os
++        from sage.env import SAGE_LOCAL
++        if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'benzene')):
+             raise TypeError("the optional benzene package is not installed")
+ 
+         # number of hexagons should be positive
+@@ -1430,8 +1432,9 @@ class GraphGenerators():
+         .. [plantri] \G. Brinkmann and B.D. McKay, Fast generation of planar graphs,
+            MATCH-Communications in Mathematical and in Computer Chemistry, 58(2):323-357, 2007.
+         """
+-        from sage.misc.package import is_package_installed
+-        if not is_package_installed("plantri"):
++        import os
++        from sage.env import SAGE_LOCAL
++        if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'plantri')):
+             raise TypeError("the optional plantri package is not installed")
+ 
+         # number of vertices should be positive
+@@ -1629,8 +1632,9 @@ class GraphGenerators():
+             sage: [g.size() for g in graphs.triangulations(6, minimum_connectivity=3)] # optional plantri
+             [12, 12]
+         """
+-        from sage.misc.package import is_package_installed
+-        if not is_package_installed("plantri"):
++        import os
++        from sage.env import SAGE_LOCAL
++        if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'plantri')):
+             raise TypeError("the optional plantri package is not installed")
+ 
+         # number of vertices should be positive
+@@ -1783,8 +1787,9 @@ class GraphGenerators():
+             sage: [len(g) for g in graphs.quadrangulations(12, no_nonfacial_quadrangles=True, dual=True)]  # optional plantri
+             [10, 10]
+         """
+-        from sage.misc.package import is_package_installed
+-        if not is_package_installed("plantri"):
++        import os
++        from sage.env import SAGE_LOCAL
++        if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'plantri')):
+             raise TypeError("the optional plantri package is not installed")
+ 
+         # number of vertices should be positive
+diff --git a/src/sage/graphs/lovasz_theta.py b/src/sage/graphs/lovasz_theta.py
+index 0d345c9..60948d2 100644
+--- a/src/sage/graphs/lovasz_theta.py
++++ b/src/sage/graphs/lovasz_theta.py
+@@ -65,10 +65,9 @@ def lovasz_theta(graph):
+     from sage.misc.temporary_file import tmp_filename
+     import os, subprocess
+     from sage.env import SAGE_LOCAL
+-    from sage.misc.package import is_package_installed, PackageNotFoundError
+ 
+-    if not is_package_installed('csdp'):
+-        raise PackageNotFoundError("csdp")
++    if not os.path.isfile(os.path.join(SAGE_LOCAL, 'bin', 'theta')):
++        raise NotImplementedError("You must install csdp before using this function")
+ 
+     g = graph.relabel(inplace=False, perm=range(1,n+1)).networkx_graph()
+     tf_name = tmp_filename()
+diff --git a/src/sage/groups/generic.py b/src/sage/groups/generic.py
+index c801636..f43e6d9 100644
+--- a/src/sage/groups/generic.py
++++ b/src/sage/groups/generic.py
+@@ -1396,15 +1396,15 @@ def structure_description(G, latex=False):
+         sage: groups.matrix.GL(4,2).structure_description() # optional - database_gap
+         'A8'
+     """
+-    import re
+-    from sage.misc.package import is_package_installed
++    import re, os
++    from sage.env import SAGE_LOCAL
+     def correct_dihedral_degree(match):
+         return "%sD%d" % (match.group(1), int(match.group(2))/2)
+ 
+     try:
+         description = str(G._gap_().StructureDescription())
+     except RuntimeError:
+-        if not is_package_installed('database_gap'):
++	if not os.path.isfile(os.path.join(SAGE_LOCAL, "gap", "latest", "small", "readsml.g")):
+             raise RuntimeError("You must install the optional database_gap package first.")
+         raise
+ 
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index e42db61..d4d5684 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -143,7 +143,6 @@ from sage.groups.perm_gps.permgroup_element import PermutationGroupElement, stan
+ from sage.groups.abelian_gps.abelian_group import AbelianGroup
+ from sage.misc.cachefunc import cached_method
+ from sage.groups.class_function import ClassFunction
+-from sage.misc.package import is_package_installed
+ from sage.sets.finite_enumerated_set import FiniteEnumeratedSet
+ from sage.categories.all import FiniteEnumeratedSets
+ from sage.groups.conjugacy_classes import ConjugacyClassGAP
+@@ -188,8 +187,6 @@ def hap_decorator(f):
+     """
+     @wraps(f)
+     def wrapped(self, n, p=0):
+-        if not is_package_installed('gap_packages'):
+-            raise RuntimeError("You must install the optional gap_packages package.")
+         load_hap()
+         from sage.arith.all import is_prime
+         if not (p == 0 or is_prime(p)):
+@@ -1681,9 +1678,7 @@ class PermutationGroup_generic(group.FiniteGroup):
+         try:
+             return [Integer(n) for n in self._gap_().IdGroup()]
+         except RuntimeError:
+-            if not is_package_installed('database_gap'):
+-                raise RuntimeError("You must install the optional database_gap package first.")
+-            raise
++            raise RuntimeError("You must install the optional gap_packages package.")
+ 
+     def id(self):
+         """
+@@ -1734,9 +1729,7 @@ class PermutationGroup_generic(group.FiniteGroup):
+         try:
+             return Integer(self._gap_().PrimitiveIdentification())
+         except RuntimeError:
+-            if not is_package_installed('database_gap'):
+-                raise RuntimeError("You must install the optional database_gap package first.")
+-            raise
++            raise RuntimeError("You must install the optional gap_packages package.")
+ 
+     def center(self):
+         """
+@@ -4112,8 +4105,6 @@ class PermutationGroup_generic(group.FiniteGroup):
+         - David Joyner and Graham Ellis
+ 
+         """
+-        if not is_package_installed('gap_packages'):
+-            raise RuntimeError("You must install the optional gap_packages package.")
+         load_hap()
+         from sage.arith.all import is_prime
+         if not (p == 0 or is_prime(p)):
+diff --git a/src/sage/misc/all.py b/src/sage/misc/all.py
+index 90e6985..21daeb0 100644
+--- a/src/sage/misc/all.py
++++ b/src/sage/misc/all.py
+@@ -52,11 +52,6 @@ from fpickle import pickle_function, unpickle_function
+ 
+ from dist import install_scripts
+ 
+-from package import (install_package,
+-        installed_packages, is_package_installed,
+-        standard_packages, optional_packages, experimental_packages,
+-        upgrade, package_versions)
+-
+ from pager import pager
+ 
+ lazy_import('sage.misc.sagedoc', ['browse_sage_doc',
+diff --git a/src/sage/rings/polynomial/multi_polynomial_sequence.py b/src/sage/rings/polynomial/multi_polynomial_sequence.py
+index da41cb0..49cae0b 100644
+--- a/src/sage/rings/polynomial/multi_polynomial_sequence.py
++++ b/src/sage/rings/polynomial/multi_polynomial_sequence.py
+@@ -158,7 +158,6 @@ from sage.misc.cachefunc import cached_method
+ 
+ from types import GeneratorType
+ from sage.misc.converting_dict import KeyConvertingDict
+-from sage.misc.package import is_package_installed
+ 
+ from sage.structure.sequence import Sequence, Sequence_generic
+ 
+@@ -1428,10 +1427,11 @@ class PolynomialSequence_gf2(PolynomialSequence_generic):
+ 
+         if S != []:
+             if algorithm == "exhaustive_search":
+-                if not is_package_installed('fes'):
+-                    from sage.misc.package import PackageNotFoundError
+-                    raise PackageNotFoundError("fes")
+-                from sage.libs.fes import exhaustive_search
++                try:
++                    from sage.libs.fes import exhaustive_search
++                except ImportError:
++                    raise RuntimeError("You must install the optional fes package.")
++
+                 solutions = exhaustive_search(S, max_sols=n, verbose=verbose, **kwds)
+ 
+             elif algorithm == "polybori":



More information about the arch-commits mailing list