source: setup.py @ 6109:55d3e5a200fa

Revision 6109:55d3e5a200fa, 36.0 KB checked in by William Stein <wstein@…>, 6 years ago (diff)

merge

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