Skip to content

Commit

Permalink
Rearrangements to support Sage 9.3
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Apr 15, 2021
1 parent fad7356 commit dca5d37
Show file tree
Hide file tree
Showing 29 changed files with 251 additions and 61 deletions.
62 changes: 62 additions & 0 deletions Sage_framework/build_framework.sh
@@ -0,0 +1,62 @@
#!/bin/bash
# This script assumes that ../repo/sage is a clone of the Sage git repository
# and that a successful build of some branch is in place there. It will be
# used as is, copying what we need into the framework.
SAGE_REPO=repo/sage
FRAMEWORK=build/Sage.framework
PYTHON=python3.9
source $SAGE_REPO/src/bin/sage-version.sh
CURRENT=$FRAMEWORK/Versions/Current
mkdir -p $FRAMEWORK/Versions/$SAGE_VERSION
ln -s $SAGE_VERSION $CURRENT
mkdir -p $CURRENT/Resources
ln -s Versions/Current/Resources $FRAMEWORK/Resources
cp $SAGE_REPO/{VERSION.txt,README.md,COPYING.txt} $FRAMEWORK/Resources
sed -e s/XXXX/$SAGE_VERSION/g resources/Info.plist > $FRAMEWORK/Resources/Info.plist
cp resources/pip.conf $FRAMEWORK/Resources
mkdir -p $CURRENT/local/var
cp -R $SAGE_REPO/local/var/lib $CURRENT/local/var
cp -R $SAGE_REPO/local/{bin,etc,include,lib,lib64,libexec} $CURRENT/local
mkdir -p $CURRENT/local/share
for dir in `ls $SAGE_REPO/local/share`
do
if [ $dir != doc ] && [ $dir != man ]; then
cp -R $SAGE_REPO/local/share/$dir $CURRENT/local/share
fi
done
LOCAL=$CURRENT/local
# Remove static libraries
find $LOCAL -name '*.a' -delete
find $LOCAL -name '*.la' -delete
# Fix symlinks
rm $LOCAL/share/gap/{gac,gap}
ln -s ../../bin/gap $CURRENT/local/share/gap/gap
ln -s ../../bin/gac $CURRENT/local/share/gap/gac
rm $LOCAL/share/jupyter/kernels/sagemath/doc
rm $LOCAL/share/jupyter/kernels/sagemath/logo*
cp $SAGE_REPO/build/pkgs/sagelib/src/sage/ext_data/notebook-ipython/logo* $LOCAL/share/jupyter/kernels/sagemath
rm $LOCAL/share/jupyter/nbextensions/threejs
ln -s ../../threejs $LOCAL/share/jupyter/nbextensions/threejs
# Remove saved wheels (which contain unsigned binaries)
rm -rf $LOCAL/var/lib/sage/wheels
# Remove .pyc files
find $LOCAL -name '*.pyc' -delete
# Fix up hardwired paths and rpaths
python3 fix_paths.py
# Recompile byte code with a relative prefix (used in tracebacks)
python3 -m compileall -d local/lib/$PYTHON $LOCAL/lib/$PYTHON
python3 -m compileall -d local/bin $LOCAL/bin
python3 -m compileall -d local/share/cysignals $CURRENT/local/share/cysignals
python3 -m compileall -d local/share/texmf/tex/latex/sagetex $CURRENT/local/share/texmf/tex/latex/sagetex
# Replace a few files with our own versions and add runpath.sh
cp files/sage files/sage-env $LOCAL/bin
cp files/page.html $LOCAL/lib/python3.9/site-packages/notebook/templates/
echo SAGE_SYMLINK=$SAGE_SYMLINK > $LOCAL/var/lib/sage/runpath.sh
chmod +x $LOCAL/var/lib/sage/runpath.sh
TCL_RPATH=@loader_path/../../../../../../../Tcl.framework/Versions/Current
TK_RPATH=@loader_path/../../../../../../../Tk.framework/Versions/Current
/usr/local/bin/macher clear_rpaths $LOCAL/lib/$PYTHON/lib-dynload/_tkinter.cpython-*.so
/usr/local/bin/macher add_rpath $TCL_RPATH $LOCAL/lib/$PYTHON/lib-dynload/_tkinter.cpython-*.so
/usr/local/bin/macher add_rpath $TK_RPATH $LOCAL/lib/$PYTHON/lib-dynload/_tkinter.cpython-*.so
ln -s $PYTHON $LOCAL/bin/SageMath
python3 sign_sage.py
8 changes: 8 additions & 0 deletions Sage_framework/entitlement.plist
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
1 change: 0 additions & 1 deletion Sage_framework/files/runpath.sh

