Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f51f29a
34185: initial version
soehms Jul 15, 2022
3071dbc
34185: correction according to review
soehms Jul 18, 2022
faacd11
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Jul 24, 2022
b4b562c
34185: take care of joined features
soehms Jul 25, 2022
ddd7ada
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Aug 3, 2022
70abb3f
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Aug 4, 2022
442fca6
Merge branch 'join_feature_texfile_with_pdflatex_34282' into hide_fea…
soehms Aug 5, 2022
f39836a
Merge branch 'circular_import_matrix_space_34283' into hide_features_…
soehms Aug 5, 2022
0ec6d46
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Aug 7, 2022
f463ac7
Merge branch 'join_feature_texfile_with_pdflatex_34282' into hide_fea…
soehms Aug 9, 2022
ebbd4a4
Merge branch 'circular_import_matrix_space_34283' into hide_features_…
soehms Aug 9, 2022
6912c1c
34185: fix doctest failure + pep8 fixes
soehms Aug 9, 2022
2e11970
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Sep 3, 2022
d676f79
Merge branch 'u/soehms/join_feature_texfile_with_pdflatex_34282' of t…
soehms Sep 6, 2022
187bdcf
34185: fix typos
soehms Sep 6, 2022
2a582f4
Merge branch 'u/soehms/hide_features_34185' of trac.sagemath.org:sage…
soehms Sep 30, 2022
f69396c
Merge branch 'u/soehms/hide_features_34185' of https://github.com/sag…
soehms May 22, 2023
b695c04
34185: fix RST issues
soehms May 22, 2023
c3da4d8
34185 / 35668: fixes according to review
soehms May 25, 2023
6dff841
Merge branch 'sagemath:develop' into hide_features_34185
soehms May 25, 2023
72d9da7
Merge branch 'develop' into hide_features_34185
soehms May 30, 2023
7d58d67
Merge branch 'develop' into hide_features_34185
soehms Jun 11, 2023
560228c
Merge branch 'sagemath:develop' into hide_features_34185
soehms Jun 11, 2023
d0ccd37
Merge branch 'hide_features_34185' of github.com:soehms/sage into hid…
soehms Jun 19, 2023
97eaac9
35668: pycodestyle fix
soehms Jun 19, 2023
3103888
Merge branch 'hide_features_34185' into feature_standard_optional_static
mkoeppe Jun 23, 2023
1fcdde3
sage.features: Declare type='standard' explicitly, check against SPKG…
mkoeppe Jun 23, 2023
fd8a32d
Terminology change
mkoeppe Jun 24, 2023
ad202ba
Add 'type=standard' in more places
mkoeppe Jun 24, 2023
62ad2a3
Add 'type=standard' in more places that use pplpy
mkoeppe Jun 25, 2023
98a8664
src/sage/features/cddlib.py: Add type='standard'
mkoeppe Jun 25, 2023
4eddb7c
src/sage/misc/package.py: Do not fail if SAGE_PKGS is not set
mkoeppe Jun 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sage.features: Declare type='standard' explicitly, check against SPKG…
… type if SAGE_ROOT/build/pkgs is available
  • Loading branch information
Matthias Koeppe committed Jun 23, 2023
commit 1fcdde370d7e586a57d032c940536a5f42d751f9
29 changes: 21 additions & 8 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class Feature(TrivialUniqueRepresentation):

- ``url`` -- a URL for the upstream package providing the feature

- ``type`` -- (string) one of ``'standard'``, ``'optional'`` (default), ``'experimental'``

Overwrite :meth:`_is_present` to add feature checks.

EXAMPLES::
Expand All @@ -137,7 +139,7 @@ class Feature(TrivialUniqueRepresentation):
sage: GapPackage("grape") is GapPackage("grape")
True
"""
def __init__(self, name, spkg=None, url=None, description=None):
def __init__(self, name, spkg=None, url=None, description=None, type='optional'):
r"""
TESTS::

Expand All @@ -154,6 +156,19 @@ def __init__(self, name, spkg=None, url=None, description=None):
self._cache_is_present = None
self._cache_resolution = None
self._hidden = False
self._type = type

