summaryrefslogtreecommitdiff
path: root/libre/sagemath/is-package-installed.patch
blob: 000b8cb3ea93d5fdb28a894c4a4a2cb230864f88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
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
@@ -53,7 +53,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
 
@@ -824,7 +823,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:
@@ -1673,7 +1672,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
@@ -614,8 +614,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
@@ -1317,13 +1318,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
@@ -21,7 +21,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
@@ -3691,7 +3690,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
@@ -7858,7 +7858,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 " +
@@ -7876,10 +7875,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)
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
@@ -1195,8 +1195,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
@@ -1280,8 +1281,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
@@ -1433,8 +1435,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
@@ -1632,8 +1635,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
@@ -1786,8 +1790,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
@@ -1400,15 +1400,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, "lib", "gap", "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
@@ -145,7 +145,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
@@ -190,8 +189,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)):
@@ -1682,9 +1679,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):
         """
@@ -1735,9 +1730,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):
         """
@@ -4113,8 +4106,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
@@ -53,11 +53,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
@@ -163,7 +163,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
 
@@ -1433,10 +1432,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":