This file was deleted.

77 changes: 36 additions & 41 deletions Sage_framework/files/sage
@@ -1,5 +1,41 @@
#!/usr/bin/env bash

# Get the installation-specific symlink and intialize TARGET and SAGE_ROOT
saved_cwd=`pwd`
cd "`dirname $0`/../.."
TARGET=`pwd`
cd $saved_cwd
runpath_sh="$TARGET/local/var/lib/sage/runpath.sh"
if [ -x "$runpath_sh" ]; then
. "$runpath_sh"
fi

# Check that the installation specific symlink points to the sage
# root directory. If not, try to reset it. Strangely, this script
# can get called a second time and when that happens we will have
# $TARGET == $SAGE_SYMLINK. We had better not set the symlink to
# point to itself!

OLD_TARGET=`readlink $SAGE_SYMLINK`
if [ "$TARGET" != "$OLD_TARGET" ] && [ "$TARGET" != "$SAGE_SYMLINK" ]; then
echo "This SageMath application has been moved! Reconfiguring ..."
rm -f $SAGE_SYMLINK 2> /dev/null
if [ $? -ne 0 ]; then
OWNER=$(stat -f '%Su' $SAGE_SYMLINK)
echo
echo "Oh no!"
echo "You do not have permission to reconfigure this SageMath."
echo "Please ask $OWNER to open the app."
echo
read -p "The app will exit when you press a key."
exit
fi
if [ "$TARGET" != "$SAGE_SYMLINK" ]; then
ln -s "$TARGET" "$SAGE_SYMLINK"
fi
fi
export SAGE_ROOT="`readlink $SAGE_SYMLINK`"

# Display the current version of Sage
# usage: sage_version [-v]
# -v display the full version banner including release date
Expand Down Expand Up @@ -49,9 +85,6 @@ usage() {
echo " --optional - controls which optional tests are run"
echo " --help - show all testing options"
echo " -v, --version -- display Sage version information"
if [ -n "$SAGE_ROOT" ]; then
exec "$SAGE_ROOT/build/bin/sage-site" "-h"
fi
exit 0
}

Expand Down Expand Up @@ -190,41 +223,6 @@ if [ "$1" = '-root' -o "$1" = '--root' ]; then
exit 0
fi

# Get the installation-specific symlink
saved_cwd=`pwd`
cd "`dirname $0`/../.."
TARGET=`pwd`
cd $saved_cwd
runpath_sh="$TARGET/local/var/lib/sage/runpath.sh"
if [ -x "$runpath_sh" ]; then
. "$runpath_sh"
fi

# Check that the installation specific symlink points to this sage
# root directory. If not, try to reset it. Strangely, this script
# can get called a second time and when that happens we will have
# $TARGET == $SAGE_SYMLINK. We had better not set the symlink to
# point to itself!

OLD_TARGET=`readlink $SAGE_SYMLINK`
if [ "$TARGET" != "$OLD_TARGET" ] && [ "$TARGET" != "$SAGE_SYMLINK" ]; then
echo "This SageMath application has been moved! Reconfiguring ..."
rm -f $SAGE_SYMLINK 2> /dev/null
if [ $? -ne 0 ]; then
OWNER=$(stat -f '%Su' $SAGE_SYMLINK)
echo
echo "Oh no!"
echo "You do not have permission to reconfigure this SageMath."
echo "Please ask $OWNER to open the app."
echo
read -p "The app will exit when you press a key."
exit
fi
if [ "$TARGET" != "$SAGE_SYMLINK" ]; then
ln -s "$TARGET" "$SAGE_SYMLINK"
fi
fi

