Skip to content

Commit

Permalink
Trac #15465: Allow using Sage without dev/git
Browse files Browse the repository at this point in the history
For binary builds / system-wide installs and perhaps tarballs we should
not require the git repository. This ticket fixes two doctests for that
use case.

That is, to remove the development functionality you can now
* delete `SAGE_SRC/sage/dev`
* delete `SAGE_ROOT/.git`
and all doctests still pass

URL: http://trac.sagemath.org/15465
Reported by: vbraun
Ticket author(s): Volker Braun
Reviewer(s): R. Andrew Ohana
  • Loading branch information
Release Manager authored and vbraun committed Dec 16, 2013
2 parents e1a7d2a + 24e5a73 commit 608159c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
22 changes: 20 additions & 2 deletions src/bin/sage-dev
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,26 @@ import inspect
import sys
from textwrap import dedent

if __name__ == '__main__':
from sage.dev.sagedev_instance import dev as DEV
DISABLED_MESSAGE = """
Developer interface disabled.
To develop for Sage you must compile Sage from its git
repository. This just amounts to running
git clone git://github.com/sagemath/sage.git
cd sage
make
See http://trac.sagemath.org/wiki/QuickStartSageGit for slightly more
information.
"""

try:
from sage.all import dev as DEV
except ImportError:
print(DISABLED_MESSAGE.strip())
sys.exit(0)


class SageHelpFormatter(argparse.HelpFormatter):
"""
Expand Down
6 changes: 4 additions & 2 deletions src/sage/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@

from sage.libs.all import *
from sage.doctest.all import *
if SAGE_ROOT is not None:
from sage.dev.all import *
try:
from sage.dev.all import *
except ImportError:
pass # dev scripts are disabled

from sage.rings.all import *
from sage.matrix.all import *
Expand Down
16 changes: 10 additions & 6 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def add_files(self):
sage: DD = DocTestDefaults(new = True)
sage: DC = DocTestController(DD, [])
sage: DC.add_files()
Doctesting files ...
Doctesting ...
::
Expand All @@ -458,22 +458,26 @@ def add_files(self):
"""
opj = os.path.join
from sage.env import SAGE_SRC, SAGE_ROOT
if self.options.all:
self.log("Doctesting entire Sage library.")
def all_files():
from glob import glob
self.files.append(opj(SAGE_SRC, 'sage'))
self.files.append(opj(SAGE_SRC, 'doc', 'common'))
self.files.extend(glob(opj(SAGE_SRC, 'doc', '[a-z][a-z]')))
self.options.sagenb = True
elif self.options.new:
DOT_GIT= opj(SAGE_ROOT, '.git')
have_git = os.path.exists(DOT_GIT)
if self.options.all or (self.options.new and not have_git):
self.log("Doctesting entire Sage library.")
all_files()
elif self.options.new and have_git:
# Get all files changed in the working repo.
self.log("Doctesting files changed since last git commit")
import subprocess
change = subprocess.check_output(["git",
"--git-dir=" + SAGE_ROOT + "/.git",
"--git-dir=" + DOT_GIT,
"--work-tree=" + SAGE_ROOT,
"status",
"--porcelain"])
self.log("Doctesting files changed since last git commit")
for line in change.split("\n"):
if not line:
continue
Expand Down
4 changes: 3 additions & 1 deletion src/sage/tests/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,13 @@ def test_executable(args, input="", timeout=100.0, **kwds):
sage: (out, err, ret) = test_executable(["sage", "--dev", "help"])
sage: ret, err
(0, '')
sage: print out
sage: print out # random output
usage: sage-dev [-h] subcommand ...
<BLANKLINE>
The developer interface for sage.
...
sage: ('usage: sage-dev' in out) or ('Developer interface disabled' in out)
True
sage: (out, err, ret) = test_executable(["sage", "--ecl"], "(* 12345 54321)\n")
sage: out.find("Embeddable Common-Lisp") >= 0
Expand Down

0 comments on commit 608159c

Please sign in to comment.