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":