#####################################################################
# Source sage-env ($0 is the name of this "sage" script, so we can just
# append -env to that). We redirect stdout to stderr, which is safer
Expand Down Expand Up @@ -499,9 +497,6 @@ usage_advanced() {
echo " files are named sage-omega.PID can be found in"
echo " \$DOT_SAGE"
echo " --valgrind -- this is an alias for --memcheck"
if [ -n "$SAGE_ROOT" ]; then
exec "$SAGE_ROOT/build/bin/sage-site" "--advanced"
fi
echo
exit 0
}
Expand Down
18 changes: 12 additions & 6 deletions Sage_framework/files/sage-env
Expand Up @@ -509,10 +509,16 @@ if [ -z "$CCACHE_BASEDIR" ]; then
export CCACHE_BASEDIR="$SAGE_ROOT"
fi

# On macOS, calling gcc when it is not installed produces a dialog asking
# whether to intall the command line tools. We don't want that.
if ! [ -e /usr/bin/xcode-select ] || /usr/bin/xcode-select -p &>/dev/null ; then
CAN_CALL_CC=YES
fi

# Set AS to assembler used by $CC ("as" by default)
if [ "$AS" = "" ]; then
CC_as=`$CC -print-prog-name=as 2>/dev/null`
if command -v $CC_as >/dev/null 2>/dev/null; then
if [ "$AS" = "" ] && [ "$CAN_CALL_CC" = "YES" ] ; then
if command -v $CC_as &> /dev/null ; then
CC_as=`$CC -print-prog-name=as 2>/dev/null`
AS="$CC_as"
fi
if [ "$AS" = "" ]; then
Expand All @@ -522,9 +528,9 @@ fi
export AS

# Set LD to linker used by $CC ("ld" by default)
if [ "$LD" = "" ]; then
CC_ld=`$CC -print-prog-name=ld 2>/dev/null`
if command -v $CC_ld >/dev/null 2>/dev/null; then
if [ "$LD" = "" ] && [ "$CAN_CALL_CC" = "YES" ] ; then
if command -v $CC_ld &> /dev/null; then
CC_ld=`$CC -print-prog-name=ld 2>/dev/null`
LD="$CC_ld"
fi
if [ "$LD" = "" ]; then
Expand Down
28 changes: 28 additions & 0 deletions Sage_framework/resources/Info.plist
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Sage</string>
<key>CFBundleGetInfoString</key>
<string>SageMath</string>
<key>CFBundleIdentifier</key>
<string>org.computop.sage</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Python</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>Sage XXXX</string>
<key>CFBundleLongVersionString</key>
<string>Sage XXXX.</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>XXXX</string>
</dict>
</plist>
2 changes: 2 additions & 0 deletions Sage_framework/resources/pip.conf
@@ -0,0 +1,2 @@
[install]
user = yes
8 changes: 4 additions & 4 deletions package-9.2/Distribution
Expand Up @@ -6,15 +6,15 @@
<options customize="allow" require-scripts="false" rootVolumeOnly="true"/>
<choices-outline>
<line choice="org.computop.SageMath-9-2.bin"/>
<line choice="org.computop.SageMath-9-2.share"/>
<line choice="org.computop.SageMath-9-2.kernel"/>
</choices-outline>
<choice id="default"/>
<choice id="org.computop.SageMath-9-2.bin" title="Sage Script" description="Creates /usr/local/bin/sage">
<pkg-ref id="org.computop.SageMath-9-2.bin"/>
</choice>
<choice id="org.computop.SageMath-9-2.share" title="Jupyter" description="Creates /usr/local/share/jupyter/">
<pkg-ref id="org.computop.SageMath-9-2.share"/>
<choice id="org.computop.SageMath-9-2.kernel" title="Jupyter" description="Creates jupyter kernel file.">
<pkg-ref id="org.computop.SageMath-9-2.kernel"/>
</choice>
<pkg-ref id="org.computop.SageMath-9-2.bin" version="9.2" auth="Root" onConclusion="none" installKBytes="0">#SageMath_bin.pkg</pkg-ref>
<pkg-ref id="org.computop.SageMath-9-2.share" version="9.2" auth="Root" onConclusion="none" installKBytes="0">#SageMath_share.pkg</pkg-ref>
<pkg-ref id="org.computop.SageMath-9-2.kernel" version="9.2" auth="Root" onConclusion="none" installKBytes="0">#SageMath_kernel.pkg</pkg-ref>
</installer-gui-script>
14 changes: 7 additions & 7 deletions package-9.2/build_package.sh
@@ -1,16 +1,16 @@
#!/bin/bash
source IDs.sh

