Skip to content

Commit

Permalink
Trac #28242: spkg-configure.m4 for pari
Browse files Browse the repository at this point in the history
libpari-gmp is a dependency of many packages, so it's important to be
able to use the one from the system.

We check that system's PARI/GP environment is close enough to what we
would install in Sage (i.e. versions of GP and libpari, and that they
share the datadir). Also, PARI packages need to be checked.

URL: https://trac.sagemath.org/28242
Reported by: dimpase
Ticket author(s): Dima Pasechnik
Reviewer(s): Isuru Fernando
  • Loading branch information
Release Manager committed Aug 10, 2019
2 parents 9a77264 + dd2b3fa commit ecdd404
Show file tree
Hide file tree
Showing 22 changed files with 204 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build/pkgs/eclib/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cd src/


sdh_configure $SAGE_CONFIGURE_NTL \
--with-pari="$SAGE_LOCAL" \
$SAGE_CONFIGURE_PARI \
$SAGE_CONFIGURE_FLINT \
--with-boost="no" \
--disable-allprogs
Expand Down
33 changes: 33 additions & 0 deletions build/pkgs/gp2c/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
SAGE_SPKG_CONFIGURE([gp2c], [
AC_REQUIRE([SAGE_SPKG_CONFIGURE_PARI])
AC_MSG_CHECKING([installing pari? ])
if test x$sage_spkg_install_pari = xyes; then
AC_MSG_RESULT([yes; install gp2c as well])
sage_spkg_install_gp2c=yes
libpari_pari_cfg='$SAGE_LOCAL/lib/pari/pari.cfg'
AC_MSG_NOTICE([pari.cfg is $libpari_pari_cfg ])
else
AC_MSG_RESULT([no])
AC_PATH_PROG([GP2C], [gp2c])
if test x$GP2C = x; then
AC_MSG_NOTICE([using pari/gp from the system, but building gp2c])
AC_MSG_NOTICE([one might prefer to install a system-wide gp2c, instead])
AC_MSG_NOTICE([and re-run configure.])
dnl need to figure out libpari prefix
gp_prefix=`dirname $GP`
gp_prefix=`dirname $gp_prefix`
AC_MSG_NOTICE([gp prefix is $gp_prefix ])
libpari_pari_cfg=`find $gp_prefix -name pari.cfg`
AC_MSG_NOTICE([pari.cfg is $libpari_pari_cfg ])
sage_spkg_install_gp2c=yes
fi
fi
], [], [], [
if test x$sage_spkg_install_gp2c = xyes; then
AC_SUBST(SAGE_PARI_CFG, [$libpari_pari_cfg])
AC_MSG_RESULT([using Sage's gp2c SPKG])
else
AC_SUBST(SAGE_PARI_CFG, [''])
AC_MSG_RESULT([using gp2c from the system])
fi
])
2 changes: 1 addition & 1 deletion build/pkgs/gp2c/spkg-install
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cd src
sdh_configure --with-paricfg="$SAGE_LOCAL/lib/pari/pari.cfg"
sdh_configure --with-paricfg=$SAGE_PARI_CFG
sdh_make
sdh_make_install
113 changes: 113 additions & 0 deletions build/pkgs/pari/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
SAGE_SPKG_CONFIGURE([pari], [
dnl See gp_version below on how the version is computed from MAJV.MINV.PATCHV
m4_pushdef([SAGE_PARI_MINVER],["133889"])
AC_REQUIRE([SAGE_SPKG_CONFIGURE_GMP])
AC_REQUIRE([SAGE_SPKG_CONFIGURE_READLINE])
AC_MSG_CHECKING([installing gmp/mpir or readline? ])
if test x$sage_spkg_install_mpir = xyes -o x$sage_spkg_install_gmp = xyes -o x$sage_spkg_install_readline = xyes; then dnl deps test
AC_MSG_RESULT([yes; install pari as well])
sage_spkg_install_pari=yes
else
AC_MSG_RESULT([no])
AC_MSG_CHECKING([installing PARI/GP packages? ])
AC_PATH_PROG([GP], [gp])
if test x$GP = x; then dnl GP test
AC_MSG_NOTICE([gp is not found])
sage_spkg_install_pari=yes
else
AC_MSG_CHECKING([is pari_elldata installed? ])
gp_ell_check=`echo "r=ellinit(\"11a1\"); r[[11]]" | $GP -qf 2>> config.log`
if test x$gp_ell_check = x20008; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no; cannot use system pari/GP without elldata package])
AC_MSG_NOTICE([Install elldata package and reconfigure.])
AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.])
sage_spkg_install_pari=yes
fi
AC_MSG_CHECKING([is pari_galdata installed? ])
gp_gal_check=`echo "polgalois(x^8-2)[[1]]" | $GP -qf 2>> config.log`
if test x$gp_gal_check = x16; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no; cannot use system pari/GP without gapdata package])
AC_MSG_NOTICE([Install galdata package and reconfigure.])
AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.])
sage_spkg_install_pari=yes
fi
AC_MSG_CHECKING([is pari_galpol installed? ])
gp_galp_check=`echo "galoisgetname(12,1)" | $GP -qf 2>> config.log`
if test "x$gp_galp_check = xC3\ \:\ C4"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no; cannot use system pari/GP without galpol package])
AC_MSG_NOTICE([Install galpol package and reconfigure.])
AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.])
sage_spkg_install_pari=yes
fi
AC_MSG_CHECKING([is pari_seadata installed? ])
gp_seadat_check=`echo "poldegree(ellmodulareqn(211)[[1]])" | $GP -qf 2>> config.log`
if test x$gp_seadat_check = x212; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no; cannot use system pari/GP without seadata package])
AC_MSG_NOTICE([Install seadata package and reconfigure.])
AC_MSG_NOTICE([Otherwise Sage will build its own pari/GP.])
sage_spkg_install_pari=yes
fi
fi dnl end GP test
if test x$sage_spkg_install_pari = x; then dnl main PARI test
AC_MSG_RESULT([no])
AC_CHECK_HEADER([pari/pari.h], [], [sage_spkg_install_pari=yes])
dnl matpermanent appears in pari 2.11
AC_SEARCH_LIBS([matpermanent], [pari], [
AC_MSG_CHECKING([getting GP's version ])
gp_version=`echo "v=version(); v[[1]]<<16 + v[[2]]<<8 + v[[3]]" | $GP -qf 2>> config.log`
AC_MSG_RESULT([$gp_version])
AC_MSG_CHECKING([comparing GP and libpari versions])
AC_LANG_PUSH(C)
AC_RUN_IFELSE([AC_LANG_PROGRAM([
[#include <pari/pari.h>]],
[[long vers;]
[pari_init(5000000, 2);]
[vers=paricfg_version_code;]
[pari_close()];
[return vers!=$gp_version;]])],
[AC_MSG_RESULT([libpari's and GP's versions match. Good])],
[AC_MSG_RESULT([libpari's version does not match GP's version. Not good])
sage_spkg_install_pari=yes])
AC_MSG_CHECKING([is GP's version good enough? ])
AX_COMPARE_VERSION([$gp_version], [ge], [$SAGE_PARI_MINVER], [
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([getting GP's datadir])
gp_datadir=`echo "default(datadir)" | $GP -qf 2>> config.log`
AC_MSG_RESULT([$gp_datadir])
AC_MSG_CHECKING([comparing GP's and libpari's datadirs])
AC_RUN_IFELSE([AC_LANG_PROGRAM([
[#include <pari/pari.h>]],
[[int t;]
[pari_init(5000000, 2);]
[t=strcmp(paricfg_datadir,$gp_datadir);]
[pari_close()];
[return t;]])],
[AC_MSG_RESULT([libpari's and GP's datadirs match. Good])],
[AC_MSG_RESULT([libpari's datadir does not match GP's datadir. Not good])
sage_spkg_install_pari=yes])
], [
AC_MSG_RESULT([no])
sage_spkg_install_pari=yes])
AC_LANG_POP()
], [sage_spkg_install_pari=yes])
fi dnl end main PARI test
fi dnl end deps test
m4_popdef([SAGE_PARI_MINVER])
], [], [], [
if test x$sage_spkg_install_pari = xyes; then
AC_SUBST(SAGE_PARI_PREFIX, ['$SAGE_LOCAL'])
AC_MSG_RESULT([using Sage's pari SPKG])
else
AC_SUBST(SAGE_PARI_PREFIX, [''])
AC_MSG_RESULT([using pari/gp from the system])
fi
])
3 changes: 3 additions & 0 deletions build/pkgs/pari_elldata/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([pari_elldata], [
SAGE_CHECK_PARI_DEP([pari_elldata])
])
2 changes: 1 addition & 1 deletion build/pkgs/pari_elldata/spkg-install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdh_install src/* "$GP_DATA_DIR"
sdh_install src/* "$SAGE_LOCAL/share/pari"
3 changes: 3 additions & 0 deletions build/pkgs/pari_galdata/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([pari_galdata], [
SAGE_CHECK_PARI_DEP([pari_galdata])
])
2 changes: 1 addition & 1 deletion build/pkgs/pari_galdata/spkg-install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdh_install src/* "$GP_DATA_DIR"
sdh_install src/* "$SAGE_LOCAL/share/pari"
3 changes: 3 additions & 0 deletions build/pkgs/pari_galpol/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([pari_galpol], [
SAGE_CHECK_PARI_DEP([pari_galpol])
])
2 changes: 1 addition & 1 deletion build/pkgs/pari_galpol/spkg-install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdh_install src/* "$GP_DATA_DIR"
sdh_install src/* "$SAGE_LOCAL/share/pari"
12 changes: 12 additions & 0 deletions build/pkgs/pari_nftables/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SAGE_SPKG_CONFIGURE([pari_nftables], [
AC_REQUIRE([SAGE_SPKG_CONFIGURE_PARI])
AC_MSG_CHECKING([installing pari? ])
if test x$sage_spkg_install_pari = xyes; then
AC_MSG_RESULT([yes; install pari_nftables as well])
sage_spkg_install_pari_nftables=yes
else
AC_MSG_RESULT([no])
AC_MSG_NOTICE([Installing nftables should be done by the user,])
AC_MSG_NOTICE([cf. http://pari.math.u-bordeaux1.fr/pub/pari/packages/nftables/README.txt])
fi
])
2 changes: 1 addition & 1 deletion build/pkgs/pari_nftables/spkg-install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdh_install src/* "$GP_DATA_DIR/nftables"
sdh_install src/* "$SAGE_LOCAL/share/pari/nftables"
3 changes: 3 additions & 0 deletions build/pkgs/pari_seadata/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([pari_seadata], [
SAGE_CHECK_PARI_DEP([pari_seadata])
])
2 changes: 1 addition & 1 deletion build/pkgs/pari_seadata/spkg-install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdh_install src/* "$GP_DATA_DIR"
sdh_install src/* "$SAGE_LOCAL/share/pari"
3 changes: 3 additions & 0 deletions build/pkgs/pari_seadata_small/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SAGE_SPKG_CONFIGURE([pari_seadata_small], [
SAGE_CHECK_PARI_DEP([pari_seadata_small])
])
2 changes: 1 addition & 1 deletion build/pkgs/pari_seadata_small/spkg-install
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdh_install src/* "$GP_DATA_DIR"
sdh_install src/* "$SAGE_LOCAL/share/pari"
10 changes: 10 additions & 0 deletions m4/sage_check_pari_dep.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AC_DEFUN([SAGE_CHECK_PARI_DEP],[
AC_REQUIRE([SAGE_SPKG_CONFIGURE_PARI])
AC_MSG_CHECKING([installing pari? ])
if test x$sage_spkg_install_pari = xyes; then
AC_MSG_RESULT([yes; install $1 as well])
[sage_spkg_install_]$1=yes
else
AC_MSG_RESULT([no])
fi
])
5 changes: 0 additions & 5 deletions src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,6 @@ if [ -n "$MULTI_ARCH" ]; then
CPATH="${CPATH}:/usr/include/$MULTI_ARCH"
fi

# For PARI/GP
GP_DATA_DIR="$SAGE_LOCAL/share/pari" && export GP_DATA_DIR
GPHELP="$SAGE_LOCAL/bin/gphelp" && export GPHELP
GPDOCDIR="$SAGE_LOCAL/share/pari/doc" && export GPDOCDIR

SINGULARPATH="$SAGE_LOCAL/share/singular" && export SINGULARPATH
SINGULAR_EXECUTABLE="$SAGE_LOCAL/bin/Singular" && export SINGULAR_EXECUTABLE

Expand Down
10 changes: 10 additions & 0 deletions src/bin/sage-env-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ if [ -n "$SAGE_FLINT_PREFIX" ]; then
# their ./configure scripts. Thus we deal with this just as with GMP above.
export SAGE_CONFIGURE_FLINT="--with-flint=$SAGE_FLINT_PREFIX"
fi

# This is usually blank if the system PARI is used, or $SAGE_LOCAL otherwise
export SAGE_PARI_PREFIX="@SAGE_PARI_PREFIX@"
if [ -n "$SAGE_PARI_PREFIX" ]; then
# Some packages that depend on PARI accept a --with-pari=<prefix> flag to
# their ./configure scripts. Thus we deal with this just as with GMP above.
export SAGE_CONFIGURE_PARI="--with-pari=$SAGE_PARI_PREFIX"
fi
export SAGE_PARI_CFG="@SAGE_PARI_CFG@"

export SAGE_FREETYPE_PREFIX="@SAGE_FREETYPE_PREFIX@"
export SAGE_ARB_LIBRARY="@SAGE_ARB_LIBRARY@"

Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def is_package_installed(package, exclude_pip=True):
EXAMPLES::
sage: is_package_installed('pari') # optional - build
sage: is_package_installed('gap') # optional - build
True
Giving just the beginning of the package name is not good enough::
Expand Down
2 changes: 1 addition & 1 deletion src/sage_setup/docbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def _build_many(target, args):
raise
return ret

if not (CYGWIN_VERSION and CYGWIN_VERSION[0] < 3):
if (os.environ['SAGE_PARI_CFG'] !='') and (not (CYGWIN_VERSION and CYGWIN_VERSION[0] < 3)):
build_many = _build_many
else:
# Cygwin 64-bit < 3.0.0 has a bug with exception handling when exceptions
Expand Down
2 changes: 1 addition & 1 deletion src/sage_setup/optional_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def OptionalExtension(*args, **kwds):
sage: ext = OptionalExtension("foo", ["foo.c"], package="no_such_package")
sage: print(ext.__class__.__name__)
CythonizeExtension
sage: ext = OptionalExtension("foo", ["foo.c"], package="pari")
sage: ext = OptionalExtension("foo", ["foo.c"], package="gap")
sage: print(ext.__class__.__name__)
Extension
"""
Expand Down

0 comments on commit ecdd404

Please sign in to comment.