[Bio] / Numeric / setup-mac.py Repository:
ViewVC logotype

Annotation of /Numeric/setup-mac.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (view) (download) (as text)

1 : efrank 1.1 #!/usr/bin/env python
2 :     # To use:
3 :     # python setup.py install
4 :     # or:
5 :     # python setup.py bdist_rpm (you'll end up with RPMs in dist)
6 :     #
7 :     import os, sys, string, re
8 :     from glob import glob
9 :     if not hasattr(sys, 'version_info') or sys.version_info < (2,0,0,'alpha',0):
10 :     raise SystemExit, "Python 2.0 or later required to build Numeric."
11 :     import distutils
12 :     from distutils.core import setup, Extension
13 :    
14 :     # Get all version numbers
15 :     execfile(os.path.join('Lib','numeric_version.py'))
16 :     numeric_version = version
17 :    
18 :     execfile(os.path.join('Packages', 'MA', 'Lib', 'MA_version.py'))
19 :     MA_version = version
20 :    
21 :     headers = glob (os.path.join ("Include","Numeric","*.h"))
22 :     extra_compile_args = [] # You could put "-O4" etc. here.
23 :     mathlibs = ['m']
24 :     define_macros = [('HAVE_INVERSE_HYPERBOLIC',None)]
25 :     undef_macros = []
26 :     # You might need to add a case here for your system
27 :     if sys.platform in ['win32']:
28 :     mathlibs = []
29 :     define_macros = []
30 :     undef_macros = ['HAVE_INVERSE_HYPERBOLIC']
31 :     elif sys.platform in ['mac', 'beos5']:
32 :     mathlibs = []
33 :    
34 :     # delete all but the first one in this list if using your own LAPACK/BLAS
35 :     sourcelist = [os.path.join('Src', 'lapack_litemodule.c'),
36 :     #os.path.join('Src', 'blas_lite.c'),
37 :     #os.path.join('Src', 'f2c_lite.c'),
38 :     #os.path.join('Src', 'zlapack_lite.c'),
39 :     #os.path.join('Src', 'dlapack_lite.c')
40 :     ]
41 :     # set these to use your own BLAS;
42 :    
43 :     library_dirs_list = []
44 :     libraries_list = []
45 :    
46 :     # set to true (1), if you also want BLAS optimized matrixmultiply/dot/innerproduct
47 :     use_dotblas = 1
48 :     include_dirs = ['/usr/include/atlas']
49 :     # You may need to set this to find cblas.h
50 :     # e.g. on UNIX using ATLAS this should be ['/usr/include/atlas']
51 :     extra_link_args = []
52 :    
53 :     # for MacOS X to link against vecLib if present
54 :     VECLIB_PATH = '/System/Library/Frameworks/vecLib.framework'
55 :     if os.path.exists(VECLIB_PATH):
56 :     extra_link_args = ['-framework', 'vecLib']
57 :     include_dirs = [os.path.join(VECLIB_PATH, 'Headers')]
58 :    
59 :     # The packages are split in this way to allow future optional inclusion
60 :     # Numeric package
61 :     packages = ['']
62 :     package_dir = {'': 'Lib'}
63 :     include_dirs.append('Include')
64 :     ext_modules = [
65 :     Extension('_numpy',
66 :     [os.path.join('Src', '_numpymodule.c'),
67 :     os.path.join('Src', 'arrayobject.c'),
68 :     os.path.join('Src', 'ufuncobject.c')],
69 :     extra_compile_args = extra_compile_args),
70 :     Extension('multiarray',
71 :     [os.path.join('Src', 'multiarraymodule.c')],
72 :     extra_compile_args = extra_compile_args),
73 :     Extension('umath',
74 :     [os.path.join('Src', 'umathmodule.c')],
75 :     libraries = mathlibs,
76 :     define_macros = define_macros,
77 :     undef_macros = undef_macros,
78 :     extra_compile_args = extra_compile_args),
79 :     Extension('arrayfns',
80 :     [os.path.join('Src', 'arrayfnsmodule.c')],
81 :     extra_compile_args = extra_compile_args),
82 :     Extension('ranlib',
83 :     [os.path.join('Src', 'ranlibmodule.c'),
84 :     os.path.join('Src', 'ranlib.c'),
85 :     os.path.join('Src', 'com.c'),
86 :     os.path.join('Src', 'linpack.c')],
87 :     extra_compile_args = extra_compile_args),
88 :     Extension('lapack_lite', sourcelist,
89 :     library_dirs = library_dirs_list,
90 :     libraries = libraries_list,
91 :     extra_link_args = extra_link_args,
92 :     extra_compile_args = extra_compile_args)
93 :     ]
94 :    
95 :     # add FFT package (optional)
96 :     packages.append('FFT')
97 :     package_dir['FFT'] = os.path.join('Packages','FFT','Lib')
98 :     include_dirs.append(os.path.join('Packages','FFT','Include'))
99 :     ext_modules.append(Extension('FFT.fftpack',
100 :     [os.path.join('Packages','FFT','Src', 'fftpackmodule.c'),
101 :     os.path.join('Packages', 'FFT', 'Src', 'fftpack.c')],
102 :     extra_compile_args = extra_compile_args))
103 :    
104 :     # add MA package (optional)
105 :     packages.append('MA')
106 :     package_dir['MA'] = os.path.join('Packages', 'MA', 'Lib')
107 :    
108 :     # add RNG package (optional)
109 :     packages.append('RNG')
110 :     package_dir['RNG'] = os.path.join('Packages', 'RNG', 'Lib')
111 :     include_dirs.append(os.path.join('Packages', 'RNG', 'Include'))
112 :     ext_modules.append(Extension('RNG.RNG',
113 :     [os.path.join('Packages', 'RNG', 'Src', 'RNGmodule.c'),
114 :     os.path.join('Packages', 'RNG', 'Src', 'ranf.c'),
115 :     os.path.join('Packages', 'RNG', 'Src', 'pmath_rng.c')],
116 :     extra_compile_args = extra_compile_args))
117 :     # add dotblas package (optional)
118 :     if use_dotblas:
119 :     packages.append('dotblas')
120 :     package_dir['dotblas'] = os.path.join('Packages', 'dotblas', 'dotblas')
121 :     ext_modules.append(Extension('_dotblas',
122 :     [os.path.join('Packages', 'dotblas', 'dotblas', '_dotblas.c')],
123 :     library_dirs = library_dirs_list,
124 :     libraries = libraries_list,
125 :     extra_link_args = extra_link_args,
126 :     extra_compile_args=extra_compile_args))
127 :    
128 :    
129 :    
130 :    
131 :     long_description = """
132 :     Numerical Extension to Python with subpackages.
133 :    
134 :     The authors and maintainers of the subpackages are:
135 :    
136 :     FFTPACK-3.1
137 :     maintainer = "Numerical Python Developers"
138 :     maintainer_email = "numpy-discussion@lists.sourceforge.net"
139 :     description = "Fast Fourier Transforms"
140 :     url = "http://numpy.sourceforge.net"
141 :    
142 :     MA-%s
143 :     author = "Paul F. Dubois"
144 :     description = "Masked Array facility"
145 :     maintainer = "Paul F. Dubois"
146 :     maintainer_email = "dubois@users.sf.net"
147 :     url = "http://sourceforge.net/projects/numpy"
148 :    
149 :     RNG-3.1
150 :     author = "Lee Busby, Paul F. Dubois, Fred Fritsch"
151 :     maintainer = "Paul F. Dubois"
152 :     maintainer_email = "dubois@users.sf.net"
153 :     description = "Cray-like Random number package."
154 :     """ % (MA_version, )
155 :    
156 :     # Oops, another bug in Distutils!?
157 :     # Write rpm_build.sh pointing to this python
158 :     rpm_build_text="""env CFLAGS="$RPM_OPT_FLAGS" %s setup.py build\n""" % sys.executable
159 :     rpm_script = open("rpm_build.sh", "w")
160 :     rpm_script.write(rpm_build_text)
161 :     rpm_script.close()
162 :    
163 :     # Write rpm_install.sh pointing to this python
164 :     rpm_install_text=sys.executable +""" setup.py install --root=$RPM_BUILD_ROOT
165 :    
166 :     cat >INSTALLED_FILES <<EOF
167 :     %doc Demo
168 :     EOF
169 :     find $RPM_BUILD_ROOT -type f | sed -e "s|$RPM_BUILD_ROOT||g" >>INSTALLED_FILES
170 :    
171 :     """
172 :     rpm_script = open("rpm_install.sh", "w")
173 :     rpm_script.write(rpm_install_text)
174 :     rpm_script.close()
175 :    
176 :     setup (name = "Numeric",
177 :     version = numeric_version,
178 :     maintainer = "Numerical Python Developers",
179 :     maintainer_email = "numpy-developers@lists.sourceforge.net",
180 :     description = "Numerical Extension to Python",
181 :     long_description = long_description,
182 :     url = "http://numpy.sourceforge.net",
183 :    
184 :     # distutils allows you to fix or fudge anything :-)
185 :     extra_path = 'Numeric',
186 :     packages = packages,
187 :     package_dir = package_dir,
188 :     headers = headers,
189 :     include_dirs = include_dirs,
190 :     ext_modules = ext_modules
191 :     )
192 :    
193 :     print 'MA Version', MA_version
194 :     print 'Numeric Version', numeric_version

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3