pkgbuild --root local_bin --scripts local_bin/scripts --identifier org.computop.SageMath.bin --version 9.2 --install-location /usr/local/bin bin.pkg
productsign --sign $DEV_ID bin.pkg packages/SageMath_bin.pkg
pkgbuild --root local_bin --scripts local_bin/scripts --identifier org.computop.SageMath-9-2.bin --version 1.0 --install-location /usr/local/bin bin.pkg
productsign --sign $DEV_ID bin.pkg packages/SageMath_9_2_bin.pkg

pkgbuild --root local_share --identifier org.computop.SageMath.share --version 9.2 --install-location /usr/local/share share.pkg
productsign --sign $DEV_ID share.pkg packages/SageMath_share.pkg
pkgbuild --root kernel --identifier org.computop.SageMath-9-2.kernel --version 1.0 --install-location /usr/local/share/jupyter/kernels/sagemath_9_2_all kernel.pkg
productsign --sign $DEV_ID kernel.pkg packages/SageMath_9_2_kernel.pkg

productbuild --distribution Distribution --package-path packages --resources resources recommended.pkg

productsign --sign $DEV_ID recommended.pkg Recommended.pkg
productsign --sign $DEV_ID recommended.pkg Recommended_9_2.pkg

xcrun altool --notarize-app --primary-bundle-id "SageMath-9.2-beta" --username "marc.culler@gmail.com" --password $ONE_TIME_PASS --file Recommended.pkg
xcrun altool --notarize-app --primary-bundle-id "SageMath-9.2" --username "$EMAIL" --password $ONE_TIME_PASS --file Recommended_9_2.pkg

#xcrun stapler staple Recommended.pkg
#xcrun stapler staple Recommended_9_2.pkg
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes

This file was deleted.

20 changes: 20 additions & 0 deletions package-9.3/Distribution
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<installer-gui-script minSpecVersion="1">
<title>SageMath App</title>
<background alignment="bottomleft" file="sagelogo.png" mime-type="image/png" scaling="none" />
<welcome file="Welcome.rtf" mime-type="text/richtext"/>
<options customize="allow" require-scripts="false" rootVolumeOnly="true"/>
<choices-outline>
<line choice="org.computop.SageMath-9-3.bin"/>
<line choice="org.computop.SageMath-9-3.kernel"/>
</choices-outline>
<choice id="default"/>
<choice id="org.computop.SageMath-9-3.bin" title="Sage Script" description="Creates /usr/local/bin/sage">
<pkg-ref id="org.computop.SageMath-9-3.bin"/>
</choice>
<choice id="org.computop.SageMath-9-3.kernel" title="Jupyter" description="Creates jupyter kernel file.">
<pkg-ref id="org.computop.SageMath-9-3.kernel"/>
</choice>
<pkg-ref id="org.computop.SageMath-9-3.bin" version="9.3" auth="Root" onConclusion="none" installKBytes="0">#SageMath_bin.pkg</pkg-ref>
<pkg-ref id="org.computop.SageMath-9-3.kernel" version="9.3" auth="Root" onConclusion="none" installKBytes="0">#SageMath_kernel.pkg</pkg-ref>
</installer-gui-script>
3 changes: 3 additions & 0 deletions package-9.3/IDs.sh
@@ -0,0 +1,3 @@
DEV_ID=A3LBEGBB69
ONE_TIME_PASS="jnsr-kxur-wcnh-qsyy"
EMAIL=marc.culler@gmail.com
Binary file added package-9.3/Recommended.pkg
Binary file not shown.
Binary file added package-9.3/bin.pkg
Binary file not shown.
16 changes: 16 additions & 0 deletions package-9.3/build_package.sh
@@ -0,0 +1,16 @@
#!/bin/bash
source IDs.sh

