blob: e2d0a59b02ee9115583d91272b25eb6e3905c7d3 [file] [log] [blame]
Fernando Perez36d3c162006-07-12 06:02:281#!/usr/bin/env python
Travis Oliphantc8b5a7e2006-01-06 02:12:502"""NumPy: array processing for numbers, strings, records, and objects.
Travis Oliphantda9c6da2006-01-04 17:31:073
Travis Oliphantc8b5a7e2006-01-06 02:12:504NumPy is a general-purpose array-processing package designed to
Travis Oliphantda9c6da2006-01-04 17:31:075efficiently manipulate large multi-dimensional arrays of arbitrary
6records without sacrificing too much speed for small multi-dimensional
Travis Oliphantc8b5a7e2006-01-06 02:12:507arrays. NumPy is built on the Numeric code base and adds features
Travis Oliphantda9c6da2006-01-04 17:31:078introduced by numarray as well as an extended C-API and the ability to
Travis Oliphant00a35872007-05-31 04:57:019create arrays of arbitrary type which also makes NumPy suitable for
10interfacing with general-purpose data-base applications.
Travis Oliphantda9c6da2006-01-04 17:31:0711
12There are also basic facilities for discrete fourier transform,
13basic linear algebra and random number generation.
14"""
15
16DOCLINES = __doc__.split("\n")
Pearu Petersonc415fd12002-11-18 22:39:3117
Pearu Petersone8fa0132003-03-07 18:08:2818import os
Pauli Virtanen68159432009-12-06 11:56:1819import shutil
Pearu Petersone8fa0132003-03-07 18:08:2820import sys
David Cournapeau5864bd22009-03-27 16:39:3421import re
David Cournapeau5623a7c2009-04-02 16:21:3022import subprocess
Pearu Petersonc415fd12002-11-18 22:39:3123
David Cournapeau2b517692009-12-03 15:53:2924if sys.version_info[0] < 3:
25 import __builtin__ as builtins
26else:
27 import builtins
28
Travis Oliphantda9c6da2006-01-04 17:31:0729CLASSIFIERS = """\
Robert Kern19da9712008-06-18 22:53:4430Development Status :: 5 - Production/Stable
Travis Oliphantda9c6da2006-01-04 17:31:0731Intended Audience :: Science/Research
32Intended Audience :: Developers
33License :: OSI Approved
34Programming Language :: C
35Programming Language :: Python
36Topic :: Software Development
37Topic :: Scientific/Engineering
38Operating System :: Microsoft :: Windows
39Operating System :: POSIX
40Operating System :: Unix
41Operating System :: MacOS
42"""
43
David Cournapeaucc9a4462009-03-27 11:16:1344NAME = 'numpy'
45MAINTAINER = "NumPy Developers"
46MAINTAINER_EMAIL = "numpy-discussion@scipy.org"
47DESCRIPTION = DOCLINES[0]
48LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
49URL = "http://numpy.scipy.org"
50DOWNLOAD_URL = "http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103"
51LICENSE = 'BSD'
52CLASSIFIERS = filter(None, CLASSIFIERS.split('\n'))
53AUTHOR = "Travis E. Oliphant, et.al."
54AUTHOR_EMAIL = "oliphant@enthought.com"
55PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
Pauli Virtanen99adb172010-07-17 18:40:5056MAJOR = 1
57MINOR = 5
rgommers97cb28e2010-10-17 06:33:0158MICRO = 1
rgommers33047912010-11-08 13:59:3259ISRELEASED = True
rgommersde969d72010-11-18 11:14:2460VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
Stefan van der Waltb9a22d72009-06-17 14:28:0361
David Cournapeau5623a7c2009-04-02 16:21:3062# Return the svn version as a string, raise a ValueError otherwise
63def svn_version():
David Cournapeau44d92ec2009-06-01 05:43:1664 def _minimal_ext_cmd(cmd):
65 # construct minimal environment
66 env = {}
David Cournapeau5032b522009-09-18 10:10:3967 for k in ['SYSTEMROOT', 'PATH']:
68 v = os.environ.get(k)
69 if v is not None:
70 env[k] = v
David Cournapeau44d92ec2009-06-01 05:43:1671 # LANGUAGE is used on win32
72 env['LANGUAGE'] = 'C'
73 env['LANG'] = 'C'
74 env['LC_ALL'] = 'C'
75 out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
76 return out
77
David Cournapeau5623a7c2009-04-02 16:21:3078 try:
David Cournapeau44d92ec2009-06-01 05:43:1679 out = _minimal_ext_cmd(['svn', 'info'])
David Cournapeau5623a7c2009-04-02 16:21:3080 except OSError:
David Cournapeau44d92ec2009-06-01 05:43:1681 print(" --- Could not run svn info --- ")
David Cournapeau5623a7c2009-04-02 16:21:3082 return ""
David Cournapeau5e041cb2009-03-27 11:16:0183
David Cournapeau5623a7c2009-04-02 16:21:3084 r = re.compile('Revision: ([0-9]+)')
Stefan van der Waltb9a22d72009-06-17 14:28:0385 svnver = ""
Pauli Virtanenab391a92009-12-06 12:49:2186
Pauli Virtanen3033a149c2009-12-06 13:00:4787 out = out.decode()
88
89 for line in out.split('\n'):
Stefan van der Waltb9a22d72009-06-17 14:28:0390 m = r.match(line.strip())
David Cournapeau5623a7c2009-04-02 16:21:3091 if m:
92 svnver = m.group(1)
David Cournapeau52fb78d2009-03-27 18:37:0793
David Cournapeau5623a7c2009-04-02 16:21:3094 if not svnver:
Stefan van der Waltb9a22d72009-06-17 14:28:0395 print("Error while parsing svn version")
96
David Cournapeau5623a7c2009-04-02 16:21:3097 return svnver
David Cournapeau5e041cb2009-03-27 11:16:0198
David Cournapeau5bb1aa52009-03-27 16:39:0199# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
100# update it when the contents of directories change.
101if os.path.exists('MANIFEST'): os.remove('MANIFEST')
102
103# This is a bit hackish: we are setting a global variable so that the main
104# numpy __init__ can detect if it is being loaded by the setup routine, to
105# avoid attempting to load components that aren't built yet. While ugly, it's
106# a lot more robust than what was previously being used.
David Cournapeau2b517692009-12-03 15:53:29107builtins.__NUMPY_SETUP__ = True
David Cournapeau5bb1aa52009-03-27 16:39:01108
David Cournapeaud8fc4ad2009-04-01 16:18:55109FULLVERSION = VERSION
110if not ISRELEASED:
111 FULLVERSION += '.dev'
112 # If in git or something, bypass the svn rev
113 if os.path.exists('.svn'):
David Cournapeau5623a7c2009-04-02 16:21:30114 FULLVERSION += svn_version()
David Cournapeaud8fc4ad2009-04-01 16:18:55115
David Cournapeaua2ac9852009-03-27 11:15:36116def write_version_py(filename='numpy/version.py'):
117 cnt = """
David Cournapeau914bb152009-03-27 11:15:47118# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
David Cournapeaua70c4832009-03-27 12:07:37119short_version='%(version)s'
David Cournapeaua2ac9852009-03-27 11:15:36120version='%(version)s'
121release=%(isrelease)s
122
123if not release:
124 version += '.dev'
125 import os
126 svn_version_file = os.path.join(os.path.dirname(__file__),
127 'core','__svn_version__.py')
128 if os.path.isfile(svn_version_file):
129 import imp
130 svn = imp.load_module('numpy.core.__svn_version__',
131 open(svn_version_file),
132 svn_version_file,
133 ('.py','U',1))
134 version += svn.version
135"""
136 a = open(filename, 'w')
137 try:
138 a.write(cnt % {'version': VERSION, 'isrelease': str(ISRELEASED)})
139 finally:
140 a.close()
141
Pearu Peterson471196b2006-03-31 08:59:36142def configuration(parent_package='',top_path=None):
143 from numpy.distutils.misc_util import Configuration
144
Pearu Peterson17d7cfe2006-04-04 12:26:14145 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36146 config.set_options(ignore_setup_xxx_py=True,
147 assume_default_configuration=True,
148 delegate_options_to_subpackages=True,
149 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18150
Pearu Peterson471196b2006-03-31 08:59:36151 config.add_subpackage('numpy')
Jarrod Millman0b77f0e2007-10-29 14:58:18152
Pearu Peterson7b76ca72007-06-05 18:54:28153 config.add_data_files(('numpy','*.txt'),
154 ('numpy','COMPATIBILITY'),
rgommersc0440f82010-08-04 10:57:50155 ('numpy','site.cfg.example'),
156 ('numpy/tools', 'tools/py3tool.py'))
Pearu Peterson17d7cfe2006-04-04 12:26:14157
158 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01159
Pearu Peterson471196b2006-03-31 08:59:36160 return config
161
Pearu Petersone8fa0132003-03-07 18:08:28162def setup_package():
Travis Oliphant14db4192005-09-14 22:08:46163
David Cournapeaua2ac9852009-03-27 11:15:36164 # Rewrite the version file everytime
165 if os.path.exists('numpy/version.py'): os.remove('numpy/version.py')
166 write_version_py()
167
Pauli Virtanen68159432009-12-06 11:56:18168 # Perform 2to3 if needed
169 local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
170 src_path = local_path
171
172 if sys.version_info[0] == 3:
173 src_path = os.path.join(local_path, 'build', 'py3k')
174 sys.path.insert(0, os.path.join(local_path, 'tools'))
175 import py3tool
176 print("Converting to Python3 via 2to3...")
177 py3tool.sync_2to3('numpy', os.path.join(src_path, 'numpy'))
178
179 site_cfg = os.path.join(local_path, 'site.cfg')
180 if os.path.isfile(site_cfg):
181 shutil.copy(site_cfg, src_path)
182
183 # Run build
184 old_path = os.getcwd()
185 os.chdir(src_path)
186 sys.path.insert(0, src_path)
187
188 from numpy.distutils.core import setup
189
Pearu Petersone8fa0132003-03-07 18:08:28190 try:
Pearu Peterson17d7cfe2006-04-04 12:26:14191 setup(
David Cournapeauc253b722009-03-27 11:15:22192 name=NAME,
193 maintainer=MAINTAINER,
194 maintainer_email=MAINTAINER_EMAIL,
195 description=DESCRIPTION,
196 long_description=LONG_DESCRIPTION,
197 url=URL,
198 download_url=DOWNLOAD_URL,
199 license=LICENSE,
200 classifiers=CLASSIFIERS,
201 author=AUTHOR,
202 author_email=AUTHOR_EMAIL,
203 platforms=PLATFORMS,
Pearu Peterson17d7cfe2006-04-04 12:26:14204 configuration=configuration )
Pearu Petersone8fa0132003-03-07 18:08:28205 finally:
206 del sys.path[0]
207 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46208 return
Pearu Petersonc415fd12002-11-18 22:39:31209
Travis Oliphant14db4192005-09-14 22:08:46210if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28211 setup_package()