Ticket #9191: 9191_doctest_spyx.patch

File 9191_doctest_spyx.patch, 4.5 KB (added by jdemeyer, 9 years ago)
  • sage/misc/cython.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1348748664 -7200
    # Node ID c75673dfa9f3799d1aa0e43cc77d5eeff0918c49
    # Parent  e74c2b7648c9812e3de4ba3833e905ac9c4c75f4
    Doctest sage-run-cython, print "Compiling" message to stderr, use Python 3 syntax
    
    diff --git a/sage/misc/cython.py b/sage/misc/cython.py
    a b  
    77- William Stein (2007-07-28): update from sagex to cython
    88- Martin Albrecht & William Stein (2011-08): cfile & cargs
    99"""
    10 
    1110#*****************************************************************************
    1211#       Copyright (C) 2006 William Stein <wstein@gmail.com>
    1312#
     
    1615#                  http://www.gnu.org/licenses/
    1716#*****************************************************************************
    1817
     18from __future__ import print_function
     19
    1920import os, sys, platform
    2021
    2122from misc import SPYX_TMP, SAGE_ROOT, SAGE_LOCAL
     
    308309      information.
    309310
    310311    - ``compile_message`` (bool, default False) - if True, print
    311       ``'Compiling <filename>...'``
     312      ``'Compiling <filename>...'`` to the standard error.
    312313
    313314    - ``use_cache`` (bool, default False) - if True, check the
    314315      temporary build directory to see if there is already a
     
    355356
    356357    """
    357358    if not filename.endswith('pyx'):
    358         print "File (=%s) should have extension .pyx"%filename
     359        print("Warning: file (={}) should have extension .pyx".format(filename), file=sys.stderr)
    359360
    360361    # base is the name of the .so module that we create. If we are
    361362    # creating a local shared object file, we use a more natural
     
    407408            os.unlink("%s/setup.py" % build_dir)
    408409
    409410    if compile_message:
    410         print "Compiling %s..."%filename
     411        print("Compiling {}...".format(filename), file=sys.stderr)
    411412
    412413    F = open(filename).read()
    413414
     
    490491            cmd += " && cp '%s.html' '%s'"%(name, target_html)
    491492
    492493    if verbose:
    493         print cmd
     494        print(cmd)
    494495    if os.system(cmd):
    495496        log = open('%s/log'%build_dir).read()
    496497        err = subtract_from_line_numbers(open('%s/err'%build_dir).read(), offset)
     
    532533
    533534
    534535    cmd = 'cd %s && python setup.py build 1>log 2>err'%build_dir
    535     if verbose: print cmd
     536    if verbose:
     537        print(cmd)
    536538    if os.system(cmd):
    537539        log = open('%s/log'%build_dir).read()
    538540        err = open('%s/err'%build_dir).read()
     
    540542
    541543    # Move from lib directory.
    542544    cmd = 'mv %s/build/lib.*/* %s'%(build_dir, build_dir)
    543     if verbose: print cmd
     545    if verbose:
     546        print(cmd)
    544547    if os.system(cmd):
    545548        raise RuntimeError, "Error copying extension module for %s"%filename
    546549
     
    645648 return %s
    646649    """%(v, expr)
    647650    if verbose:
    648         print s
     651        print(s)
    649652    import sage.misc.misc
    650653    tmpfile = sage.misc.temporary_file.tmp_filename(ext=".spyx")
    651654    open(tmpfile,'w').write(s)
     
    690693        sage: f.write(s)
    691694        sage: f.close()
    692695        sage: cython_create_local_so('hello.spyx')
    693         Compiling hello.spyx...
    694696        sage: sys.path.append('.')
    695697        sage: import hello
    696698        sage: hello.hello()
  • sage/misc/preparser.py

    diff --git a/sage/misc/preparser.py b/sage/misc/preparser.py
    a b  
    15241524   
    15251525        sage: t=tmp_filename(ext='.pyx'); open(t,'w').write("print 'hi',2/3; z=-2/9")
    15261526        sage: z=0; sage.misc.preparser.load(t,globals())
    1527         Compiling ....pyx...
    15281527        hi 0
    15291528        sage: z
    15301529        -1
  • sage/tests/cmdline.py

    diff --git a/sage/tests/cmdline.py b/sage/tests/cmdline.py
    a b  
    88/path/to/test.py
    99test.sage
    1010/path/to/test.sage
     11test.spyx
     12/path/to/test.spyx
    1113--advanced
    1214--branch
    1315-c
     
    267269        sage: ret
    268270        0
    269271
     272    Test running a ``.spyx`` file::
     273
     274        sage: dir = tmp_dir(); name = 'sage_test_file.spyx'
     275        sage: fullname = os.path.join(dir, name)
     276        sage: F = open(fullname, 'w')
     277        sage: F.write("cdef long i, s = 0\nfor i in range(1000): s += i\nprint s")
     278        sage: F.close()
     279        sage: (out, err, ret) = test_executable(["sage", fullname])
     280        sage: print out
     281        499500
     282        sage: err
     283        'Compiling ...spyx...'
     284        sage: ret
     285        0
     286        sage: (out, err, ret) = test_executable(["sage", name], cwd=dir)
     287        sage: print out
     288        499500
     289        sage: err
     290        'Compiling ...spyx...'
     291        sage: ret
     292        0
     293
    270294    Testing ``sage --preparse FILE`` and ``sage -t FILE``.  First create
    271295    a file and preparse it::
    272296