Changeset 8057:20cd22d1b4f7


Ignore:
Timestamp:
01/15/08 14:27:59 (5 years ago)
Author:
Robert Bradshaw <robertwb@…>
Branch:
default
Message:

Improve use of cython in notebook

  • automatically import sage.all (when Cython upgraded)
  • html code annotation
  • shorten long filenames in output
Location:
sage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sage/misc/cython.py

    r7666 r8057  
    133133 
    134134def cython(filename, verbose=False, compile_message=False, 
    135           use_cache=False, create_local_c_file=False): 
     135          use_cache=False, create_local_c_file=False, annotate=True, sage_namespace=True): 
    136136    if not filename.endswith('pyx'): 
    137137        print "File (=%s) should have extension .pyx"%filename 
     
    218218 
    219219    cython_include = ' '.join(["-I '%s'"%x for x in includes if len(x.strip()) > 0 ]) 
    220  
    221     cmd = "cd '%s' && cython -p --incref-local-binop %s '%s.pyx' 1>log 2>err " % (build_dir, cython_include, name) 
     220     
     221    options = ['-p', '--incref-local-binop'] 
     222    if annotate: 
     223        options.append('-a') 
     224    if sage_namespace: 
     225        options.append('--pre-import sage.all') 
     226 
     227    cmd = "cd '%s' && cython %s %s '%s.pyx' 1>log 2>err " % (build_dir, ' '.join(options), cython_include, name) 
    222228 
    223229    if create_local_c_file: 
     
    226232            target_c = target_c + "pp" 
    227233        cmd += " && cp '%s.c' '%s'"%(name, target_c) 
     234        if annotate: 
     235            target_html = '%s/_%s.pyx.html'%(os.path.abspath(os.curdir), base) 
     236            cmd += " && cp '%s.pyx.html' '%s'"%(name, target_html) 
    228237         
    229238    if verbose: 
  • sage/server/notebook/cell.py

    r7996 r8057  
    614614                pass # jmol data 
    615615            else: 
    616                 files.append('<a href="%s" class="file_link">%s</a>'%(url, F)) 
     616                link_text = str(F) 
     617                if len(link_text) > 40: 
     618                    link_text = link_text[:10] + '...' + link_text[-20:] 
     619                files.append('<a href="%s" class="file_link">%s</a>'%(url, link_text)) 
    617620        if len(images) == 0: 
    618621            images = '' 
Note: See TracChangeset for help on using the changeset viewer.