Skip to content

Commit

Permalink
sagemath: use pep517
Browse files Browse the repository at this point in the history
  • Loading branch information
tornaria committed Mar 6, 2024
1 parent d35e5f5 commit 4b4f147
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 54 deletions.
4 changes: 0 additions & 4 deletions srcpkgs/sagemath/files/sage_conf.py

This file was deleted.

72 changes: 22 additions & 50 deletions srcpkgs/sagemath/template
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ pkgname=sagemath
version=10.3.rc2
revision=1
build_wrksrc=pkgs/sagemath-standard
build_style=python3-module
_bindir=/usr/lib/sagemath/$version/bin
make_install_args="--install-scripts=$_bindir"
build_style=python3-pep517
make_build_args="--skip-dependency-check"
hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
python3-pkgconfig python3-setuptools"
python3-pkgconfig python3-setuptools python3-wheel"
makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
Expand Down Expand Up @@ -36,6 +35,9 @@ distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
checksum=1e2857f68fc8ae57bbf39ea88044db942eb05935a347f4cfbfbc8804ec60879a
nocross="due to ntl (eclib, singular), fflas-ffpack, givaro, linbox, sympow, maxima"

# parallel build
export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"

post_patch() {
# git tree needs bootstrapping
$wrksrc/bootstrap sagelib
Expand All @@ -44,60 +46,28 @@ post_patch() {
ln -s ../../src/sage_setup .
}

pre_build() {
export PYTHONDONTWRITEBYTECODE=yes
export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
}

post_build() {
_lib=$(cd build/lib* && pwd)
_scripts=$(cd build/scripts* && pwd)

# configuration files
#cp ${FILESDIR}/sage_conf.py $_lib
cp ${FILESDIR}/sage-env-config $_scripts
}

pre_install() {
export PYTHONDONTWRITEBYTECODE=yes
export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
}

post_install() {
# fix jupyter kernel spec
vsed -i -e 's|"/usr/bin/sage"|"'${_bindir}'/sage"|' \
${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json

# replace broken symlinks by good copies (sagemath logo images)
for file in $(ls sage/ext_data/notebook-ipython); do
rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/$file
cp -a sage/ext_data/notebook-ipython/$file \
${DESTDIR}/usr/share/jupyter/kernels/sagemath
done
# move scripts to /usr/libexec
vmkdir usr/libexec
mv -T ${DESTDIR}/usr/bin ${DESTDIR}/usr/libexec/sagemath

# we don't have docs here
rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
# this symlink is shipped in threejs-sage pkg
rm -f ${DESTDIR}/usr/share/jupyter/nbextensions/threejs-sage
# copy configuration
cp ${FILESDIR}/sage-env-config ${DESTDIR}/usr/libexec/sagemath

# symlink main binary
vmkdir usr/bin
ln -s $_bindir/sage ${DESTDIR}/usr/bin/sage-${version}
ln -s sage-${version} ${DESTDIR}/usr/bin/sage
ln -s /usr/libexec/sagemath/sage ${DESTDIR}/usr/bin
}

do_check() {
_lib=$(cd build/lib* && pwd)
_scripts=$(cd build/scripts* && pwd)
local testdir="${wrksrc}/.xbps-testdir/$(date +%s)"
python3 -m installer -d "${testdir}" dist/*.whl

export PYTHONPATH=$_lib
export PYTHONDONTWRITEBYTECODE=yes

# get out of $build_wrksrc, otherwise python picks the wrong sage module
cd $(mktemp -dp build)
# this makes for nicer (shorter) relative paths in output
cd ${testdir}/${py3_sitelib}

if [ -f ${XBPS_DISTDIR}/sagemath-check ] ; then
_sed='s|#.*||;/^\s*$/d;s|^\([^ ]*/\)\?sage/|'$_lib'/sage/|g' \
_sed='s|#.*||;/^\s*$/d;s|^\s*\([^ ]*/\)\?sage/|sage/|g' \
_test_files=$(sed -e "$_sed" ${XBPS_DISTDIR}/sagemath-check)
fi
if [ -z "$_test_files" ]; then
Expand All @@ -106,13 +76,15 @@ do_check() {
cp ${FILESDIR}/timings2.json .
_test_args="--stats_path=timings2.json"
if [ "$XBPS_CHECK_PKGS" = full ]; then
_test_args+=" --long --warn-long 60.0"
_test_args+=" --long --warn-long 30.0"
else
_test_args+=" --warn-long 30.0"
_test_args+=" --warn-long 10.0"
fi
if [ "$XBPS_BUILD_ENVIRONMENT" = "void-packages-ci" ]; then
# for CI use a predictable random seed
_test_args+=" --random-seed=0"
fi
$_scripts/sage -tp ${XBPS_MAKEJOBS} ${_test_args} ${_test_files}

PATH="${testdir}/usr/bin:${PATH}" PYTHONPATH="${testdir}/${py3_sitelib}" \
sage -tp ${XBPS_MAKEJOBS} ${_test_args} ${_test_files}
}

0 comments on commit 4b4f147

Please sign in to comment.