try:
from sage.misc.package import spkg_type
except ImportError: # may be butchered in a downstream distribution
pass
else:
if spkg and (t := spkg_type(spkg)) not in (type, None):
from warnings import warn
warn(f'Feature {name} is declared {type}, '
f'but it is provided by {spkg}, '
f'which is declared {t} in SAGE_ROOT/build/pkgs',
stacklevel=3)

def is_present(self):
r"""
Expand Down Expand Up @@ -246,7 +261,10 @@ def __repr__(self):

def _spkg_type(self):
r"""
Return the type of the SPKG corresponding to this feature.
Return the type of this feature.

For features provided by an SPKG in the Sage distribution,
this should match the SPKG type, or a warning will be issued.

EXAMPLES::

Expand All @@ -257,13 +275,8 @@ def _spkg_type(self):
OUTPUT:

The type as a string in ``('base', 'standard', 'optional', 'experimental')``.
If no SPKG corresponds to this feature ``None`` is returned.
"""
from sage.misc.package import _spkg_type
spkg = self.spkg
if not spkg:
spkg = self.name
return _spkg_type(spkg)
return self._type

def resolution(self):
r"""
Expand Down
3 changes: 2 additions & 1 deletion src/sage/features/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def __init__(self):
filename='conway_polynomials.p',
search_path=search_path,
spkg='conway_polynomials',
description="Frank Luebeck's database of Conway polynomials")
description="Frank Luebeck's database of Conway polynomials",
type='standard')


CREMONA_DATA_DIRS = set([CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR])
Expand Down
2 changes: 1 addition & 1 deletion src/sage/features/gfan.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, cmd=None):
name = "gfan"
else:
name = f"gfan_{cmd}"
Executable.__init__(self, name, executable=name, spkg="gfan")
Executable.__init__(self, name, executable=name, spkg="gfan", type='standard')


def all_features():
Expand Down
13 changes: 11 additions & 2 deletions src/sage/features/join_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class JoinFeature(Feature):
FeatureTestResult('xxyyyy', False)
"""

def __init__(self, name, features, spkg=None, url=None, description=None):
def __init__(self, name, features, spkg=None, url=None, description=None, type=None,
**kwds):
"""
TESTS:

Expand All @@ -69,7 +70,15 @@ def __init__(self, name, features, spkg=None, url=None, description=None):
raise ValueError('given features have more than one url; provide url argument')
elif len(urls) == 1:
url = next(iter(urls))
super().__init__(name, spkg=spkg, url=url, description=description)
if type is None:
if any(f._spkg_type() == 'experimental' for f in features):
type = 'experimental'
elif any(f._spkg_type() == 'optional' for f in features):
type = 'optional'
else:
type = 'standard'

super().__init__(name, spkg=spkg, url=url, description=description, type=type, **kwds)
self._features = features

def _is_present(self):
Expand Down
3 changes: 2 additions & 1 deletion src/sage/features/mip_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def __init__(self):
JoinFeature.__init__(self, 'cvxopt',
[MIPBackend('CVXOPT'),
PythonModule('cvxopt')],
spkg='cvxopt')
spkg='cvxopt',
type='standard')


def all_features():
Expand Down
3 changes: 2 additions & 1 deletion src/sage/features/nauty.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def __init__(self, name):
"""
Executable.__init__(self, name=f"nauty_{name}",
executable=f"{SAGE_NAUTY_BINS_PREFIX}{name}",
spkg="nauty")
spkg="nauty",
type="standard")


class Nauty(JoinFeature):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/features/palp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def __init__(self, palpprog, suff=None):
if suff:
Executable.__init__(self, f"palp_{palpprog}_{suff}d",
executable=f"{palpprog}-{suff}d.x",
spkg="palp")
spkg="palp", type="standard")
else:
Executable.__init__(self, f"palp_{palpprog}",
executable=f"{palpprog}.x",
spkg="palp")
spkg="palp", type="standard")

class Palp(JoinFeature):
r"""
Expand Down
38 changes: 22 additions & 16 deletions src/sage/features/sagemath.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def __init__(self):
StaticFile.__init__(self, 'sagemath_doc_html',
filename='html',
search_path=(SAGE_DOC,),
spkg='sagemath_doc_html')
spkg='sagemath_doc_html',
type='standard')


