Opened 14 years ago
Last modified 10 years ago
#5155 closed defect
Fix doctests and methods that want write access to $SAGE_LOCAL — at Version 8
Reported by:  mabshoff  Owned by:  jdemeyer 

Priority:  critical  Milestone:  sage5.7 
Component:  scripts  Keywords:  
Cc:  lftabera, leif  Merged in:  
Authors:  Mike Hansen  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  Commit:  
Dependencies:  #11926  Stopgaps: 
Description (last modified by )
All doctests in Sage should pass when they are run as a user that does not have write access to the Sage install. To do that, set SAGE_TESTDIR to some place writable, for example
export SAGE_TESTDIR=$HOME/tmp
and run the doctests on a Sage install that isn't owned by the user:
$ ./sage tp 6 devel/sage/doc/common devel/sage/doc/de devel/sage/doc/en devel/sage/doc/fr devel/sage/doc/ru devel/sage/sage
Here, we assume that the owner of the Sage install has run Sage at least once (or has applied #11926) and has ran some doctest.
On sage4.7.2.alpha4, this causes the following failures:
sage t long devel/sage/sage/matrix/matrix2.pyx # 1 doctests failed sage t long devel/doc/tut/tut.tex # 5 doctests failed sage t long devel/sage/sage/interfaces/qepcad.py # 2 doctests failed sage t long devel/sage/sage/plot/plot.py # 6 doctests failed sage t long devel/sage/sage/databases/database.py # 1 doctests failed sage t long devel/sage/sage/calculus/calculus.py # 1 doctests failed sage t long devel/sage/sage/misc/package.py # 1 doctests failed sage t long devel/sage/sage/gsl/ode.pyx # 4 doctests failed sage t long devel/sage/sage/server/support.py # 1 doctests failed sage t long devel/sage/sage/server/notebook/notebook.py # 1 doctests failed sage t long devel/sage/sage/server/notebook/twist.py # 8 doctests failed sage t long devel/sage/sage/structure/sage_object.pyx # 6 doctests failed
Change History (8)
comment:1 Changed 13 years ago by
 Report Upstream set to N/A
 Status changed from new to needs_review
comment:2 Changed 13 years ago by
 Status changed from needs_review to needs_work
comment:3 Changed 12 years ago by
Some of the doctest are ok nowadays but there are other new fails. See for example #9965
I can confirm that, with sage 4.5.3 I get the following doctest failures:
sage t long "devel/sage/doc/common/builder.py" sage t long "devel/sage/sage/interfaces/qepcad.py" sage t long "devel/sage/sage/schemes/elliptic_curves/ell_rational_field.py" sage t long "devel/sage/sage/modular/hecke/submodule.py" sage t long "devel/sage/sage/modular/abvar/abvar.py" sage t long "devel/sage/sage/lfunctions/sympow.py"
All except quecad are trying to be solved in #9965
comment:4 Changed 12 years ago by
qepcad failures
sage t long "devel/sage/sage/interfaces/qepcad.py" ********************************************************************** File "/opt/SAGE/sage/devel/sage/sage/interfaces/qepcad.py", line 638: sage: _rewrite_qepcadrc() Exception raised: Traceback (most recent call last): File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/opt/SAGE/sage/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_3[3]>", line 1, in <module> _rewrite_qepcadrc()###line 638: sage: _rewrite_qepcadrc() File "/opt/SAGE/sage/local/lib/python/sitepackages/sage/interfaces/qepcad.py", line 660, in _rewrite_qepcadrc open(fn, 'w').write(text) IOError: [Errno 13] Permission denied: '/opt/SAGE/sage/local//default.qepcadrc' ********************************************************************** File "/opt/SAGE/sage/devel/sage/sage/interfaces/qepcad.py", line 689: sage: Qepcad_expect(memcells=100000, logfile=sys.stdout) Exception raised: Traceback (most recent call last): File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1231, in run_one_test self.run_one_example(test, example, filename, compileflags) File "/opt/SAGE/sage/local/bin/sagedoctest.py", line 38, in run_one_example OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags) File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1172, in run_one_example compileflags, 1) in test.globs File "<doctest __main__.example_6[3]>", line 1, in <module> Qepcad_expect(memcells=Integer(100000), logfile=sys.stdout)###line 689: sage: Qepcad_expect(memcells=100000, logfile=sys.stdout) File "/opt/SAGE/sage/local/lib/python/sitepackages/sage/interfaces/qepcad.py", line 692, in __init__ _rewrite_qepcadrc() File "/opt/SAGE/sage/local/lib/python/sitepackages/sage/interfaces/qepcad.py", line 660, in _rewrite_qepcadrc open(fn, 'w').write(text) IOError: [Errno 13] Permission denied: '/opt/SAGE/sage/local//default.qepcadrc' ********************************************************************** 2 items had failures: 1 of 6 in __main__.example_3 1 of 4 in __main__.example_6 ***Test Failed*** 2 failures. For whitespace errors, see the file /home/usuario/.sage//tmp/.doctest_qepcad.py [1.9 s]
comment:5 Changed 12 years ago by
 Cc lftabera added
 Summary changed from Sage 3.3.a3: fix doctests that want write access to $SAGE_LOCAL to Fix doctests and methods that want write access to $SAGE_LOCAL
Another issue, if you compile sage but the very first access of sage is made by a user without write permissions, you get the following error:
 Sage Version 4.5.3, Release Date: 20100904   Type notebook() for the GUI, and license() for information. 
Traceback (most recent call last):
File "/opt/SAGE/sage4.5.3/local/bin/sagelocation", line 174, in <module>
t, R = install_moved()
File "/opt/SAGE/sage4.5.3/local/bin/sagelocation", line 18, in install_moved
write_flags_file()
File "/opt/SAGE/sage4.5.3/local/bin/sagelocation", line 82, in write_flags_file
open(flags_file,'w').write(get_flags_info())
IOError: [Errno 13] Permission denied: '/opt/SAGE/sage4.5.3/local/lib/sageflags.txt'
comment:6 Changed 11 years ago by
With Sage 4.7.2.alpha2, I see problems with qepcad and sympow. I think the qepcad problem should be easy to solve, basically as mhansen did before:

sage/interfaces/qepcad.py
diff git a/sage/interfaces/qepcad.py b/sage/interfaces/qepcad.py
a b def _rewrite_qepcadrc(): 636 636 EXAMPLES: 637 637 sage: from sage.interfaces.qepcad import _rewrite_qepcadrc 638 638 sage: _rewrite_qepcadrc() 639 sage: from sage.misc.misc import SAGE_LOCAL640 sage: open('%s/default.qepcadrc'% SAGE_LOCAL).readlines()[1]639 sage: from sage.misc.misc import DOT_SAGE 640 sage: open('%s/default.qepcadrc'%DOT_SAGE).readlines()[1] 641 641 'SINGULAR .../local//bin' 642 642 """ 643 643 global _rewrote_qepcadrc 644 644 if _rewrote_qepcadrc: return 645 645 646 SL = sage.misc.misc. SAGE_LOCAL646 SL = sage.misc.misc.DOT_SAGE 647 647 fn = '%s/default.qepcadrc'%SL 648 648 text = \ 649 649 """# THIS FILE IS AUTOMATICALLY GENERATED  DO NOT EDIT
Sympow will be harder to deal with, because of how the spkg is written: it tries to write files to SAGE_LOCAL/lib/sympow. See http://trac.sagemath.org/sage_trac/ticket/9703#comment:9 for a possible fix.
I'm attaching a patch to try to deal with the situation when you run Sage for the very first time as a user without write permissions.
Finally, there may be other issues if you compile Sage but don't run it, and then run doctests as a user without write permissions (the first time doctests get run, they might write some files which don't need to be written later). These issues should be fixed, too.
comment:7 Changed 11 years ago by
I'm not sure this patch is a good idea or needed, considering #11926. If the Sage install was moved, it is probably good to bail out with an error if there is no write access.
comment:8 Changed 11 years ago by
 Dependencies set to #11926
 Description modified (diff)
 Owner changed from mabshoff to jdemeyer
Before applying the patch, I get two doctest failures (with a nonwriteable Sage install). Applying the patch "trac_5155.patch" fixes both. So positive review for that.
The scripts patch wasn't necessary to get those tests to pass, and it also doesn't apply cleanly to 4.3.1:
The changes there look fine in principle, though. So once it's rebased, positive review there, too.