Changeset 7599:584fb51a671c


Ignore:
Timestamp:
12/10/07 14:22:43 (5 years ago)
Author:
mabshoff@…
Branch:
default
Parents:
7572:61c96b713e46 (diff), 7598:610450e0810d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • setup.py

    r7570 r7599  
    881881              ), \ 
    882882 
     883    Extension('sage.rings.polynomial.pbori', 
     884              sources = ['sage/rings/polynomial/pbori.pyx'], 
     885              libraries=['polybori','pboriCudd','groebner'], 
     886              include_dirs=[SAGE_ROOT+'/local/include/cudd', 
     887                            SAGE_ROOT+'/local/include/polybori', 
     888                            SAGE_ROOT+'/local/include/polybori/groebner'], 
     889              language = 'c++'), \ 
    883890                             
    884891    ] 
  • setup.py

    r7598 r7599  
    99from distutils.extension import Extension 
    1010from Cython.Distutils import build_ext 
    11  
    12  
    1311 
    1412## Choose cblas library -- note -- make sure to update sage/misc/cython.py 
     
    206204                         "sage/libs/mwrank/wrap.cc"], 
    207205                    define_macros = [("NTL_ALL",None)], 
    208                     libraries = ["mwrank", "ntl", "gmp", "gmpxx", "stdc++", "m", "pari"]) 
     206                    libraries = ["curvesntl", "g0nntl", "jcntl", "rankntl", "ntl", "gmp", "gmpxx", "stdc++", "m", "pari"]) 
    209207 
    210208pari = Extension('sage.libs.pari.gen', 
     
    921919###################################################################### 
    922920 
    923 def check_dependencies( filename, outfile ): 
     921def get_dependencies(filename): 
    924922    """ 
    925     INPUT: 
    926         filename -- The name of a .pyx, .pxd, or .pxi to check dependencies in the SAGE source. 
    927         outfile -- The output file for which we are determining out-of-date-ness 
    928  
    929     OUTPUT: 
    930         bool -- whether or not outfile must be regenerated. 
     923    computes everything that this file depends on 
    931924    """ 
    932     if is_older(filename, outfile): 
    933         print "\nBuilding %s because it depends on %s."%(outfile, filename) 
    934         return True 
    935  
     925    li = [] 
    936926    # Now we look inside the file to see what it cimports or include. 
    937927    # If any of these files are newer than outfile, we rebuild 
     
    971961        # Check to see if a/b/c/d.pxd exists and is newer than filename. 
    972962        # If so, we have to regenerate outfile.  If not, we're safe. 
    973         if os.path.exists(A) and check_dependencies(A, outfile): 
    974             return True # yep we must rebuild 
     963        A = os.path.normpath(A) 
     964        if os.path.exists(A): 
     965            li.extend(get_dependencies(A)) 
     966            li.append(A) 
    975967 
    976968    # OK, next we move on to include pxi files. 
     
    1000992            A = R # restore 
    1001993        # Finally, check to see if filename is older than A 
    1002         if os.path.exists(A) and check_dependencies(A, outfile): 
     994        A = os.path.normpath(A) 
     995        if os.path.exists(A): 
     996            li.extend(get_dependencies(A)) 
     997            li.append(A) 
     998             
     999    # if we get here, this file depends on nothing 
     1000    return li 
     1001 
     1002def check_dependencies(filename, outfile, deps_of): 
     1003    """ 
     1004    INPUT: 
     1005        filename -- The name of a .pyx, .pxd, or .pxi to check dependencies in the SAGE source. 
     1006        outfile -- The output file for which we are determining out-of-date-ness 
     1007 
     1008    OUTPUT: 
     1009        bool -- whether or not outfile must be regenerated. 
     1010    """ 
     1011    # add filename to depend on filename 
     1012    try: 
     1013        deps = deps_of[filename] 
     1014    except KeyError: 
     1015        return True 
     1016 
     1017    for dep in deps: 
     1018        if is_older(dep, outfile): 
     1019            print "\nBuilding %s because it depends on %s."%(outfile, dep) 
    10031020            return True 
    10041021 
    1005  
    1006 def need_to_cython(filename, outfile): 
     1022def need_to_cython(filename, outfile, deps): 
    10071023    """ 
    10081024    INPUT: 
    10091025        filename -- The name of a cython file in the SAGE source tree. 
    10101026        outfile -- The name of the corresponding c or cpp file in the build directory. 
     1027        deps -- a structure containing dependency information 
    10111028 
    10121029    OUTPUT: 
     
    10171034    pxd = base+'.pxd' 
    10181035 
    1019     if check_dependencies(filename, outfile): 
     1036    if check_dependencies(filename, outfile, deps): 
    10201037        return True 
    1021     elif os.path.exists(pxd) and check_dependencies(pxd, outfile): 
     1038    if os.path.exists(pxd) and check_dependencies(pxd, outfile, deps): 
    10221039        return True 
    1023     else: 
    1024         return False 
    1025  
    1026 def process_cython_file(f, m): 
     1040    return False 
     1041 
     1042def process_cython_file(f, m, deps_of): 
    10271043    """ 
    10281044    INPUT: 
     
    10321048    # This is a cython file, so process accordingly. 
    10331049    pyx_inst_file = '%s/%s'%(SITE_PACKAGES, f) 
     1050    # if f is *more recent* than the pyx_install_file 
    10341051    if is_older(f, pyx_inst_file): 
    10351052        print "%s --> %s"%(f, pyx_inst_file) 
    10361053        os.system('cp %s %s 2>/dev/null'%(f, pyx_inst_file)) 
     1054        # we need to recompute the dependencies, here 
     1055        deps_list = get_dependencies(f) 
     1056        try: 
     1057            deps_of[f].extend(deps_list) 
     1058        except KeyError: 
     1059            deps_of[f] = deps_list 
    10371060    outfile = f[:-4] + ".c" 
    10381061    if m.language == 'c++': 
    10391062        outfile += 'pp' 
    10401063 
    1041     if need_to_cython(f, outfile): 
     1064    if need_to_cython(f, outfile, deps_of): 
    10421065        # Insert the -o parameter to specify the output file (particularly for c++) 
    1043         cmd = "cython --embed-positions --incref-local-binop -I%s -o %s %s"%(os.getcwd(), outfile, f) 
     1066        cmd = "cython --embed-positions --incref-local-binop -I%s -o %s %s"%(os.getcwd(), outfile, f ) 
    10441067        print cmd 
    10451068        ret = os.system(cmd) 
     
    10471070            print "sage: Error running cython." 
    10481071            sys.exit(1) 
     1072 
    10491073    return [outfile] 
    10501074     
    10511075 
    10521076def cython(ext_modules): 
     1077    import pickle 
     1078    deps_filename = SAGE_DEVEL + 'sage/.cython_dependencies' 
     1079    # check if the cached dependency information is there 
     1080    if os.path.exists(deps_filename): 
     1081        deps_file = open(deps_filename, 'r') 
     1082        deps_of = pickle.load(deps_file) 
     1083        deps_file.close() 
     1084        deps_file = None 
     1085        compute_all_deps = False 
     1086    else: 
     1087        compute_all_deps = True 
     1088        deps_of = {} 
     1089 
     1090    tot = 0 
    10531091    for m in ext_modules: 
    10541092        m.extra_compile_args += extra_compile_args 
     
    10571095        for i in range(len(m.sources)): 
    10581096            f = m.sources[i] 
    1059 #            s = open(f).read() 
     1097            if compute_all_deps: 
     1098                deps_list = get_dependencies(f) 
     1099                try: 
     1100                    deps_of[f].extend(deps_list) 
     1101                except KeyError: 
     1102                    deps_of[f] = deps_list 
     1103                pxd_file = f[:-4] + '.pxd' 
     1104                if os.path.exists(pxd_file): 
     1105                    deps_list = get_dependencies(pxd_file) 
     1106                    try: 
     1107                        deps_of[pxd_file].extend(deps_list) 
     1108                    except KeyError: 
     1109                        deps_of[pxd_file] = deps_list 
     1110 
    10601111            if f[-4:] == ".pyx": 
    1061                 new_sources += process_cython_file(f, m) 
     1112                # run cython, to output the corresponding c/cpp file, 
     1113                # if needed 
     1114                new_sources += process_cython_file(f, m, deps_of) 
    10621115            else: 
    10631116                new_sources.append(f) 
     1117 
    10641118        m.sources = new_sources 
    1065  
    1066          
     1119        tot +=  len(m.sources) 
     1120 
     1121    # now cache the dependencies if we just computed them 
     1122    deps_file = open(deps_filename, 'w') 
     1123    pickle.dump(deps_of, deps_file) 
     1124    deps_file.close() 
    10671125 
    10681126if not sdist: 
     
    11531211                      
    11541212                     'sage.monoids', 
     1213 
     1214                     'sage.numerical',  
    11551215                      
    11561216                     'sage.plot', 
Note: See TracChangeset for help on using the changeset viewer.