Skip to content

Commit

Permalink
gh-36765: Update to new conway-polynomials python package
Browse files Browse the repository at this point in the history
    
Fix #32747 by switching to the
newly-minted [conway-polynomials
package](https://pypi.org/project/conway-polynomials/0.7/) on pypi.

IMO `sage.databases.conway` (which makes the dict immutable by wrapping
it in a class) is of dubious value but I've left everything alone for
now.
    
URL: #36765
Reported by: Michael Orlitzky
Reviewer(s): François Bissey, Matthias Köppe, Michael Orlitzky, Tobias Diez
  • Loading branch information
Release Manager committed Dec 12, 2023
2 parents 2ab6da5 + 1685d81 commit dfdd7da
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 96 deletions.
24 changes: 19 additions & 5 deletions build/pkgs/conway_polynomials/SPKG.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
conway_polynomials: Tables of Conway polynomials over finite fields
===================================================================
conway_polynomials: Python interface to Frank Lübeck's Conway polynomial database
=================================================================================

Description
-----------

Frank Lübeck's tables of Conway polynomials over finite fields.
This python module evolved from the old SageMath *conway_polynomials*
package once hosted at,

Upstream contact
http://files.sagemath.org/spkg/upstream/conway_polynomials/

It's still maintained by Sage developers, but having a pip-installable
interface to the data will make it easier to install SageMath via pip
or another package manager.


License
-------

GPL version 3 or later


Upstream Contact
----------------

http://www.math.rwth-aachen.de/~Frank.Luebeck/data/ConwayPol/
https://github.com/sagemath/conway-polynomials
9 changes: 5 additions & 4 deletions build/pkgs/conway_polynomials/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tarball=conway_polynomials-VERSION.tar.bz2
sha1=d4d89bda60ac54e73121f84635e774766e19a8b6
md5=a2725ba21f44554196781424d957f68a
cksum=1387933493
tarball=conway-polynomials-VERSION.tar.gz
sha1=cf0904c184d7f947eaae0de1b0e2e47411e9cfda
md5=ddc0e82da67120efc353a6ec29c4cca2
cksum=2976854063
upstream_url=https://files.pythonhosted.org/packages/source/c/conway-polynomials/conway-polynomials-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
| $(PYTHON)
| $(PYTHON_TOOLCHAIN) $(PYTHON)

----------
All lines of this file are ignored except the first.
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/distros/conda.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sagemath-db-conway-polynomials
conway-polynomials
1 change: 1 addition & 0 deletions build/pkgs/conway_polynomials/distros/gentoo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev-python/conway-polynomials
1 change: 1 addition & 0 deletions build/pkgs/conway_polynomials/install-requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conway-polynomials >=0.8
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5
0.8
3 changes: 3 additions & 0 deletions build/pkgs/conway_polynomials/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([conway_polynomials], [
SAGE_PYTHON_PACKAGE_CHECK([conway_polynomials])
])
2 changes: 1 addition & 1 deletion build/pkgs/conway_polynomials/spkg-install.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exec python3 spkg-install.py
cd src && sdh_pip_install .
20 changes: 0 additions & 20 deletions build/pkgs/conway_polynomials/spkg-install.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/sage/databases/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
EXAMPLES::
sage: ConwayPolynomials()
Frank Luebeck's database of Conway polynomials
Frank Lübeck's database of Conway polynomials
sage: CremonaDatabase()
Cremona's database of elliptic curves with conductor...
Expand Down
24 changes: 7 additions & 17 deletions src/sage/databases/conway.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
r"""
Frank Luebeck's tables of Conway polynomials over finite fields
Frank Lübeck's tables of Conway polynomials over finite fields
"""
# ****************************************************************************
#
Expand All @@ -15,12 +15,6 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
from collections.abc import Mapping
import pickle

from sage.features.databases import DatabaseConwayPolynomials

_conwaydict = None


class DictInMapping(Mapping):
def __init__(self, dict):
Expand Down Expand Up @@ -95,14 +89,10 @@ def __init__(self):
sage: c = ConwayPolynomials()
sage: c
Frank Luebeck's database of Conway polynomials
Frank Lübeck's database of Conway polynomials
"""
global _conwaydict
if _conwaydict is None:
_CONWAYDATA = DatabaseConwayPolynomials().absolute_filename()
with open(_CONWAYDATA, 'rb') as f:
_conwaydict = pickle.load(f)
self._store = _conwaydict
import conway_polynomials
self._store = conway_polynomials.database()

def __repr__(self):
"""
Expand All @@ -112,9 +102,9 @@ def __repr__(self):
sage: c = ConwayPolynomials()
sage: c.__repr__()
"Frank Luebeck's database of Conway polynomials"
"Frank Lübeck's database of Conway polynomials"
"""
return "Frank Luebeck's database of Conway polynomials"
return "Frank Lübeck's database of Conway polynomials"

def __getitem__(self, key):
"""
Expand Down Expand Up @@ -152,7 +142,7 @@ def __len__(self):
sage: c = ConwayPolynomials()
sage: len(c)
35352
35357
"""
try:
return self._len
Expand Down
1 change: 0 additions & 1 deletion src/sage/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
SAGE_PKG_CONFIG_PATH = var("SAGE_PKG_CONFIG_PATH")

# installation directories for various packages
CONWAY_POLYNOMIALS_DATA_DIR = var("CONWAY_POLYNOMIALS_DATA_DIR", join(SAGE_SHARE, "conway_polynomials"))
GRAPHS_DATA_DIR = var("GRAPHS_DATA_DIR", join(SAGE_SHARE, "graphs"))
ELLCURVE_DATA_DIR = var("ELLCURVE_DATA_DIR", join(SAGE_SHARE, "ellcurves"))
POLYTOPE_DATA_DIR = var("POLYTOPE_DATA_DIR", join(SAGE_SHARE, "reflexive_polytopes"))
Expand Down
13 changes: 4 additions & 9 deletions src/sage/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ def __repr__(self):
sage: GapPackage("grape") # indirect doctest
Feature('gap_package_grape')
sage: from sage.features.databases import DatabaseConwayPolynomials
sage: DatabaseConwayPolynomials() # indirect doctest
Feature('conway_polynomials': Frank Luebeck's database of Conway polynomials)
"""
description = f'{self.name!r}: {self.description}' if self.description else f'{self.name!r}'
return f'Feature({description})'
Expand Down Expand Up @@ -342,11 +339,10 @@ def is_standard(self):
EXAMPLES::
sage: from sage.features.databases import DatabaseCremona, DatabaseConwayPolynomials
sage: from sage.features.databases import DatabaseCremona
sage: DatabaseCremona().is_standard()
False
sage: DatabaseConwayPolynomials().is_standard()
True
"""
if self.name.startswith('sage.'):
return True
Expand All @@ -358,11 +354,10 @@ def is_optional(self):
EXAMPLES::
sage: from sage.features.databases import DatabaseCremona, DatabaseConwayPolynomials
sage: from sage.features.databases import DatabaseCremona
sage: DatabaseCremona().is_optional()
True
sage: DatabaseConwayPolynomials().is_optional()
False
"""
return self._spkg_type() == 'optional'

Expand Down
36 changes: 1 addition & 35 deletions src/sage/features/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,10 @@

from . import StaticFile, PythonModule
from sage.env import (
CONWAY_POLYNOMIALS_DATA_DIR,
CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR,
POLYTOPE_DATA_DIR)


class DatabaseConwayPolynomials(StaticFile):
r"""
A :class:`~sage.features.Feature` which describes the presence of :ref:`Frank Luebeck's
database of Conway polynomials <spkg_conway_polynomials>`.
EXAMPLES::
sage: from sage.features.databases import DatabaseConwayPolynomials
sage: DatabaseConwayPolynomials().is_present()
FeatureTestResult('conway_polynomials', True)
"""

def __init__(self):
r"""
TESTS::
sage: from sage.features.databases import DatabaseConwayPolynomials
sage: isinstance(DatabaseConwayPolynomials(), DatabaseConwayPolynomials)
True
"""
if CONWAY_POLYNOMIALS_DATA_DIR:
search_path = [CONWAY_POLYNOMIALS_DATA_DIR]
else:
search_path = []
StaticFile.__init__(self, "conway_polynomials",
filename='conway_polynomials.p',
search_path=search_path,
spkg='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 Expand Up @@ -197,8 +164,7 @@ def __init__(self, name='polytopes_db', dirname='Full3D'):


def all_features():
return [DatabaseConwayPolynomials(),
DatabaseCremona(), DatabaseCremona('cremona_mini'),
return [DatabaseCremona(), DatabaseCremona('cremona_mini'),
DatabaseJones(),
DatabaseKnotInfo(),
DatabaseCubicHecke(),
Expand Down
1 change: 1 addition & 0 deletions src/setup.cfg.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ install_requires =
SPKG_INSTALL_REQUIRES_sage_conf
SPKG_INSTALL_REQUIRES_six
dnl From build/pkgs/sagelib/dependencies
SPKG_INSTALL_REQUIRES_conway_polynomials
SPKG_INSTALL_REQUIRES_cypari
SPKG_INSTALL_REQUIRES_cysignals
SPKG_INSTALL_REQUIRES_cython
Expand Down

0 comments on commit dfdd7da

Please sign in to comment.