class sage__combinat(JoinFeature):
Expand All @@ -67,7 +68,7 @@ def __init__(self):
# Hence, we test a Python module within the package.
JoinFeature.__init__(self, 'sage.combinat',
[PythonModule('sage.combinat.tableau')],
spkg='sagemath_combinat')
spkg='sagemath_combinat', type="standard")


class sage__geometry__polyhedron(PythonModule):
Expand All @@ -90,7 +91,7 @@ def __init__(self):
True
"""
PythonModule.__init__(self, 'sage.geometry.polyhedron',
spkg='sagemath_polyhedra')
spkg='sagemath_polyhedra', type="standard")


class sage__graphs(JoinFeature):
Expand All @@ -113,7 +114,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.graphs',
[PythonModule('sage.graphs.graph')],
spkg='sagemath_graphs')
spkg='sagemath_graphs', type="standard")


class sage__modular(JoinFeature):
Expand All @@ -136,7 +137,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.modular',
[PythonModule('sage.modular.modform.eisenstein_submodule')],
spkg='sagemath_schemes')
spkg='sagemath_schemes', type='standard')


class sage__groups(JoinFeature):
Expand All @@ -158,7 +159,8 @@ def __init__(self):
True
"""
JoinFeature.__init__(self, 'sage.groups',
[PythonModule('sage.groups.perm_gps.permgroup')])
[PythonModule('sage.groups.perm_gps.permgroup')],
spkg='sagemath_groups', type='standard')


class sage__libs__flint(JoinFeature):
Expand All @@ -183,7 +185,7 @@ def __init__(self):
JoinFeature.__init__(self, 'sage.libs.flint',
[PythonModule('sage.libs.flint.flint'),
PythonModule('sage.libs.arb.arith')],
spkg='sagemath_flint')
spkg='sagemath_flint', type='standard')


class sage__libs__ntl(JoinFeature):
Expand All @@ -207,7 +209,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.libs.ntl',
[PythonModule('sage.libs.ntl.convert')],
spkg='sagemath_ntl')
spkg='sagemath_ntl', type='standard')


class sage__libs__pari(JoinFeature):
Expand All @@ -230,7 +232,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.libs.pari',
[PythonModule('sage.libs.pari.convert_sage')],
spkg='sagemath_pari')
spkg='sagemath_pari', type='standard')


class sage__modules(JoinFeature):
Expand All @@ -253,7 +255,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.modules',
[PythonModule('sage.modules.free_module')],
spkg='sagemath_modules')
spkg='sagemath_modules', type='standard')


class sage__plot(JoinFeature):
Expand All @@ -276,7 +278,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.plot',
[PythonModule('sage.plot.plot')],
spkg='sagemath_symbolics')
spkg='sagemath_symbolics', type='standard')


class sage__rings__finite_rings(JoinFeature):
Expand All @@ -299,7 +301,8 @@ def __init__(self):
True
"""
JoinFeature.__init__(self, 'sage.rings.finite_rings',
[PythonModule('sage.rings.finite_rings.element_pari_ffelt')])
[PythonModule('sage.rings.finite_rings.element_pari_ffelt')],
type='standard')


class sage__rings__function_field(JoinFeature):
Expand All @@ -322,7 +325,8 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.rings.function_field',
[PythonModule('sage.rings.function_field.function_field_polymod'),
sage__libs__singular()])
sage__libs__singular()],
type='standard')


class sage__rings__number_field(JoinFeature):
Expand All @@ -344,7 +348,8 @@ def __init__(self):
True
"""
JoinFeature.__init__(self, 'sage.rings.number_field',
[PythonModule('sage.rings.number_field.number_field_element')])
[PythonModule('sage.rings.number_field.number_field_element')],
type='standard')


class sage__rings__padics(JoinFeature):
Expand All @@ -366,7 +371,8 @@ def __init__(self):
True
"""
JoinFeature.__init__(self, 'sage.rings.padics',
[PythonModule('sage.rings.padics.factory')])
[PythonModule('sage.rings.padics.factory')],
type='standard')


class sage__rings__polynomial__pbori(JoinFeature):
Expand All @@ -389,7 +395,7 @@ def __init__(self):
"""
JoinFeature.__init__(self, 'sage.rings.polynomial.pbori',
[PythonModule('sage.rings.polynomial.pbori.pbori')],
spkg='sagemath_brial')
spkg='sagemath_brial', type='standard')


