| 1 | #!/usr/bin/env python |
|---|
| 2 | DEVEL = False |
|---|
| 3 | |
|---|
| 4 | import distutils.sysconfig, os, sys |
|---|
| 5 | from distutils.core import setup, Extension |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | ## Choose cblas library -- note -- make sure to update sage/misc/cython.py |
|---|
| 9 | ## if you change this!! |
|---|
| 10 | if os.environ.has_key('SAGE_BLAS'): |
|---|
| 11 | BLAS=os.environ['SAGE_BLAS'] |
|---|
| 12 | elif os.path.exists('/usr/lib/libcblas.dylib') or \ |
|---|
| 13 | os.path.exists('/usr/lib/libcblas.so'): |
|---|
| 14 | BLAS='cblas' |
|---|
| 15 | elif os.path.exists('/usr/lib/libblas.dll.a'): |
|---|
| 16 | BLAS='gslcblas' |
|---|
| 17 | else: |
|---|
| 18 | # This is very slow (?), but *guaranteed* to be available. |
|---|
| 19 | BLAS='gslcblas' |
|---|
| 20 | |
|---|
| 21 | if len(sys.argv) > 1 and sys.argv[1] == "sdist": |
|---|
| 22 | sdist = True |
|---|
| 23 | else: |
|---|
| 24 | sdist = False |
|---|
| 25 | |
|---|
| 26 | NO_WARN = True |
|---|
| 27 | |
|---|
| 28 | if not os.environ.has_key('SAGE_ROOT'): |
|---|
| 29 | print " ERROR: The environment variable SAGE_ROOT must be defined." |
|---|
| 30 | sys.exit(1) |
|---|
| 31 | else: |
|---|
| 32 | SAGE_ROOT = os.environ['SAGE_ROOT'] |
|---|
| 33 | SAGE_LOCAL = SAGE_ROOT + '/local/' |
|---|
| 34 | SAGE_DEVEL = SAGE_ROOT + '/devel/' |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | if not os.environ.has_key('SAGE_VERSION'): |
|---|
| 38 | SAGE_VERSION=0 |
|---|
| 39 | else: |
|---|
| 40 | SAGE_VERSION = os.environ['SAGE_VERSION'] |
|---|
| 41 | |
|---|
| 42 | SITE_PACKAGES = '%s/lib/python/site-packages/'%SAGE_LOCAL |
|---|
| 43 | if not os.path.exists(SITE_PACKAGES): |
|---|
| 44 | SITE_PACKAGES = '%s/lib/python2.5/site-packages/'%SAGE_LOCAL |
|---|
| 45 | if not os.path.exists(SITE_PACKAGES): |
|---|
| 46 | SITE_PACKAGES = '%s/lib/python2.4/site-packages/'%SAGE_LOCAL |
|---|
| 47 | if not os.path.exists(SITE_PACKAGES): |
|---|
| 48 | raise RuntimeError, "Unable to find site-packages directory (see setup.py file in sage python code)." |
|---|
| 49 | |
|---|
| 50 | SITE_PACKAGES_REL=SITE_PACKAGES[len(SAGE_LOCAL)+5:] |
|---|
| 51 | |
|---|
| 52 | if not os.path.exists('build/sage'): |
|---|
| 53 | os.makedirs('build/sage') |
|---|
| 54 | |
|---|
| 55 | sage_link = SITE_PACKAGES + '/sage' |
|---|
| 56 | if not os.path.islink(sage_link) or not os.path.exists(sage_link): |
|---|
| 57 | os.system('rm -rf "%s"'%sage_link) |
|---|
| 58 | os.system('cd %s; ln -sf ../../../../devel/sage/build/sage .'%SITE_PACKAGES) |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | def is_older(file1, file2): |
|---|
| 62 | """ |
|---|
| 63 | Return True if either file2 does not exist or is older than file1. |
|---|
| 64 | |
|---|
| 65 | If file1 does not exist, always return False. |
|---|
| 66 | """ |
|---|
| 67 | if not os.path.exists(file1): |
|---|
| 68 | return False |
|---|
| 69 | if not os.path.exists(file2): |
|---|
| 70 | return True |
|---|
| 71 | if os.path.getmtime(file2) < os.path.getmtime(file1): |
|---|
| 72 | return True |
|---|
| 73 | return False |
|---|
| 74 | |
|---|
| 75 | def is_src_file( f ): |
|---|
| 76 | ext = os.path.splitext( f )[1] |
|---|
| 77 | return ext == ".h" or ext == ".c" or ext == ".cpp" |
|---|
| 78 | |
|---|
| 79 | def needs_c_lib_build(): |
|---|
| 80 | lib = '../../local/lib/libcsage.so' |
|---|
| 81 | try: |
|---|
| 82 | files = os.listdir( 'c_lib' ) |
|---|
| 83 | except OSError: # during setup.py sdist |
|---|
| 84 | return False |
|---|
| 85 | src_files = ['c_lib/' + f for f in files if is_src_file( f )] |
|---|
| 86 | src_files += ['c_lib/SConstruct'] |
|---|
| 87 | for f in src_files: |
|---|
| 88 | if is_older( f, lib ): |
|---|
| 89 | return True |
|---|
| 90 | return False |
|---|
| 91 | |
|---|
| 92 | #### Build the c_lib first |
|---|
| 93 | if needs_c_lib_build() and os.system( "cd c_lib && scons install" ) != 0: |
|---|
| 94 | print " ERROR: The c_lib did not build successfully." |
|---|
| 95 | sys.exit(1) |
|---|
| 96 | |
|---|
| 97 | include_dirs = ['%s/include'%SAGE_LOCAL, '%s/include/python'%SAGE_LOCAL, \ |
|---|
| 98 | '%s/sage/sage/ext'%SAGE_DEVEL] |
|---|
| 99 | |
|---|
| 100 | def is_src_file( f ): |
|---|
| 101 | ext = os.path.splitext( f )[1] |
|---|
| 102 | return ext == ".h" or ext == ".c" or ext == ".cc" |
|---|
| 103 | |
|---|
| 104 | def needs_c_lib_build(): |
|---|
| 105 | lib = '../../local/lib/libcsage.so' |
|---|
| 106 | try: |
|---|
| 107 | files = os.listdir( 'c_lib/src' ) |
|---|
| 108 | except OSError: |
|---|
| 109 | return False |
|---|
| 110 | src_files = ['c_lib/src/' + f for f in files if is_src_file( f )] |
|---|
| 111 | src_files += ['c_lib/configure', 'c_lib/Makefile'] |
|---|
| 112 | for f in src_files: |
|---|
| 113 | if is_older( f, lib ): |
|---|
| 114 | return True |
|---|
| 115 | return False |
|---|
| 116 | |
|---|
| 117 | #### Build the c_lib first |
|---|
| 118 | if needs_c_lib_build() and os.system( "cd c_lib && make install" ) != 0: |
|---|
| 119 | print " ERROR: The c_lib did not build successfully." |
|---|
| 120 | sys.exit(1) |
|---|
| 121 | |
|---|
| 122 | ##################################################### |
|---|
| 123 | |
|---|
| 124 | hanke = Extension(name = "sage.libs.hanke.hanke", |
|---|
| 125 | sources = ["sage/libs/hanke/hanke.pyx", |
|---|
| 126 | "sage/libs/hanke/wrap.cc", |
|---|
| 127 | "sage/libs/hanke/Matrix_mpz/Matrix_mpz.cc", |
|---|
| 128 | "sage/libs/hanke/Matrix_mpz/CountLocal2.cc", |
|---|
| 129 | "sage/libs/hanke/Matrix_mpz/CountLocal.cc", |
|---|
| 130 | "sage/libs/hanke/Matrix_mpz/Local_Constants.cc", |
|---|
| 131 | "sage/libs/hanke/Matrix_mpz/Local_Density_Front.cc", |
|---|
| 132 | "sage/libs/hanke/Matrix_mpz/Local_Density_Congruence.cc", |
|---|
| 133 | "sage/libs/hanke/Matrix_mpz/Local_Normal.cc", |
|---|
| 134 | "sage/libs/hanke/Matrix_mpz/Local_Invariants.cc", |
|---|
| 135 | "sage/libs/hanke/Utilities/string_utils.cc", |
|---|
| 136 | "sage/libs/hanke/GMP_class_extras/mpz_class_extras.cc", |
|---|
| 137 | "sage/libs/hanke/GMP_class_extras/vectors.cc" ], |
|---|
| 138 | libraries = ["gmp", "gmpxx", "stdc++"]) |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | # NOTE: It is *very* important (for cygwin) that csage be the first library |
|---|
| 142 | # listed below for ntl. |
|---|
| 143 | ntl = Extension('sage.libs.ntl.ntl', |
|---|
| 144 | sources = ["sage/libs/ntl/ntl.pyx"], |
|---|
| 145 | libraries = ["csage", "ntl", "gmp", "gmpxx", "m", "stdc++"] |
|---|
| 146 | ) |
|---|
| 147 | |
|---|
| 148 | mwrank = Extension("sage.libs.mwrank.mwrank", |
|---|
| 149 | sources = ["sage/libs/mwrank/mwrank.pyx", |
|---|
| 150 | "sage/libs/mwrank/wrap.cc"], |
|---|
| 151 | define_macros = [("NTL_ALL",None)], |
|---|
| 152 | libraries = ["mwrank", "ntl", "gmp", "gmpxx", "stdc++", "m", "pari"]) |
|---|
| 153 | |
|---|
| 154 | pari = Extension('sage.libs.pari.gen', |
|---|
| 155 | sources = ["sage/libs/pari/gen.pyx"], |
|---|
| 156 | libraries = ['pari', 'gmp']) |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | givaro_gfq = Extension('sage.rings.finite_field_givaro', |
|---|
| 160 | sources = ["sage/rings/finite_field_givaro.pyx"], |
|---|
| 161 | libraries = ['givaro', 'gmpxx', 'gmp', 'm', 'stdc++', ], # this order is needed to compile under windows. |
|---|
| 162 | language='c++' |
|---|
| 163 | ) |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | qd = Extension('sage.rings.real_rqdf', |
|---|
| 167 | sources = ["sage/rings/real_rqdf.pyx"], |
|---|
| 168 | libraries = ['qd', 'm', 'stdc++','gmp','mpfr' ], |
|---|
| 169 | language='c++' |
|---|
| 170 | ) |
|---|
| 171 | |
|---|
| 172 | matrix = Extension('sage.matrix.matrix', ['sage/matrix/matrix.pyx']) |
|---|
| 173 | |
|---|
| 174 | matrix_misc = Extension('sage.matrix.misc', ['sage/matrix/misc.pyx'], |
|---|
| 175 | libraries=['gmp']) |
|---|
| 176 | |
|---|
| 177 | matrix_dense = Extension('sage.matrix.matrix_dense', |
|---|
| 178 | ['sage/matrix/matrix_dense.pyx']) |
|---|
| 179 | |
|---|
| 180 | matrix_sparse = Extension('sage.matrix.matrix_sparse', |
|---|
| 181 | ['sage/matrix/matrix_sparse.pyx']) |
|---|
| 182 | |
|---|
| 183 | matrix_generic_dense = Extension('sage.matrix.matrix_generic_dense', |
|---|
| 184 | ['sage/matrix/matrix_generic_dense.pyx']) |
|---|
| 185 | |
|---|
| 186 | matrix_generic_sparse = Extension('sage.matrix.matrix_generic_sparse', |
|---|
| 187 | ['sage/matrix/matrix_generic_sparse.pyx']) |
|---|
| 188 | |
|---|
| 189 | matrix_domain_dense = Extension('sage.matrix.matrix_domain_dense', |
|---|
| 190 | ['sage/matrix/matrix_domain_dense.pyx']) |
|---|
| 191 | |
|---|
| 192 | matrix_domain_sparse = Extension('sage.matrix.matrix_domain_sparse', |
|---|
| 193 | ['sage/matrix/matrix_domain_sparse.pyx']) |
|---|
| 194 | |
|---|
| 195 | matrix_pid_dense = Extension('sage.matrix.matrix_pid_dense', |
|---|
| 196 | ['sage/matrix/matrix_pid_dense.pyx']) |
|---|
| 197 | |
|---|
| 198 | matrix_pid_sparse = Extension('sage.matrix.matrix_pid_sparse', |
|---|
| 199 | ['sage/matrix/matrix_pid_sparse.pyx']) |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | matrix_integer_2x2 = Extension('sage.matrix.matrix_integer_2x2', |
|---|
| 203 | ['sage/matrix/matrix_integer_2x2.pyx'], |
|---|
| 204 | libraries = ['gmp']) |
|---|
| 205 | |
|---|
| 206 | linbox = Extension('sage.libs.linbox.linbox', |
|---|
| 207 | ['sage/libs/linbox/linbox.pyx'], |
|---|
| 208 | # For this to work on cygwin, linboxwrap *must* be before ntl. |
|---|
| 209 | libraries = ['linboxwrap', 'ntl', 'linbox', 'gmp', 'gmpxx', 'stdc++', 'givaro', BLAS], |
|---|
| 210 | language = 'c++') |
|---|
| 211 | |
|---|
| 212 | libsingular = Extension('sage.libs.singular.singular', |
|---|
| 213 | sources = ['sage/libs/singular/singular.pyx'], |
|---|
| 214 | libraries = ['gmp', 'm', 'readline', 'singular', 'singfac', 'singcf', 'omalloc', 'givaro', 'gmpxx'], |
|---|
| 215 | language="c++", |
|---|
| 216 | include_dirs=[SAGE_ROOT +'/local/include/singular'] |
|---|
| 217 | ) |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | matrix_modn_dense = Extension('sage.matrix.matrix_modn_dense', |
|---|
| 221 | ['sage/matrix/matrix_modn_dense.pyx'], |
|---|
| 222 | libraries = ['gmp']) |
|---|
| 223 | |
|---|
| 224 | matrix_mod2_dense = Extension('sage.matrix.matrix_mod2_dense', |
|---|
| 225 | ['sage/matrix/matrix_mod2_dense.pyx', |
|---|
| 226 | 'sage/libs/m4ri/packedmatrix.c', |
|---|
| 227 | 'sage/libs/m4ri/matrix.c', |
|---|
| 228 | 'sage/libs/m4ri/brilliantrussian.c', |
|---|
| 229 | 'sage/libs/m4ri/grayflex.c',], |
|---|
| 230 | libraries = ['gmp']) |
|---|
| 231 | |
|---|
| 232 | matrix_modn_sparse = Extension('sage.matrix.matrix_modn_sparse', |
|---|
| 233 | ['sage/matrix/matrix_modn_sparse.pyx']) |
|---|
| 234 | |
|---|
| 235 | matrix_field_dense = Extension('sage.matrix.matrix_field_dense', |
|---|
| 236 | ['sage/matrix/matrix_field_dense.pyx']) |
|---|
| 237 | |
|---|
| 238 | matrix_field_sparse = Extension('sage.matrix.matrix_field_sparse', |
|---|
| 239 | ['sage/matrix/matrix_field_sparse.pyx']) |
|---|
| 240 | |
|---|
| 241 | matrix_rational_dense = Extension('sage.matrix.matrix_rational_dense', |
|---|
| 242 | ['sage/matrix/matrix_rational_dense.pyx'], |
|---|
| 243 | libraries = ['gmp']) |
|---|
| 244 | |
|---|
| 245 | matrix_integer_sparse = Extension('sage.matrix.matrix_integer_sparse', |
|---|
| 246 | ['sage/matrix/matrix_integer_sparse.pyx'], |
|---|
| 247 | libraries = ['gmp']) |
|---|
| 248 | |
|---|
| 249 | matrix_rational_sparse = Extension('sage.matrix.matrix_rational_sparse', |
|---|
| 250 | ['sage/matrix/matrix_rational_sparse.pyx'], |
|---|
| 251 | libraries = ['gmp']) |
|---|
| 252 | |
|---|
| 253 | # TODO -- change to use BLAS at some point. |
|---|
| 254 | matrix_integer_dense = Extension('sage.matrix.matrix_integer_dense', |
|---|
| 255 | ['sage/matrix/matrix_integer_dense.pyx'], |
|---|
| 256 | libraries = ['iml', 'gmp', 'm', BLAS]) # order matters for cygwin!! |
|---|
| 257 | |
|---|
| 258 | matrix_real_double_dense=Extension('sage.matrix.matrix_real_double_dense', |
|---|
| 259 | ['sage/matrix/matrix_real_double_dense.pyx'],libraries=['gsl',BLAS], |
|---|
| 260 | define_macros=[('GSL_DISABLE_DEPRECATED','1')],include_dirs=[SAGE_ROOT+'/local/lib/python2.5/site-packages/numpy/core/include/numpy']) |
|---|
| 261 | |
|---|
| 262 | matrix_complex_double_dense=Extension('sage.matrix.matrix_complex_double_dense', |
|---|
| 263 | ['sage/matrix/matrix_complex_double_dense.pyx'],libraries=['gsl',BLAS], |
|---|
| 264 | define_macros=[('GSL_DISABLE_DEPRECATED','1')],include_dirs=[SAGE_ROOT+'/local/lib/python2.5/site-packages/numpy/core/include/numpy']) |
|---|
| 265 | |
|---|
| 266 | |
|---|
| 267 | solve = Extension('sage.matrix.solve',['sage/matrix/solve.pyx'],libraries = ['gsl',BLAS],define_macros = |
|---|
| 268 | [('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 269 | |
|---|
| 270 | matrix_cyclo_dense = Extension('sage.matrix.matrix_cyclo_dense', |
|---|
| 271 | ['sage/matrix/matrix_cyclo_dense.pyx']) |
|---|
| 272 | |
|---|
| 273 | matrix_rational_sparse = Extension('sage.matrix.matrix_rational_sparse', |
|---|
| 274 | ['sage/matrix/matrix_rational_sparse.pyx'], |
|---|
| 275 | libraries = ['gmp']) |
|---|
| 276 | |
|---|
| 277 | matrix_cyclo_sparse = Extension('sage.matrix.matrix_cyclo_sparse', |
|---|
| 278 | ['sage/matrix/matrix_cyclo_sparse.pyx']) |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | matrix_mpolynomial_dense = Extension('sage.matrix.matrix_mpolynomial_dense', |
|---|
| 282 | ['sage/matrix/matrix_mpolynomial_dense.pyx'], |
|---|
| 283 | libraries = ['gmp', 'm', 'readline', 'singular', 'singcf', 'singfac', 'omalloc', 'givaro', 'gmpxx'], |
|---|
| 284 | language="c++", |
|---|
| 285 | include_dirs=[SAGE_ROOT +'/local/include/singular']) |
|---|
| 286 | |
|---|
| 287 | #matrix_padic_capped_relative_dense = Extension('sage.matrix.padics.matrix_padic_capped_relative_dense', |
|---|
| 288 | # ['sage/matrix/padics/matrix_padic_capped_relative_dense.pyx']) |
|---|
| 289 | |
|---|
| 290 | complex_number = Extension('sage.rings.complex_number', |
|---|
| 291 | ['sage/rings/complex_number.pyx'], |
|---|
| 292 | libraries = ['mpfr', 'gmp']) |
|---|
| 293 | |
|---|
| 294 | free_module_element = Extension('sage.modules.free_module_element', |
|---|
| 295 | ['sage/modules/free_module_element.pyx']) |
|---|
| 296 | |
|---|
| 297 | ################ GSL wrapping ###################### |
|---|
| 298 | gsl_probability=Extension('sage.gsl.probability_distribution',['sage/gsl/probability_distribution.pyx'],libraries=['gsl',BLAS],define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 299 | gsl_integration=Extension('sage.gsl.integration',['sage/gsl/integration.pyx'],define_macros=[('GSL_DISABLE_DEPRECATED','1')], libraries=['gsl',BLAS]) |
|---|
| 300 | |
|---|
| 301 | gsl_ode = Extension('sage.gsl.ode',['sage/gsl/ode.pyx'],libraries=['gsl',BLAS],define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 302 | |
|---|
| 303 | gsl_fft = Extension('sage.gsl.fft', |
|---|
| 304 | ['sage/gsl/fft.pyx'], |
|---|
| 305 | libraries = ['gsl', BLAS],define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 306 | |
|---|
| 307 | gsl_interpolation = Extension('sage.gsl.interpolation', |
|---|
| 308 | ['sage/gsl/interpolation.pyx'], |
|---|
| 309 | libraries = ['gsl', BLAS], |
|---|
| 310 | define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 311 | |
|---|
| 312 | gsl_callback = Extension('sage.gsl.callback', |
|---|
| 313 | ['sage/gsl/callback.pyx'], |
|---|
| 314 | libraries = ['gsl', BLAS] |
|---|
| 315 | ,define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 316 | |
|---|
| 317 | real_double = Extension('sage.rings.real_double', |
|---|
| 318 | ['sage/rings/real_double.pyx'], |
|---|
| 319 | libraries = ['gsl', 'gmp', BLAS],define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 320 | |
|---|
| 321 | complex_double = Extension('sage.rings.complex_double', |
|---|
| 322 | ['sage/rings/complex_double.pyx'], |
|---|
| 323 | libraries = ['gsl', BLAS, 'pari', 'gmp']) |
|---|
| 324 | |
|---|
| 325 | real_double_vector = Extension('sage.modules.real_double_vector',['sage/modules/real_double_vector.pyx'], |
|---|
| 326 | libraries = ['gsl',BLAS,'pari','gmp'],define_macros = [('GSL_DISABLE_DEPRECAED','1')],include_dirs=[SAGE_ROOT+'/local/lib/python2.5/site-packages/numpy/core/include/numpy']) |
|---|
| 327 | |
|---|
| 328 | complex_double_vector = Extension('sage.modules.complex_double_vector',['sage/modules/complex_double_vector.pyx'], |
|---|
| 329 | libraries = ['gsl', BLAS, 'pari', 'gmp'],define_macros=[('GSL_DISABLE_DEPRECATED','1')],include_dirs=[SAGE_ROOT+'/local/lib/python2.5/site-packages/numpy/core/include/numpy']) |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | vector_integer_dense = Extension('sage.modules.vector_integer_dense', |
|---|
| 333 | ['sage/modules/vector_integer_dense.pyx'], |
|---|
| 334 | libraries = ['gmp']) |
|---|
| 335 | |
|---|
| 336 | vector_modn_dense = Extension('sage.modules.vector_modn_dense', |
|---|
| 337 | ['sage/modules/vector_modn_dense.pyx']) |
|---|
| 338 | |
|---|
| 339 | vector_rational_sparse = Extension('sage.modules.vector_rational_sparse', |
|---|
| 340 | ['sage/modules/vector_rational_sparse.pyx'], |
|---|
| 341 | libraries = ['gmp']) |
|---|
| 342 | |
|---|
| 343 | vector_rational_dense = Extension('sage.modules.vector_rational_dense', |
|---|
| 344 | ['sage/modules/vector_rational_dense.pyx'], |
|---|
| 345 | libraries = ['gmp']) |
|---|
| 346 | |
|---|
| 347 | gsl_array = Extension('sage.gsl.gsl_array',['sage/gsl/gsl_array.pyx'], |
|---|
| 348 | libraries=['gsl',BLAS],define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 349 | |
|---|
| 350 | gsl_ode = Extension('sage.gsl.ode',['sage/gsl/ode.pyx'],libraries=['gsl',BLAS], |
|---|
| 351 | define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 352 | |
|---|
| 353 | |
|---|
| 354 | dwt = Extension('sage.gsl.dwt',['sage/gsl/dwt.pyx'], |
|---|
| 355 | libraries=['gsl',BLAS], |
|---|
| 356 | define_macros=[('GSL_DISABLE_DEPRECATED','1')]) |
|---|
| 357 | |
|---|
| 358 | |
|---|
| 359 | sagex_ds = Extension('sage.misc.sagex_ds', ['sage/misc/sagex_ds.pyx']) |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | ##################################################### |
|---|
| 363 | |
|---|
| 364 | ext_modules = [ \ |
|---|
| 365 | free_module_element, |
|---|
| 366 | |
|---|
| 367 | complex_double_vector, |
|---|
| 368 | real_double_vector, |
|---|
| 369 | |
|---|
| 370 | vector_integer_dense, |
|---|
| 371 | vector_modn_dense, |
|---|
| 372 | vector_rational_dense, |
|---|
| 373 | |
|---|
| 374 | #vector_rational_sparse, |
|---|
| 375 | |
|---|
| 376 | pari, |
|---|
| 377 | |
|---|
| 378 | mwrank, |
|---|
| 379 | |
|---|
| 380 | ntl, |
|---|
| 381 | |
|---|
| 382 | matrix, |
|---|
| 383 | |
|---|
| 384 | matrix_misc, |
|---|
| 385 | |
|---|
| 386 | matrix_dense, |
|---|
| 387 | matrix_generic_dense, |
|---|
| 388 | |
|---|
| 389 | matrix_sparse, |
|---|
| 390 | matrix_generic_sparse, |
|---|
| 391 | |
|---|
| 392 | ## matrix_domain_dense, |
|---|
| 393 | ## matrix_domain_sparse, |
|---|
| 394 | |
|---|
| 395 | ## matrix_pid_dense, |
|---|
| 396 | ## matrix_pid_sparse, |
|---|
| 397 | |
|---|
| 398 | ## matrix_field_dense, |
|---|
| 399 | ## matrix_field_sparse, |
|---|
| 400 | |
|---|
| 401 | matrix_integer_dense, |
|---|
| 402 | matrix_rational_dense, |
|---|
| 403 | matrix_rational_sparse, |
|---|
| 404 | matrix_integer_2x2, |
|---|
| 405 | matrix_integer_sparse, |
|---|
| 406 | matrix_real_double_dense, |
|---|
| 407 | matrix_complex_double_dense, |
|---|
| 408 | # matrix_padic_capped_relative_dense, |
|---|
| 409 | solve, |
|---|
| 410 | linbox, |
|---|
| 411 | matrix_modn_dense, |
|---|
| 412 | matrix_modn_sparse, |
|---|
| 413 | matrix_mod2_dense, |
|---|
| 414 | matrix_mpolynomial_dense, \ |
|---|
| 415 | |
|---|
| 416 | givaro_gfq, \ |
|---|
| 417 | |
|---|
| 418 | libsingular, \ |
|---|
| 419 | |
|---|
| 420 | ## matrix_rational_sparse, |
|---|
| 421 | |
|---|
| 422 | ## matrix_cyclo_dense, |
|---|
| 423 | ## matrix_cyclo_sparse, |
|---|
| 424 | |
|---|
| 425 | |
|---|
| 426 | dwt, |
|---|
| 427 | |
|---|
| 428 | gsl_array, |
|---|
| 429 | gsl_ode, |
|---|
| 430 | gsl_fft, |
|---|
| 431 | gsl_interpolation, |
|---|
| 432 | gsl_callback, |
|---|
| 433 | gsl_probability, |
|---|
| 434 | gsl_integration, |
|---|
| 435 | real_double, |
|---|
| 436 | complex_double, |
|---|
| 437 | qd, |
|---|
| 438 | |
|---|
| 439 | complex_number, |
|---|
| 440 | |
|---|
| 441 | sagex_ds, |
|---|
| 442 | |
|---|
| 443 | Extension('sage.media.channels', |
|---|
| 444 | sources = ['sage/media/channels.pyx']), \ |
|---|
| 445 | |
|---|
| 446 | Extension('sage.ext.sig', |
|---|
| 447 | sources = ['sage/ext/sig.pyx']), \ |
|---|
| 448 | |
|---|
| 449 | Extension('sage.ext.arith', |
|---|
| 450 | sources = ['sage/ext/arith.pyx']), \ |
|---|
| 451 | |
|---|
| 452 | Extension('sage.ext.arith_gmp', |
|---|
| 453 | sources = ['sage/ext/arith_gmp.pyx'], |
|---|
| 454 | libraries=['gmp']), \ |
|---|
| 455 | |
|---|
| 456 | Extension('sage.ext.multi_modular', |
|---|
| 457 | sources = ['sage/ext/multi_modular.pyx'], |
|---|
| 458 | libraries=['gmp']), \ |
|---|
| 459 | |
|---|
| 460 | Extension('sage.structure.coerce', |
|---|
| 461 | sources = ['sage/structure/coerce.pyx']), \ |
|---|
| 462 | |
|---|
| 463 | Extension('sage.modular.congroup_pyx', |
|---|
| 464 | sources = ['sage/modular/congroup_pyx.pyx', \ |
|---|
| 465 | 'sage/ext/arith.pyx']), \ |
|---|
| 466 | |
|---|
| 467 | Extension('sage.structure.element', |
|---|
| 468 | sources = ['sage/structure/element.pyx']), \ |
|---|
| 469 | |
|---|
| 470 | Extension('sage.categories.morphism', |
|---|
| 471 | sources = ['sage/categories/morphism.pyx']), \ |
|---|
| 472 | |
|---|
| 473 | Extension('sage.categories.functor', |
|---|
| 474 | sources = ['sage/categories/functor.pyx']), \ |
|---|
| 475 | |
|---|
| 476 | Extension('sage.categories.action', |
|---|
| 477 | sources = ['sage/categories/action.pyx']), \ |
|---|
| 478 | |
|---|
| 479 | Extension('sage.modules.module', |
|---|
| 480 | sources = ['sage/modules/module.pyx']), \ |
|---|
| 481 | |
|---|
| 482 | Extension('sage.rings.ring', |
|---|
| 483 | sources = ['sage/rings/ring.pyx']), \ |
|---|
| 484 | |
|---|
| 485 | Extension('sage.rings.polynomial.multi_polynomial', |
|---|
| 486 | sources = ['sage/rings/polynomial/multi_polynomial.pyx'] |
|---|
| 487 | ), \ |
|---|
| 488 | |
|---|
| 489 | Extension('sage.rings.polynomial.multi_polynomial_ring_generic', |
|---|
| 490 | sources = ['sage/rings/polynomial/multi_polynomial_ring_generic.pyx'] |
|---|
| 491 | ), \ |
|---|
| 492 | |
|---|
| 493 | Extension('sage.rings.polynomial.multi_polynomial_libsingular', |
|---|
| 494 | sources = ['sage/rings/polynomial/multi_polynomial_libsingular.pyx'], |
|---|
| 495 | libraries = ['gmp', 'm', 'readline', 'singular', 'singcf', 'singfac', 'omalloc', 'givaro', 'gmpxx'], |
|---|
| 496 | language="c++", |
|---|
| 497 | include_dirs=[SAGE_ROOT +'/local/include/singular']), \ |
|---|
| 498 | |
|---|
| 499 | Extension('sage.rings.polynomial.multi_polynomial_ideal_libsingular', |
|---|
| 500 | sources = ['sage/rings/polynomial/multi_polynomial_ideal_libsingular.pyx'], |
|---|
| 501 | libraries = ['gmp', 'm', 'readline', 'singular', 'singcf', 'singfac', 'omalloc', 'givaro', 'gmpxx'], |
|---|
| 502 | language="c++", |
|---|
| 503 | include_dirs=[SAGE_ROOT +'/local/include/singular']), \ |
|---|
| 504 | |
|---|
| 505 | Extension('sage.groups.group', |
|---|
| 506 | sources = ['sage/groups/group.pyx']), \ |
|---|
| 507 | |
|---|
| 508 | Extension('sage.structure.sage_object', |
|---|
| 509 | sources = ['sage/structure/sage_object.pyx'], libraries=['ntl']), \ |
|---|
| 510 | |
|---|
| 511 | Extension('sage.structure.parent', |
|---|
| 512 | sources = ['sage/structure/parent.pyx']), \ |
|---|
| 513 | |
|---|
| 514 | Extension('sage.structure.parent_base', |
|---|
| 515 | sources = ['sage/structure/parent_base.pyx']), \ |
|---|
| 516 | |
|---|
| 517 | Extension('sage.structure.parent_gens', |
|---|
| 518 | sources = ['sage/structure/parent_gens.pyx']), \ |
|---|
| 519 | |
|---|
| 520 | Extension('sage.ext.interactive_constructors_c', |
|---|
| 521 | sources = ['sage/ext/interactive_constructors_c.pyx']), \ |
|---|
| 522 | |
|---|
| 523 | Extension('sage.misc.cython_c', |
|---|
| 524 | sources = ['sage/misc/cython_c.pyx']), \ |
|---|
| 525 | |
|---|
| 526 | Extension('sage.rings.real_mpfr', |
|---|
| 527 | sources = ['sage/rings/real_mpfr.pyx', 'sage/rings/ring.pyx'], |
|---|
| 528 | libraries = ['mpfr', 'pari', 'gmp']), \ |
|---|
| 529 | |
|---|
| 530 | Extension('sage.rings.real_mpfi', |
|---|
| 531 | sources = ['sage/rings/real_mpfi.pyx'], |
|---|
| 532 | libraries = ['mpfi', 'mpfr', 'gmp']), \ |
|---|
| 533 | |
|---|
| 534 | Extension('sage.rings.integer', |
|---|
| 535 | sources = ['sage/ext/arith.pyx', 'sage/rings/integer.pyx', \ |
|---|
| 536 | 'sage/ext/mpn_pylong.c', 'sage/ext/mpz_pylong.c'], |
|---|
| 537 | libraries=['ntl', 'gmp']), \ |
|---|
| 538 | |
|---|
| 539 | Extension('sage.rings.integer_ring', |
|---|
| 540 | sources = ['sage/rings/integer_ring.pyx'], |
|---|
| 541 | libraries=['ntl', 'gmp']), \ |
|---|
| 542 | |
|---|
| 543 | Extension('sage.rings.padics.pow_computer', |
|---|
| 544 | sources = ['sage/rings/padics/pow_computer.pyx'], |
|---|
| 545 | libraries=['gmp']), |
|---|
| 546 | Extension('sage.rings.padics.local_generic_element', |
|---|
| 547 | sources = ['sage/rings/padics/local_generic_element.pyx']), |
|---|
| 548 | Extension('sage.rings.padics.padic_generic_element', |
|---|
| 549 | sources = ['sage/rings/padics/padic_generic_element.pyx']), |
|---|
| 550 | Extension('sage.rings.padics.padic_base_generic_element', |
|---|
| 551 | sources = ['sage/rings/padics/padic_base_generic_element.pyx']), |
|---|
| 552 | Extension('sage.rings.padics.padic_fixed_mod_element', |
|---|
| 553 | sources = ['sage/rings/padics/padic_fixed_mod_element.pyx', \ |
|---|
| 554 | 'sage/rings/padics/padic_generic_element.c'], |
|---|
| 555 | libraries=['gmp']), |
|---|
| 556 | Extension('sage.rings.padics.padic_capped_absolute_element', |
|---|
| 557 | sources = ['sage/rings/padics/padic_capped_absolute_element.pyx', \ |
|---|
| 558 | 'sage/rings/padics/padic_generic_element.c'], |
|---|
| 559 | libraries=['gmp']), |
|---|
| 560 | Extension('sage.rings.padics.padic_capped_relative_element', |
|---|
| 561 | sources = ['sage/rings/padics/padic_capped_relative_element.pyx', \ |
|---|
| 562 | 'sage/rings/padics/padic_generic_element.c'], |
|---|
| 563 | libraries=['gmp']), |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | Extension('sage.rings.memory', \ |
|---|
| 567 | sources = ['sage/rings/memory.pyx'], \ |
|---|
| 568 | libraries=['gmp','stdc++']), \ |
|---|
| 569 | |
|---|
| 570 | Extension('sage.rings.bernoulli_mod_p', |
|---|
| 571 | sources = ['sage/rings/bernoulli_mod_p.pyx', 'sage/ext/arith.pyx'], |
|---|
| 572 | libraries=['ntl'], |
|---|
| 573 | include_dirs=['sage/libs/ntl/']), \ |
|---|
| 574 | |
|---|
| 575 | Extension('sage.schemes.hyperelliptic_curves.frobenius', |
|---|
| 576 | sources = ['sage/schemes/hyperelliptic_curves/frobenius.pyx', |
|---|
| 577 | 'sage/schemes/hyperelliptic_curves/frobenius_cpp.cpp'], |
|---|
| 578 | libraries = ['ntl', 'stdc++', 'gmp'], |
|---|
| 579 | language = 'c++', |
|---|
| 580 | include_dirs=['sage/libs/ntl/']), \ |
|---|
| 581 | |
|---|
| 582 | Extension('sage.rings.polynomial.polynomial_compiled', |
|---|
| 583 | sources = ['sage/rings/polynomial/polynomial_compiled.pyx']), \ |
|---|
| 584 | |
|---|
| 585 | Extension('sage.rings.polynomial.polynomial_element', |
|---|
| 586 | sources = ['sage/rings/polynomial/polynomial_element.pyx']), \ |
|---|
| 587 | |
|---|
| 588 | Extension('sage.rings.power_series_ring_element', |
|---|
| 589 | sources = ['sage/rings/power_series_ring_element.pyx']), \ |
|---|
| 590 | |
|---|
| 591 | Extension('sage.rings.power_series_poly', |
|---|
| 592 | sources = ['sage/rings/power_series_poly.pyx']), \ |
|---|
| 593 | |
|---|
| 594 | Extension('sage.rings.power_series_mpoly', |
|---|
| 595 | sources = ['sage/rings/power_series_mpoly.pyx']), \ |
|---|
| 596 | |
|---|
| 597 | Extension('sage.rings.laurent_series_ring_element', |
|---|
| 598 | sources = ['sage/rings/laurent_series_ring_element.pyx']), \ |
|---|
| 599 | |
|---|
| 600 | Extension('sage.rings.rational', |
|---|
| 601 | sources = ['sage/rings/rational.pyx', |
|---|
| 602 | 'sage/ext/arith.pyx', \ |
|---|
| 603 | 'sage/rings/integer.pyx', \ |
|---|
| 604 | 'sage/ext/mpn_pylong.c', 'sage/ext/mpz_pylong.c'], |
|---|
| 605 | libraries=['ntl', 'gmp']), \ |
|---|
| 606 | |
|---|
| 607 | Extension('sage.rings.sparse_poly', |
|---|
| 608 | sources = ['sage/rings/sparse_poly.pyx'], |
|---|
| 609 | libraries=['gmp']), \ |
|---|
| 610 | |
|---|
| 611 | Extension('sage.rings.polynomial.polydict', |
|---|
| 612 | sources = ['sage/rings/polynomial/polydict.pyx']), \ |
|---|
| 613 | |
|---|
| 614 | Extension('sage.rings.number_field.number_field_element', |
|---|
| 615 | sources = ['sage/rings/number_field/number_field_element.pyx'], |
|---|
| 616 | libraries=['ntl','gmp'], |
|---|
| 617 | language = 'c++'), \ |
|---|
| 618 | |
|---|
| 619 | Extension('sage.misc.search', |
|---|
| 620 | ['sage/misc/search.pyx']), \ |
|---|
| 621 | |
|---|
| 622 | Extension('sage.misc.reset', |
|---|
| 623 | ['sage/misc/reset.pyx']), \ |
|---|
| 624 | |
|---|
| 625 | Extension('sage.calculus.var', |
|---|
| 626 | ['sage/calculus/var.pyx']), \ |
|---|
| 627 | |
|---|
| 628 | Extension('sage.modular.modsym.heilbronn', |
|---|
| 629 | ['sage/modular/modsym/heilbronn.pyx', |
|---|
| 630 | 'sage/modular/modsym/p1list.pyx', |
|---|
| 631 | 'sage/ext/arith.pyx'], |
|---|
| 632 | libraries = ['gmp', 'm']), \ |
|---|
| 633 | |
|---|
| 634 | Extension('sage.modular.modsym.p1list', |
|---|
| 635 | ['sage/modular/modsym/p1list.pyx', |
|---|
| 636 | 'sage/ext/arith.pyx'], |
|---|
| 637 | libraries = ['gmp']), \ |
|---|
| 638 | |
|---|
| 639 | Extension('sage.structure.mutability', |
|---|
| 640 | ['sage/structure/mutability.pyx'] |
|---|
| 641 | ), \ |
|---|
| 642 | |
|---|
| 643 | Extension('sage.matrix.matrix0', |
|---|
| 644 | ['sage/matrix/matrix0.pyx'] |
|---|
| 645 | ), \ |
|---|
| 646 | |
|---|
| 647 | Extension('sage.matrix.matrix1', |
|---|
| 648 | ['sage/matrix/matrix1.pyx'] |
|---|
| 649 | ), \ |
|---|
| 650 | |
|---|
| 651 | Extension('sage.matrix.matrix2', |
|---|
| 652 | ['sage/matrix/matrix2.pyx'] |
|---|
| 653 | ), \ |
|---|
| 654 | |
|---|
| 655 | Extension('sage.matrix.matrix', |
|---|
| 656 | ['sage/matrix/matrix.pyx'] |
|---|
| 657 | ), \ |
|---|
| 658 | |
|---|
| 659 | Extension('sage.matrix.matrix_window', |
|---|
| 660 | ['sage/matrix/matrix_window.pyx'] |
|---|
| 661 | ), \ |
|---|
| 662 | |
|---|
| 663 | Extension('sage.matrix.matrix_window_modn_dense', |
|---|
| 664 | ['sage/matrix/matrix_window_modn_dense.pyx'] |
|---|
| 665 | ), \ |
|---|
| 666 | |
|---|
| 667 | Extension('sage.matrix.strassen', |
|---|
| 668 | ['sage/matrix/strassen.pyx'] |
|---|
| 669 | ), \ |
|---|
| 670 | |
|---|
| 671 | Extension('sage.rings.integer_mod', |
|---|
| 672 | ['sage/rings/integer_mod.pyx'], |
|---|
| 673 | libraries = ['gmp'] |
|---|
| 674 | ), \ |
|---|
| 675 | |
|---|
| 676 | Extension('sage.combinat.expnums', |
|---|
| 677 | ['sage/combinat/expnums.pyx'], |
|---|
| 678 | libraries = ['gmp'] |
|---|
| 679 | ), \ |
|---|
| 680 | |
|---|
| 681 | Extension('sage.combinat.partitions', |
|---|
| 682 | ['sage/combinat/partitions.pyx', |
|---|
| 683 | 'sage/combinat/partitions_c.cc'], |
|---|
| 684 | libraries = ['gmp', 'mpfr'], |
|---|
| 685 | language='c++' |
|---|
| 686 | ), \ |
|---|
| 687 | |
|---|
| 688 | Extension('sage.graphs.graph_fast', |
|---|
| 689 | ['sage/graphs/graph_fast.pyx'], |
|---|
| 690 | libraries = ['gmp'] |
|---|
| 691 | ), \ |
|---|
| 692 | |
|---|
| 693 | Extension('sage.graphs.graph_isom', |
|---|
| 694 | ['sage/graphs/graph_isom.pyx'] |
|---|
| 695 | ), \ |
|---|
| 696 | |
|---|
| 697 | Extension('sage.graphs.bruhat_sn', |
|---|
| 698 | ['sage/graphs/bruhat_sn.pyx'] |
|---|
| 699 | ), \ |
|---|
| 700 | |
|---|
| 701 | |
|---|
| 702 | Extension('sage.plot.plot3d.base', |
|---|
| 703 | ['sage/plot/plot3d/base.pyx'] |
|---|
| 704 | ), \ |
|---|
| 705 | Extension('sage.plot.plot3d.transform', |
|---|
| 706 | ['sage/plot/plot3d/transform.pyx'] |
|---|
| 707 | ), \ |
|---|
| 708 | Extension('sage.plot.plot3d.index_face_set', |
|---|
| 709 | ['sage/plot/plot3d/index_face_set.pyx'] |
|---|
| 710 | ), \ |
|---|
| 711 | Extension('sage.plot.plot3d.parametric_surface', |
|---|
| 712 | ['sage/plot/plot3d/parametric_surface.pyx'] |
|---|
| 713 | ), \ |
|---|
| 714 | Extension('sage.plot.plot3d.shapes', |
|---|
| 715 | ['sage/plot/plot3d/shapes.pyx'] |
|---|
| 716 | ), \ |
|---|
| 717 | |
|---|
| 718 | |
|---|
| 719 | ] |
|---|
| 720 | |
|---|
| 721 | |
|---|
| 722 | #mpc = Extension('sage.rings.mpc', |
|---|
| 723 | # sources = ['sage/rings/mpc.pyx', 'sage/rings/ring.pyx'], |
|---|
| 724 | # libraries = ['mpc', 'mpfr', 'gmp']) |
|---|
| 725 | |
|---|
| 726 | |
|---|
| 727 | extra_compile_args = [ ] |
|---|
| 728 | |
|---|
| 729 | if NO_WARN and distutils.sysconfig.get_config_var('CC').startswith("gcc"): |
|---|
| 730 | extra_compile_args = ['-w'] |
|---|
| 731 | |
|---|
| 732 | if DEVEL: |
|---|
| 733 | extra_compile_args.append('-ggdb') |
|---|
| 734 | ext_modules.append(hanke) |
|---|
| 735 | #ext_modules.append(mpc) |
|---|
| 736 | |
|---|
| 737 | for m in ext_modules: |
|---|
| 738 | m.libraries = ['csage'] + m.libraries + ['stdc++', 'ntl'] |
|---|
| 739 | m.library_dirs += ['%s/lib' % SAGE_LOCAL] |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | ###################################################################### |
|---|
| 743 | # CODE for generating C/C++ code from Cython and doing dependency |
|---|
| 744 | # checking, etc. In theory distutils would run Cython, but I don't |
|---|
| 745 | # trust it at all, and it won't have the more sophisticated dependency |
|---|
| 746 | # checking that we need. |
|---|
| 747 | ###################################################################### |
|---|
| 748 | |
|---|
| 749 | def check_dependencies( filename, outfile ): |
|---|
| 750 | """ |
|---|
| 751 | INPUT: |
|---|
| 752 | filename -- The name of a .pyx, .pxd, or .pxi to check dependencies in the SAGE source. |
|---|
| 753 | outfile -- The output file for which we are determining out-of-date-ness |
|---|
| 754 | |
|---|
| 755 | OUTPUT: |
|---|
| 756 | bool -- whether or not outfile must be regenerated. |
|---|
| 757 | """ |
|---|
| 758 | |
|---|
| 759 | if is_older(filename, outfile): |
|---|
| 760 | print "\nBuilding %s because it depends on %s."%(outfile, filename) |
|---|
| 761 | return True |
|---|
| 762 | |
|---|
| 763 | # Now we look inside the file to see what it cimports or include. |
|---|
| 764 | # If any of these files are newer than outfile, we rebuild |
|---|
| 765 | # outfile. |
|---|
| 766 | S = open(filename).readlines() |
|---|
| 767 | # Take the lines that begin with cimport (it won't hurt to |
|---|
| 768 | # have extra lines) |
|---|
| 769 | C = [x.strip() for x in S if 'cimport' in x] |
|---|
| 770 | for A in C: |
|---|
| 771 | # Deduce the full module name. |
|---|
| 772 | # The only allowed forms of cimport/include are: |
|---|
| 773 | # cimport a.b.c.d |
|---|
| 774 | # from a.b.c.d cimport e |
|---|
| 775 | # Also, the cimport can be both have no dots (current directory) or absolute. |
|---|
| 776 | # The multiple imports with parens, e.g., |
|---|
| 777 | # import (a.b.c.d, e.f.g) |
|---|
| 778 | # of Python are not allowed in Cython. |
|---|
| 779 | # In both cases, the module name is the second word if we split on whitespace. |
|---|
| 780 | try: |
|---|
| 781 | A = A.strip().split()[1] |
|---|
| 782 | except IndexError: |
|---|
| 783 | # illegal statement or not really a cimport (e.g., cimport could |
|---|
| 784 | # be in a comment or something) |
|---|
| 785 | continue |
|---|
| 786 | |
|---|
| 787 | if A[0] == '"': |
|---|
| 788 | A = A[1:-1] |
|---|
| 789 | |
|---|
| 790 | # Now convert A to a filename, e.g., a/b/c/d |
|---|
| 791 | # |
|---|
| 792 | if '.' in A: |
|---|
| 793 | # It is an absolute cimport. |
|---|
| 794 | A = A.replace('.','/') + '.pxd' |
|---|
| 795 | else: |
|---|
| 796 | # It is a relative cimport. |
|---|
| 797 | A = os.path.split(filename)[0] + '/' + A + '.pxd' |
|---|
| 798 | # Check to see if a/b/c/d.pxd exists and is newer than filename. |
|---|
| 799 | # If so, we have to regenerate outfile. If not, we're safe. |
|---|
| 800 | if os.path.exists(A) and check_dependencies(A, outfile): |
|---|
| 801 | return True # yep we must rebuild |
|---|
| 802 | |
|---|
| 803 | # OK, next we move on to include pxi files. |
|---|
| 804 | # If they change, we likewise must rebuild the pyx file. |
|---|
| 805 | I = [x for x in S if 'include' in x] |
|---|
| 806 | # The syntax for include is like this: |
|---|
| 807 | # include "../a/b/c.pxi" |
|---|
| 808 | # I.e., it's a quoted *relative* path to a pxi file. |
|---|
| 809 | for A in I: |
|---|
| 810 | try: |
|---|
| 811 | A = A.strip().split()[1] |
|---|
| 812 | except IndexError: |
|---|
| 813 | # Illegal include statement or not really an include |
|---|
| 814 | # (e.g., include could easily be in a comment or |
|---|
| 815 | # something). No reason to crash setup.py! |
|---|
| 816 | continue |
|---|
| 817 | # Strip the quotes from either side of the pxi filename. |
|---|
| 818 | A = A.strip('"').strip("'") |
|---|
| 819 | # Now take filename (the input argument to this function) |
|---|
| 820 | # and strip off the last part of the path and stick |
|---|
| 821 | # A onto it to get the filename of the pxi file relative |
|---|
| 822 | # where setup.py is being run. |
|---|
| 823 | R = A # save the relative filename in case it is absolute |
|---|
| 824 | A = os.path.split(filename)[0] + '/' + A |
|---|
| 825 | if not os.path.exists(A): |
|---|
| 826 | # A is an "absolute" path -- that is, absolute to the base of the sage tree |
|---|
| 827 | A = R # restore |
|---|
| 828 | # Finally, check to see if filename is older than A |
|---|
| 829 | if os.path.exists(A) and check_dependencies(A, outfile): |
|---|
| 830 | return True |
|---|
| 831 | |
|---|
| 832 | |
|---|
| 833 | def need_to_cython(filename, outfile): |
|---|
| 834 | """ |
|---|
| 835 | INPUT: |
|---|
| 836 | filename -- The name of a cython file in the SAGE source tree. |
|---|
| 837 | outfile -- The name of the corresponding c or cpp file in the build directory. |
|---|
| 838 | |
|---|
| 839 | OUTPUT: |
|---|
| 840 | bool -- whether or not outfile must be regenerated. |
|---|
| 841 | """ |
|---|
| 842 | |
|---|
| 843 | base = os.path.splitext(filename)[0] |
|---|
| 844 | pxd = base+'.pxd' |
|---|
| 845 | |
|---|
| 846 | if check_dependencies(filename, outfile): |
|---|
| 847 | return True |
|---|
| 848 | elif os.path.exists(pxd) and check_dependencies(pxd, outfile): |
|---|
| 849 | return True |
|---|
| 850 | else: |
|---|
| 851 | return False |
|---|
| 852 | |
|---|
| 853 | def process_cython_file(f, m): |
|---|
| 854 | """ |
|---|
| 855 | INPUT: |
|---|
| 856 | f -- file name |
|---|
| 857 | m -- Extension module description (i.e., object of type Extension). |
|---|
| 858 | """ |
|---|
| 859 | # This is a cython file, so process accordingly. |
|---|
| 860 | pyx_inst_file = '%s/%s'%(SITE_PACKAGES, f) |
|---|
| 861 | if is_older(f, pyx_inst_file): |
|---|
| 862 | print "%s --> %s"%(f, pyx_inst_file) |
|---|
| 863 | os.system('cp %s %s 2>/dev/null'%(f, pyx_inst_file)) |
|---|
| 864 | outfile = f[:-4] + ".c" |
|---|
| 865 | if m.language == 'c++': |
|---|
| 866 | outfile += 'pp' |
|---|
| 867 | |
|---|
| 868 | if need_to_cython(f, outfile): |
|---|
| 869 | # Insert the -o parameter to specify the output file (particularly for c++) |
|---|
| 870 | cmd = "cython --embed-positions -I%s -o %s %s"%(os.getcwd(), outfile, f) |
|---|
| 871 | print cmd |
|---|
| 872 | ret = os.system(cmd) |
|---|
| 873 | if ret != 0: |
|---|
| 874 | print "sage: Error running cython." |
|---|
| 875 | sys.exit(1) |
|---|
| 876 | return [outfile] |
|---|
| 877 | |
|---|
| 878 | |
|---|
| 879 | def cython(ext_modules): |
|---|
| 880 | for m in ext_modules: |
|---|
| 881 | m.extra_compile_args += extra_compile_args |
|---|
| 882 | # m.extra_link_args += extra_link_args |
|---|
| 883 | new_sources = [] |
|---|
| 884 | for i in range(len(m.sources)): |
|---|
| 885 | f = m.sources[i] |
|---|
| 886 | # s = open(f).read() |
|---|
| 887 | if f[-4:] == ".pyx": |
|---|
| 888 | new_sources += process_cython_file(f, m) |
|---|
| 889 | else: |
|---|
| 890 | new_sources.append(f) |
|---|
| 891 | m.sources = new_sources |
|---|
| 892 | |
|---|
| 893 | |
|---|
| 894 | |
|---|
| 895 | if not sdist: |
|---|
| 896 | cython(ext_modules) |
|---|
| 897 | |
|---|
| 898 | setup(name = 'sage', |
|---|
| 899 | |
|---|
| 900 | version = SAGE_VERSION, |
|---|
| 901 | |
|---|
| 902 | description = 'SAGE: System for Algebra and Geometry Experimentation', |
|---|
| 903 | |
|---|
| 904 | license = 'GNU Public License (GPL)', |
|---|
| 905 | |
|---|
| 906 | author = 'William Stein', |
|---|
| 907 | |
|---|
| 908 | author_email= 'wstein@gmail.com', |
|---|
| 909 | |
|---|
| 910 | url = 'http://www.sagemath.org', |
|---|
| 911 | |
|---|
| 912 | packages = ['sage', |
|---|
| 913 | |
|---|
| 914 | 'sage.algebras', |
|---|
| 915 | |
|---|
| 916 | 'sage.catalogue', |
|---|
| 917 | |
|---|
| 918 | 'sage.categories', |
|---|
| 919 | |
|---|
| 920 | 'sage.coding', |
|---|
| 921 | |
|---|
| 922 | 'sage.combinat', |
|---|
| 923 | |
|---|
| 924 | 'sage.crypto', |
|---|
| 925 | |
|---|
| 926 | 'sage.databases', |
|---|
| 927 | |
|---|
| 928 | 'sage.ext', |
|---|
| 929 | |
|---|
| 930 | 'sage.calculus', |
|---|
| 931 | |
|---|
| 932 | 'sage.functions', |
|---|
| 933 | |
|---|
| 934 | 'sage.geometry', |
|---|
| 935 | |
|---|
| 936 | 'sage.games', |
|---|
| 937 | |
|---|
| 938 | 'sage.gsl', |
|---|
| 939 | |
|---|
| 940 | 'sage.graphs', |
|---|
| 941 | |
|---|
| 942 | 'sage.groups', |
|---|
| 943 | 'sage.groups.abelian_gps', |
|---|
| 944 | 'sage.groups.matrix_gps', |
|---|
| 945 | 'sage.groups.perm_gps', |
|---|
| 946 | |
|---|
| 947 | 'sage.interfaces', |
|---|
| 948 | |
|---|
| 949 | 'sage.lfunctions', |
|---|
| 950 | |
|---|
| 951 | 'sage.libs', |
|---|
| 952 | 'sage.libs.hanke', |
|---|
| 953 | 'sage.libs.linbox', |
|---|
| 954 | 'sage.libs.mwrank', |
|---|
| 955 | 'sage.libs.ntl', |
|---|
| 956 | 'sage.libs.pari', |
|---|
| 957 | 'sage.libs.singular', |
|---|
| 958 | |
|---|
| 959 | 'sage.matrix', |
|---|
| 960 | # 'sage.matrix.padics', |
|---|
| 961 | 'sage.media', |
|---|
| 962 | 'sage.misc', |
|---|
| 963 | |
|---|
| 964 | 'sage.modules', |
|---|
| 965 | |
|---|
| 966 | 'sage.modular', |
|---|
| 967 | 'sage.modular.abvar', |
|---|
| 968 | 'sage.modular.hecke', |
|---|
| 969 | 'sage.modular.modform', |
|---|
| 970 | 'sage.modular.modsym', |
|---|
| 971 | 'sage.modular.ssmod', |
|---|
| 972 | |
|---|
| 973 | 'sage.monoids', |
|---|
| 974 | |
|---|
| 975 | 'sage.plot', |
|---|
| 976 | 'sage.plot.mpl3d', |
|---|
| 977 | 'sage.plot.plot3d', |
|---|
| 978 | |
|---|
| 979 | 'sage.probability', |
|---|
| 980 | |
|---|
| 981 | 'sage.quadratic_forms', |
|---|
| 982 | 'sage.quadratic_forms.genera', |
|---|
| 983 | |
|---|
| 984 | 'sage.rings', |
|---|
| 985 | 'sage.rings.number_field', |
|---|
| 986 | 'sage.rings.padics', |
|---|
| 987 | 'sage.rings.polynomial', |
|---|
| 988 | 'sage.rings.polynomial.padics', |
|---|
| 989 | |
|---|
| 990 | 'sage.tests', |
|---|
| 991 | |
|---|
| 992 | 'sage.sets', |
|---|
| 993 | |
|---|
| 994 | 'sage.schemes', |
|---|
| 995 | 'sage.schemes.generic', |
|---|
| 996 | 'sage.schemes.jacobians', |
|---|
| 997 | 'sage.schemes.plane_curves', |
|---|
| 998 | 'sage.schemes.plane_quartics', |
|---|
| 999 | 'sage.schemes.elliptic_curves', |
|---|
| 1000 | 'sage.schemes.hyperelliptic_curves', |
|---|
| 1001 | |
|---|
| 1002 | 'sage.server', |
|---|
| 1003 | 'sage.server.server1', |
|---|
| 1004 | 'sage.server.notebook', |
|---|
| 1005 | 'sage.server.notebook.compress', |
|---|
| 1006 | 'sage.server.wiki', |
|---|
| 1007 | 'sage.server.trac', |
|---|
| 1008 | |
|---|
| 1009 | 'sage.structure', |
|---|
| 1010 | |
|---|
| 1011 | 'sage.dsage', |
|---|
| 1012 | 'sage.dsage.tests', |
|---|
| 1013 | 'sage.dsage.database', |
|---|
| 1014 | 'sage.dsage.database.tests', |
|---|
| 1015 | 'sage.dsage.server', |
|---|
| 1016 | 'sage.dsage.server.tests', |
|---|
| 1017 | 'sage.dsage.interface', |
|---|
| 1018 | 'sage.dsage.interface.tests', |
|---|
| 1019 | 'sage.dsage.errors', |
|---|
| 1020 | 'sage.dsage.twisted', |
|---|
| 1021 | 'sage.dsage.twisted.tests', |
|---|
| 1022 | 'sage.dsage.dist_functions', |
|---|
| 1023 | 'sage.dsage.dist_functions.tests', |
|---|
| 1024 | 'sage.dsage.misc', |
|---|
| 1025 | 'sage.dsage.misc.tests', |
|---|
| 1026 | 'sage.dsage.scripts' |
|---|
| 1027 | ], |
|---|
| 1028 | |
|---|
| 1029 | scripts = ['sage/dsage/scripts/dsage_server.py', |
|---|
| 1030 | 'sage/dsage/scripts/dsage_worker.py', |
|---|
| 1031 | 'sage/dsage/scripts/dsage_setup.py' |
|---|
| 1032 | ], |
|---|
| 1033 | |
|---|
| 1034 | ext_modules = ext_modules, |
|---|
| 1035 | include_dirs = include_dirs) |
|---|
| 1036 | |
|---|
| 1037 | |
|---|
| 1038 | |
|---|