From 87098dcde086eb8cfe37933fb326ddaeba29dd20 Mon Sep 17 00:00:00 2001 From: Jerry James Date: Sat, 19 Jan 2019 09:07:04 -0700 Subject: [PATCH] Add -buildroot patch and only build cython interfaces once. Also: - Drop LANGUAGES variable setting, now ignored by the sagemath build system. - Drop unused SAGE_CBLAS variable from /usr/bin/sage. - Do not force the C locale when launching sagemath. - Allow the user to override SAGE_DEBUG in /usr/bin/sage. - Add -ecm, -giac, and -latte patches to fix interactions with external tools. - Add -sigfpe patch from upstream. - Fix flask_autoindex and flask_openid imports in sagenb. - Add Education category to the desktop file (bz 1624545). - Fix SINGULAR_SO variable in /usr/bin/sage (bz 1636759 and 1655248). - Invoke twistd-2 instead of twistd (bz 1640890). - Improve jupyter integration (bz 1663165). - Move existing jupyter integration into the notebook subpackage. - Require python-jupyter-filesystem instead of owning its directories. - Drop one more remnant of the F24 to F25 upgrade fixup. --- sagemath-buildroot.patch | 13 ++++ sagemath-ecm.patch | 12 ++++ sagemath-giac.patch | 15 ++++ sagemath-gmp.patch | 19 ------ sagemath-latte.patch | 21 ++++++ sagemath-sagenb.patch | 24 +++++-- sagemath-sigfpe.patch | 143 +++++++++++++++++++++++++++++++++++++++ sagemath.spec | 110 +++++++++++++++++++++--------- 8 files changed, 301 insertions(+), 56 deletions(-) create mode 100644 sagemath-buildroot.patch create mode 100644 sagemath-ecm.patch create mode 100644 sagemath-giac.patch delete mode 100644 sagemath-gmp.patch create mode 100644 sagemath-latte.patch create mode 100644 sagemath-sigfpe.patch diff --git a/sagemath-buildroot.patch b/sagemath-buildroot.patch new file mode 100644 index 0000000..93d8b29 --- /dev/null +++ b/sagemath-buildroot.patch @@ -0,0 +1,13 @@ +diff -up src/setup.py.orig src/setup.py +--- src/setup.py.orig 2018-08-29 08:35:19.955079610 -0600 ++++ src/setup.py 2019-01-18 11:28:06.915666783 -0700 +@@ -386,6 +386,9 @@ class sage_build_cython(Command): + with open(self._version_file, 'w') as f: + f.write(self._version_stamp) + ++ # Remove buildroot paths from the generated files ++ subprocess.check_call(["find", "build/cythonized/sage", "-type", "f", "-exec", "sed", "-i", "s|@@BUILDROOT@@||g", "{}", "+"]) ++ + # Finally, copy relevant cythonized files from build/cythonized + # tree into the build-lib tree + for (dst_dir, src_files) in self.get_cythonized_package_files(): diff --git a/sagemath-ecm.patch b/sagemath-ecm.patch new file mode 100644 index 0000000..d097ce9 --- /dev/null +++ b/sagemath-ecm.patch @@ -0,0 +1,12 @@ +diff -up src/sage/interfaces/ecm.py.orig src/sage/interfaces/ecm.py +--- src/sage/interfaces/ecm.py.orig 2018-08-03 05:10:08.000000000 -0600 ++++ src/sage/interfaces/ecm.py 2019-01-18 11:03:25.492710113 -0700 +@@ -256,7 +256,7 @@ class ECM(SageObject): + """ + print("Enter numbers to run ECM on them.") + print("Press control-C to exit.") +- os.system(self._cmd) ++ os.system(' '.join(self._cmd)) + + # Recommended settings from + # http://www.mersennewiki.org/index.php/Elliptic_Curve_Method diff --git a/sagemath-giac.patch b/sagemath-giac.patch new file mode 100644 index 0000000..e3418e9 --- /dev/null +++ b/sagemath-giac.patch @@ -0,0 +1,15 @@ +diff -up src/sage/interfaces/giac.py.orig src/sage/interfaces/giac.py +--- src/sage/interfaces/giac.py.orig 2018-08-03 05:10:08.000000000 -0600 ++++ src/sage/interfaces/giac.py 2019-01-18 11:04:10.255917393 -0700 +@@ -616,10 +616,7 @@ If you got giac from the spkg then ``$PR + '4\n3' + sage: s='g(x):={\nx+1;\nx+2;\n}' + sage: giac(s) +- (x)->{ +- x+1; +- x+2; +- } ++ (x)->[x+1,x+2] + sage: giac.g(5) + 7 + """ diff --git a/sagemath-gmp.patch b/sagemath-gmp.patch deleted file mode 100644 index 31dea02..0000000 --- a/sagemath-gmp.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -up src/sage/modular/arithgroup/farey.cpp.orig src/sage/modular/arithgroup/farey.cpp ---- src/sage/modular/arithgroup/farey.cpp.orig 2017-11-08 06:03:07.383885084 -0500 -+++ src/sage/modular/arithgroup/farey.cpp 2017-11-08 06:03:18.271885501 -0500 -@@ -136,6 +136,7 @@ operator*(const SL2Z& M, const vector ++ ++/* Rummage around to determine how ECL was configured */ ++#define ECL_AVOID_FPE_H /* Prevent some local includes */ ++#include ++ ++#ifdef HAVE_FENV_H ++#include ++#ifndef FE_ALL_EXCEPT ++#define FE_ALL_EXCEPT FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID ++#endif ++#else ++#ifndef FE_ALL_EXCEPT ++#define FE_ALL_EXCEPT 0 ++#endif ++#endif ++ ++#ifndef HAVE_FEENABLEEXCEPT ++/* These are GNU extensions */ ++#define fegetexcept() 0 ++#define feenablexcept(flags) ++#define fdisableexcept(flags) ++#endif ++ + static struct sigaction ecl_sigint_handler; + static struct sigaction ecl_sigbus_handler; ++static struct sigaction ecl_sigfpe_handler; + static struct sigaction ecl_sigsegv_handler; + static struct sigaction sage_sigint_handler; + static struct sigaction sage_sigbus_handler; ++static struct sigaction sage_sigfpe_handler; + static struct sigaction sage_sigsegv_handler; ++static int ecl_feflags; ++static int sage_feflags; + + static inline void set_ecl_signal_handler(void) + { + sigaction(SIGINT, &ecl_sigint_handler, &sage_sigint_handler); + sigaction(SIGBUS, &ecl_sigbus_handler, &sage_sigbus_handler); ++ sigaction(SIGFPE, &ecl_sigfpe_handler, &sage_sigfpe_handler); + sigaction(SIGSEGV, &ecl_sigsegv_handler, &sage_sigsegv_handler); ++ /* sage_feflags should be 0; we don't set them otherwise */ ++ sage_feflags = fedisableexcept(FE_ALL_EXCEPT); ++ feenableexcept(ecl_feflags); + } + + static inline void unset_ecl_signal_handler(void) + { + sigaction(SIGINT, &sage_sigint_handler, NULL); + sigaction(SIGBUS, &sage_sigbus_handler, NULL); ++ sigaction(SIGFPE, &sage_sigfpe_handler, NULL); + sigaction(SIGSEGV, &sage_sigsegv_handler, NULL); ++ ecl_feflags = fedisableexcept(FE_ALL_EXCEPT); ++ feenableexcept(sage_feflags); + } + + /* This MUST be a macro because sig_on() must be in the same +--- src/sage/libs/mpmath/ext_impl.pyx.orig 2018-08-03 05:10:08.000000000 -0600 ++++ src/sage/libs/mpmath/ext_impl.pyx 2019-01-18 11:33:53.643921141 -0700 +@@ -164,9 +164,9 @@ opts_double_precision.rounding = ROUND_N + opts_mini_prec.prec = 5 + opts_mini_prec.rounding = ROUND_D + +-cdef double _double_inf = float("1e300") * float("1e300") +-cdef double _double_ninf = -_double_inf +-cdef double _double_nan = _double_inf - _double_inf ++cdef double _double_inf = float("inf") ++cdef double _double_ninf = float("-inf") ++cdef double _double_nan = float("nan") + + cdef inline void MPF_init(MPF *x): + """Allocate space and set value to zero. diff --git a/sagemath.spec b/sagemath.spec index 5846bb3..b629cbe 100644 --- a/sagemath.spec +++ b/sagemath.spec @@ -1,6 +1,6 @@ %global __provides_exclude_from .*/site-packages/.*\\.so -# This package install python files in nonstandard places +# This package installs python files in nonstandard places %global _python_bytecompile_extra 0 %bcond_with bundled_pexpect @@ -86,7 +86,7 @@ Name: sagemath Summary: A free open-source mathematics software system Version: 8.3 -Release: 1%{?dist} +Release: 2%{?dist} # The file ${SAGE_ROOT}/COPYING.txt is the upstream license breakdown file # Additionally, every $files section has a comment with the license name # before files with that license @@ -97,8 +97,11 @@ Source1: gprc.expect # Follow maxima's ExclusiveArch ExclusiveArch: aarch64 %{arm} %{ix86} x86_64 ppc sparcv9 -# Upstream uses mpir not gmp, but the rpm package is tailored to use gmp -Patch1: %{name}-gmp.patch +# Fix ecm interact() command +Patch0: %{name}-ecm.patch + +# Adapt a giac doctest to recent versions of giac +Patch1: %{name}-giac.patch # Set of patches to work with system wide packages Patch2: %{name}-scripts.patch @@ -145,6 +148,9 @@ Patch11: %{name}-cremona.patch # http://pallini.di.uniroma1.it/ Patch13: %{name}-nauty.patch +# remove the buildroot path from Cython output +Patch14: %{name}-buildroot.patch + # correct path to Lfunction include # update c++ standard to fix FTBFS Patch15: %{name}-lcalc.patch @@ -175,7 +181,7 @@ Patch22: %{name}-qepcad.patch Patch23: %{name}-arb.patch # No support for f" notation -Patch24: %{name}-nofstring.patch +Patch24: %{name}-nofstring.patch # Add missing include paths Patch25: %{name}-includes.patch @@ -186,6 +192,12 @@ Patch26: %{name}-atlas.patch # Adapt to recent versions of eclib Patch27: %{name}-eclib.patch +# Fix paths to latte-integrale binaries +Patch28: %{name}-latte.patch + +# Upstream fixes for random SIGFPEs due to ecl messing with the fp state +Patch29: %{name}-sigfpe.patch + BuildRequires: 4ti2 BuildRequires: arb-devel BuildRequires: atlas-devel @@ -644,6 +656,7 @@ This package contains the Turkish %{name} documentation. %package notebook Summary: The Sage Notebook Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: python-jupyter-filesystem %description notebook The Sage Notebook is a web-based graphical user interface for @@ -825,6 +838,7 @@ pushd build/pkgs/widgetsnbextension popd %endif +%patch0 %patch1 %patch2 %patch3 @@ -837,6 +851,7 @@ popd %patch10 %patch11 %patch13 +%patch14 %patch15 %patch16 %patch17 @@ -855,12 +870,15 @@ popd %patch25 %patch26 %patch27 +%patch28 +%patch29 sed -e 's|@@SAGE_ROOT@@|%{SAGE_ROOT}|' \ -e 's|@@SAGE_DOC@@|%{SAGE_DOC}|' \ -i src/sage/env.py sed -e 's|@@CYSIGNALS@@|%{python2_sitearch}/cysignals|' \ + -e 's|@@BUILDROOT@@|%{buildroot}|' \ -i src/setup.py sed -e "/flask-oldsessions/d" \ @@ -889,6 +907,7 @@ grep -FrlZ '#!%{_bindir}/env python' | \ xargs -0 sed -i 's,#!%{_bindir}/env python,#!%{__python2},' grep -FrlZ '#!%{_bindir}/env sage-python23' | \ xargs -0 sed -i 's,#!%{_bindir}/env sage-python23,#!%{__python2},' +grep -FrlZ 'sage-python23' | xargs -0 sed -i 's,sage-python23,#!%{__python2},' grep -FrlZ '#!%{_bindir}/env' | \ xargs -0 sed -i 's,#!%{_bindir}/env ,#!%{_bindir}/,' grep -rlZ '#!%{_bindir}/python$' | xargs -0 sed -i 's,#!%{_bindir}/python$,&2,' @@ -906,6 +925,12 @@ sed -e "s|'%{_bindir}/env', 'which'|'%{_bindir}/which'|" \ -i build/pkgs/ipython/src/IPython/utils/_process_posix.py %endif +# Fix twistd invocation; the python3 version has no suffix +sed -i 's/exec twistd/&-2/' src/bin/sage + +# GAP does not have enough memory to load the entire workspace +sed -i 's/64m/128m/' src/sage/libs/gap/util.pyx + ######################################################################## %build export CC=%{__cc} @@ -1005,16 +1030,6 @@ pushd build/pkgs/rubiks/src make %{?_smp_mflags} CC="gcc -fPIC" CXX="g++ -fPIC" CFLAGS="%{optflags}" CXXFLAGS="%{optflags}" popd -# Remove buildroot reference from cython comments -perl -pi -e 's|%{buildroot}||g;' `find src/build/cythonized -type f` - -# Try hard to remove buildroot from binaries -rm -f `grep -lr "%{buildroot}" src/build/lib.linux-*/` -rm -f `grep -lr "%{buildroot}" src/build/temp.linux-*/` -pushd src - %__python2 ./setup.py build -popd - # last build command rm -fr $DOT_SAGE @@ -1068,8 +1083,8 @@ pushd src/ext if [ $COUNT -gt 0 ]; then cp -far $dir $SAGE_ETC fi - cp -far pari $SAGE_ETC done + cp -far pari $SAGE_ETC cp -fa %{SOURCE1} $SAGE_ETC popd @@ -1274,7 +1289,7 @@ popd cat > %{buildroot}%{_bindir}/sage << EOF #!/bin/bash -i -export CUR=\`pwd\` +export CUR=\$PWD ##export DOT_SAGE="\$HOME/.sage" mkdir -p \$DOT_SAGE/{maxima,sympow,tmp} export SAGE_TESTDIR=\$DOT_SAGE/tmp @@ -1286,23 +1301,22 @@ export SAGE_ETC="$SAGE_ETC" export SAGE_SRC="%{buildroot}%{SAGE_SRC}" ##export SAGE_DOC="$SAGE_DOC" ##export SAGE_DOC_SRC="\$SAGE_DOC" -##export SAGE_PKGS="\$SAGE_LOCAL//var/lib/sage/installed" +##export SAGE_PKGS="\$SAGE_LOCAL/var/lib/sage/installed" module load 4ti2-%{_arch} module load lrcalc-%{_arch} module load surf-geometry-%{_arch} export PATH=$SAGE_LOCAL/bin:\$PATH export SINGULAR_DATA_DIR=%{_datadir} export SINGULAR_BIN_DIR=%{_libdir}/Singular -export SINGULAR_SO=%{_libdir}/libSingular-4.1.1.so +export SINGULAR_SO=%{_libdir}/libSingular-4.1.0.so ##export PYTHONPATH="$SAGE_PYTHONPATH:\$SAGE_LOCAL/bin" -export SAGE_CBLAS=blas export SAGE_FORTRAN=%{_bindir}/gfortran export SAGE_FORTRAN_LIB=\`gfortran --print-file-name=libgfortran.so\` export SYMPOW_DIR="\$DOT_SAGE/sympow" -export LC_ALL=C.UTF-8 export LD_LIBRARY_PATH=\$SAGE_ROOT/lib:\$LD_LIBRARY_PATH # Required for sage -gdb -export SAGE_DEBUG=no +: \${SAGE_DEBUG:=no} +export SAGE_DEBUG $SAGE_LOCAL/bin/sage "\$@" EOF #------------------------------------------------------------------------ @@ -1361,7 +1375,7 @@ pushd src/doc export SAGE_DOC_SRC=$SAGE_DOC # python -m sage_setup.docbuild # Build with an X server running, required by some doc builders - SAGE_NUM_THREADS=2 LANGUAGES="ca de en fr hu it ja pt ru tr" \ + SAGE_NUM_THREADS=2 \ xvfb-run -a -n 1 %__python2 -m docbuild --no-pdf-links -k all html -j rm -f %{buildroot}%{SAGE_SRC}/doc ln -sf %{SAGE_DOC} %{buildroot}%{SAGE_SRC}/doc @@ -1426,7 +1440,7 @@ Exec=sage Icon=%{name} Terminal=true Type=Application -Categories=Science;Math; +Categories=Education;Science;Math; EOF desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop @@ -1519,6 +1533,18 @@ chmod +x %{buildroot}%{SAGE_LOCAL}/bin/sage-list-packages # Byte compile python files in nonstandard places %py_byte_compile %{__python2} %{buildroot}%{_texmf_main}/tex/latex/sagetex +#------------------------------------------------------------------------ +# Jupyter integration +mkdir -p %{buildroot}%{_datadir}/jupyter/kernels/sagemath +pushd %{buildroot}%{_datadir}/jupyter/kernels/sagemath +ln -s %{_docdir}/%{name}/html/en doc +ln -s %{SAGE_ETC}/notebook-ipython/logo-64x64.png logo-64x64.png +ln -s %{SAGE_ETC}/notebook-ipython/logo.svg logo.svg +cat > kernel.json << EOF +{"display_name": "SageMath %{version}", "argv": ["%{_bindir}/sage", "--python", "-m", "sage.repl.ipython_kernel", "-f", "{connection_file}"]} +EOF +popd + # last install command rm -fr $DOT_SAGE @@ -1581,14 +1607,6 @@ rm -fr $DOT_SAGE %if %{with bundled_ipywidgets} %{SAGE_PYTHONPATH}/ipywidgets %endif -%if %{with bundled_widgetsnbextension} -%dir %{_sysconfdir}/jupyter -%dir %{_sysconfdir}/jupyter/nbconfig -%dir %{_sysconfdir}/jupyter/nbconfig/notebook.d -%config(noreplace) %{_sysconfdir}/jupyter/nbconfig/notebook.d/*.json -%{_datadir}/jupyter/ -%{python2_sitelib}/widgetsnbextension* -%endif #------------------------------------------------------------------------ %files data @@ -1697,6 +1715,10 @@ rm -fr $DOT_SAGE # with docs %endif +#------------------------------------------------------------------------ +%files jupyter +%{_datadir}/jupyter/kernels/sagemath/ + #------------------------------------------------------------------------ %files notebook %{SAGE_ETC}/notebook-ipython @@ -1722,7 +1744,6 @@ rm -fr $DOT_SAGE %{python2_sitearch}/sagenb/data/json # Symbolic link to $_jsdir/mathjax %{python2_sitearch}/sagenb/data/mathjax -%ghost %{python2_sitearch}/sagenb/data/mathjax.rpmmoved # Empty (do not run doctests flag file) %{python2_sitearch}/sagenb/data/nodoctest.py* # BSD @@ -1765,6 +1786,12 @@ rm -fr $DOT_SAGE %lang(pt_BR) %{python2_sitearch}/sagenb/translations/pt_BR %lang(ru_RU) %{python2_sitearch}/sagenb/translations/ru_RU %lang(uk_UA) %{python2_sitearch}/sagenb/translations/uk_UA +%if %{with bundled_widgetsnbextension} +%config(noreplace) %{_sysconfdir}/jupyter/nbconfig/notebook.d/*.json +%{_datadir}/jupyter/nbextensions/ +%{python2_sitelib}/widgetsnbextension* +%endif +%{_datadir}/jupyter/kernels/sagemath/ #------------------------------------------------------------------------ %files notebook-export @@ -1794,6 +1821,23 @@ rm -fr $DOT_SAGE ######################################################################## %changelog +* Sat Jan 19 2019 Jerry James - 8.3-2 +- Add -buildroot patch and only build cython interfaces once +- Drop LANGUAGES variable setting, now ignored by the sagemath build system +- Drop unused SAGE_CBLAS variable from /usr/bin/sage +- Do not force the C locale when launching sagemath +- Allow the user to override SAGE_DEBUG in /usr/bin/sage +- Add -ecm, -giac, and -latte patches to fix interactions with external tools +- Add -sigfpe patch from upstream +- Fix flask_autoindex and flask_openid imports in sagenb +- Add Education category to the desktop file (bz 1624545) +- Fix SINGULAR_SO variable in /usr/bin/sage (bz 1636759 and 1655248) +- Invoke twistd-2 instead of twistd (bz 1640890) +- Improve jupyter integration (bz 1663165) +- Move existing jupyter integration into the notebook subpackage +- Require python-jupyter-filesystem instead of owning its directories +- Drop one more remnant of the F24 to F25 upgrade fixup + * Sat Sep 22 2018 Jerry James - 8.3-1 - Update to sagemath 8.3 (bz 1612867) - Drop -lrslib, -gap-hap, and -flask patches