class sage__rings__real_double(PythonModule):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/features/singular.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
True
"""
Executable.__init__(self, "singular", SINGULAR_BIN,
spkg='singular')
spkg='singular', type='standard')


class sage__libs__singular(JoinFeature):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/features/sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self):
sage: isinstance(Sphinx(), Sphinx)
True
"""
PythonModule.__init__(self, 'sphinx', spkg='sphinx')
PythonModule.__init__(self, 'sphinx', spkg='sphinx', type='standard')


def all_features():
Expand Down
32 changes: 16 additions & 16 deletions src/sage/features/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@


def all_features():
return [PythonModule('cvxopt', spkg='cvxopt'),
PythonModule('fpylll', spkg='fpylll'),
JoinFeature('ipython', (PythonModule('IPython'),), spkg='ipython'),
JoinFeature('lrcalc_python', (PythonModule('lrcalc'),), spkg='lrcalc_python'),
PythonModule('mpmath', spkg='mpmath'),
PythonModule('networkx', spkg='networkx'),
PythonModule('numpy', spkg='numpy'),
PythonModule('pexpect', spkg='pexpect'),
JoinFeature('pillow', (PythonModule('PIL'),), spkg='pillow'),
JoinFeature('pplpy', (PythonModule('ppl'),), spkg='pplpy'),
PythonModule('primecountpy', spkg='primecountpy'),
PythonModule('ptyprocess', spkg='ptyprocess'),
PythonModule('pyparsing', spkg='pyparsing'),
PythonModule('requests', spkg='requests'),
PythonModule('scipy', spkg='scipy'),
PythonModule('sympy', spkg='sympy')]
return [PythonModule('cvxopt', spkg='cvxopt', type='standard'),
PythonModule('fpylll', spkg='fpylll', type='standard'),
JoinFeature('ipython', (PythonModule('IPython'),), spkg='ipython', type='standard'),
JoinFeature('lrcalc_python', (PythonModule('lrcalc'),), spkg='lrcalc_python', type='standard'),
PythonModule('mpmath', spkg='mpmath', type='standard'),
PythonModule('networkx', spkg='networkx', type='standard'),
PythonModule('numpy', spkg='numpy', type='standard'),
PythonModule('pexpect', spkg='pexpect', type='standard'),
JoinFeature('pillow', (PythonModule('PIL'),), spkg='pillow', type='standard'),
JoinFeature('pplpy', (PythonModule('ppl'),), spkg='pplpy', type='standard'),
PythonModule('primecountpy', spkg='primecountpy', type='standard'),
PythonModule('ptyprocess', spkg='ptyprocess', type='standard'),
PythonModule('pyparsing', spkg='pyparsing', type='standard'),
PythonModule('requests', spkg='requests', type='standard'),
PythonModule('scipy', spkg='scipy', type='standard'),
PythonModule('sympy', spkg='sympy', type='standard')]
12 changes: 7 additions & 5 deletions src/sage/misc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def pip_remote_version(pkg, pypi_url=DEFAULT_PYPI, ignore_URLError=False):
stable_releases = [v for v in info['releases'] if 'a' not in v and 'b' not in v]
return max(stable_releases)

def _spkg_type(name):

def spkg_type(name):
r"""
Return the type of the Sage package with the given name.

Expand All @@ -135,14 +136,15 @@ def _spkg_type(name):

EXAMPLES::

sage: from sage.misc.package import _spkg_type
sage: _spkg_type('pip')
sage: from sage.misc.package import spkg_type
sage: spkg_type('pip')
'standard'

OUTPUT:

The type as a string in ``('base', 'standard', 'optional', 'experimental')``.
If no ``SPKG`` exists with the given name ``None`` is returned.
If no ``SPKG`` exists with the given name (or the directory ``SAGE_PKGS`` is
not avaialble), ``None`` is returned.
"""
spkg_type = None
from sage.env import SAGE_PKGS
Expand Down Expand Up @@ -342,7 +344,7 @@ def list_packages(*pkg_types: str, pkg_sources: List[str] = ['normal', 'pip', 's

for p in lp:

typ = _spkg_type(p)
typ = spkg_type(p)
if not typ:
continue

Expand Down