pkgbuild --root local_bin --scripts local_bin/scripts --identifier org.computop.SageMath-9-3.bin --version 1.0 --install-location /usr/local/bin bin.pkg
productsign --sign $DEV_ID bin.pkg packages/SageMath_9_3bin.pkg

pkgbuild --root kernel --identifier org.computop.SageMath-9-3.kernel --version 1.0 --install-location /usr/local/share/jupyter/kernels/sagemath_9_3_all kernel.pkg
productsign --sign $DEV_ID kernel.pkg packages/SageMath_9_3_kernel.pkg

productbuild --distribution Distribution --package-path packages --resources resources recommended.pkg

productsign --sign $DEV_ID recommended.pkg Recommended_9_3.pkg

xcrun altool --notarize-app --primary-bundle-id "SageMath-9.3" --username "$EMAIL" --password $ONE_TIME_PASS --file Recommended_9_3.pkg

#xcrun stapler staple Recommended_9_3.pkg
1 change: 1 addition & 0 deletions package-9.3/kernel/kernel.json
@@ -0,0 +1 @@
{"argv": ["/var/tmp/sage-9.3.rc2-current/local/bin/sage", "--python", "-m", "sage.repl.ipython_kernel", "-f", "{connection_file}"], "display_name": "Sage 9.3", "language": "sage"}
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion package-9.2/local/bin/sage → package-9.3/local_bin/sage
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
SYMLINK=/var/tmp/sage-jc4b6yulaujayb9sr94ia88eourzeqip0oidmas3
SYMLINK=/var/tmp/sage-9.3.rc2-current
if [ ! -e $SYMLINK ]; then
APP_PATH=`osascript \
-e 'set appAlias to ""' \
Expand Down
13 changes: 13 additions & 0 deletions package-9.3/local_bin/scripts/preinstall
@@ -0,0 +1,13 @@
#!/bin/bash
ANSWER=Yes
if [ -e /usr/local/bin/sage ]; then
ANSWER=`osascript \
-e 'button returned of (display dialog "May we overwrite your current /usr/local/bin/sage file?" buttons {"No", "Yes"})' \
`
if [ $ANSWER == "Yes" ]; then
exit 0
else
osascript -e 'display dialog "Please rerun the installer, but press \"Customize\" and uncheck \"Sage Script\"" buttons {"OK"}'
exit 1
fi
fi
Binary file added package-9.3/packages/SageMath_bin.pkg
Binary file not shown.
Binary file added package-9.3/packages/SageMath_share.pkg
Binary file not shown.
38 changes: 38 additions & 0 deletions package-9.3/resources/Welcome.rtf
@@ -0,0 +1,38 @@
{\rtf1\ansi\ansicpg1252\cocoartf2577
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica-Bold;\f1\fswiss\fcharset0 Helvetica;\f2\fnil\fcharset0 Menlo-Regular;
\f3\fswiss\fcharset0 Helvetica-Oblique;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
{\*\expandedcolortbl;;\cssrgb\c0\c0\c0;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid101\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid2}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}}
\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\b\fs36 \cf0 The SageMath-9.3 App
\fs24 \
\
\fs32 Recommended Extras
\fs28 \
\
\f1\b0 This installer adds two optional additional features to your SageMath-9.3 app.\
\
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\sl288\slmult1\pardirnatural\partightenfactor0
\ls1\ilvl0\cf0 {\listtext \uc0\u8226 }A script
\f2\fs24 \cf2 /usr/local/bin/sage
\f1\fs28 \cf0 which starts Sage from any terminal window or from a script. This requires that you add
\f2\fs24 \cf2 /usr/local/bin
\f1\fs28 \cf0 to your path.\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\sl288\slmult1\pardirnatural\partightenfactor0
\cf0 \
\pard\tx220\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\sl288\slmult1\pardirnatural\partightenfactor0
\ls2\ilvl0\cf0 {\listtext \uc0\u8226 }A directory
\f2\fs24 \cf2 /usr/local/share/jupyter/
\f1\fs28 \cf0 which enables JupyterLab to detect the SageMath kernel.\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
To disable installation of either feature, press \'93Customize\'94 on the
\f3\i Installation Type
\f1\i0 screen.}
Binary file added package-9.3/resources/sagelogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dca5d37

Please sign in to comment.