Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/setup.py: Move excepthook to new module sage_setup.excepthook
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe authored and dimpase committed Jun 15, 2020
1 parent 7c4bbf6 commit ddc49aa
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
1 change: 1 addition & 0 deletions build/bin/sage-logger
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ fi

cmd="$1"
logfile="$2"
export SAGE_LOGFILE="$logfile"
logname="$(basename $logfile .log)"
logdir=`dirname "$logfile"`

Expand Down
30 changes: 30 additions & 0 deletions src/sage_setup/excepthook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import sys

def excepthook(*exc):
"""
When an error occurs, display an error message similar to the error
messages from ``sage-spkg``.
In particular, ``build/make/install`` will recognize "sage" as a failed
package, see :trac:`16774`.
"""
stars = '*' * 72

print(stars, file=sys.stderr)
import traceback
traceback.print_exception(*exc, file=sys.stderr)
print(stars, file=sys.stderr)
print("Error building the Sage library", file=sys.stderr)
print(stars, file=sys.stderr)

try:
logfile = os.environ['SAGE_LOGFILE'] # Set by build/bin/sage-logger
except Exception:
pass
else:
print("Please email sage-devel (http://groups.google.com/group/sage-devel)", file=sys.stderr)
print("explaining the problem and including the relevant part of the log file", file=sys.stderr)
print(" " + logfile, file=sys.stderr)
print("Describe your computer, operating system, etc.", file=sys.stderr)
print(stars, file=sys.stderr)
35 changes: 3 additions & 32 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,6 @@
from distutils import log
from distutils.core import setup

def excepthook(*exc):
"""
When an error occurs, display an error message similar to the error
messages from ``sage-spkg``.
In particular, ``build/make/install`` will recognize "sage" as a failed
package, see :trac:`16774`.
"""
stars = '*' * 72

print(stars, file=sys.stderr)
import traceback
traceback.print_exception(*exc, file=sys.stderr)
print(stars, file=sys.stderr)
print("Error building the Sage library", file=sys.stderr)
print(stars, file=sys.stderr)

try:
logfile = os.path.join(os.environ['SAGE_LOGS'],
"sagelib-%s.log" % os.environ['SAGE_VERSION'])
except Exception:
pass
else:
print("Please email sage-devel (http://groups.google.com/group/sage-devel)", file=sys.stderr)
print("explaining the problem and including the relevant part of the log file", file=sys.stderr)
print(" " + logfile, file=sys.stderr)
print("Describe your computer, operating system, etc.", file=sys.stderr)
print(stars, file=sys.stderr)

sys.excepthook = excepthook


#########################################################
### Set source directory
#########################################################
Expand All @@ -48,6 +16,9 @@ def excepthook(*exc):
sage.env.SAGE_SRC = os.getcwd()
from sage.env import *

from sage_setup import excepthook
sys.excepthook = excepthook

# This import allows instancemethods to be pickable
import sage_setup.fpickle_setup

Expand Down

0 comments on commit ddc49aa

Please sign in to comment.