blob: 4c43273a1e23f5f32a5af8af9ba5e9ab1f334a2a [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.
Charles Harris6aa264c2013-02-27 20:26:5814
Travis Oliphantda9c6da2006-01-04 17:31:0715"""
Charles Harrisbb726ca2013-04-06 19:25:2616from __future__ import division, print_function
Travis Oliphantda9c6da2006-01-04 17:31:0717
18DOCLINES = __doc__.split("\n")
Pearu Petersonc415fd12002-11-18 22:39:3119
Pearu Petersone8fa0132003-03-07 18:08:2820import os
Pauli Virtanen68159432009-12-06 11:56:1821import shutil
Pearu Petersone8fa0132003-03-07 18:08:2822import sys
David Cournapeau5864bd22009-03-27 16:39:3423import re
David Cournapeau5623a7c2009-04-02 16:21:3024import subprocess
Pearu Petersonc415fd12002-11-18 22:39:3125
Charles Harris28eadc02013-07-11 18:08:4926if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[0:2] < (3, 2):
27 raise RuntimeError("Python version 2.6, 2.7 or >= 3.2 required.")
28
Charles Harris09a52ed2013-03-28 23:13:5329if sys.version_info[0] >= 3:
David Cournapeau2b517692009-12-03 15:53:2930 import builtins
Charles Harris09a52ed2013-03-28 23:13:5331else:
32 import __builtin__ as builtins
David Cournapeau2b517692009-12-03 15:53:2933
Travis Oliphantda9c6da2006-01-04 17:31:0734CLASSIFIERS = """\
Robert Kern19da9712008-06-18 22:53:4435Development Status :: 5 - Production/Stable
Travis Oliphantda9c6da2006-01-04 17:31:0736Intended Audience :: Science/Research
37Intended Audience :: Developers
38License :: OSI Approved
39Programming Language :: C
40Programming Language :: Python
rgommerscdac1202011-01-25 14:02:4041Programming Language :: Python :: 3
Travis Oliphantda9c6da2006-01-04 17:31:0742Topic :: Software Development
43Topic :: Scientific/Engineering
44Operating System :: Microsoft :: Windows
45Operating System :: POSIX
46Operating System :: Unix
47Operating System :: MacOS
48"""
49
David Cournapeaucc9a4462009-03-27 11:16:1350NAME = 'numpy'
51MAINTAINER = "NumPy Developers"
52MAINTAINER_EMAIL = "numpy-discussion@scipy.org"
53DESCRIPTION = DOCLINES[0]
54LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
Sandro Tosi864353e2012-12-30 11:12:1855URL = "http://www.numpy.org"
Ralf Gommers58c1bf72012-11-05 19:47:2356DOWNLOAD_URL = "http://sourceforge.net/projects/numpy/files/NumPy/"
David Cournapeaucc9a4462009-03-27 11:16:1357LICENSE = 'BSD'
Charles Harrisb990ed52013-02-28 17:58:4058CLASSIFIERS = [_f for _f in CLASSIFIERS.split('\n') if _f]
Stefan van der Waltddbb4bd2012-11-14 21:56:2459AUTHOR = "Travis E. Oliphant et al."
David Cournapeaucc9a4462009-03-27 11:16:1360AUTHOR_EMAIL = "oliphant@enthought.com"
61PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
Ralf Gommers58c1bf72012-11-05 19:47:2362MAJOR = 1
63MINOR = 8
David Cournapeau5e041cb2009-03-27 11:16:0164MICRO = 0
Charles Harrisa60b3902013-10-28 23:21:0265ISRELEASED = True
David Cournapeau5e041cb2009-03-27 11:16:0166VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
Stefan van der Waltb9a22d72009-06-17 14:28:0367
Scott Sinclair58e63602010-11-09 15:09:1568# Return the git revision as a string
69def git_version():
David Cournapeau44d92ec2009-06-01 05:43:1670 def _minimal_ext_cmd(cmd):
71 # construct minimal environment
72 env = {}
David Cournapeau5032b522009-09-18 10:10:3973 for k in ['SYSTEMROOT', 'PATH']:
74 v = os.environ.get(k)
75 if v is not None:
76 env[k] = v
David Cournapeau44d92ec2009-06-01 05:43:1677 # LANGUAGE is used on win32
78 env['LANGUAGE'] = 'C'
79 env['LANG'] = 'C'
80 env['LC_ALL'] = 'C'
81 out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
82 return out
83
David Cournapeau5623a7c2009-04-02 16:21:3084 try:
Scott Sinclair58e63602010-11-09 15:09:1585 out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
Pauli Virtanend1a184c2010-11-15 01:00:0686 GIT_REVISION = out.strip().decode('ascii')
David Cournapeau5623a7c2009-04-02 16:21:3087 except OSError:
Scott Sinclaird5ed7442010-11-10 05:19:1588 GIT_REVISION = "Unknown"
David Cournapeau5e041cb2009-03-27 11:16:0189
Scott Sinclair58e63602010-11-09 15:09:1590 return GIT_REVISION
David Cournapeau5e041cb2009-03-27 11:16:0191
David Cournapeau5bb1aa52009-03-27 16:39:0192# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
93# update it when the contents of directories change.
94if os.path.exists('MANIFEST'): os.remove('MANIFEST')
95
96# This is a bit hackish: we are setting a global variable so that the main
97# numpy __init__ can detect if it is being loaded by the setup routine, to
98# avoid attempting to load components that aren't built yet. While ugly, it's
99# a lot more robust than what was previously being used.
David Cournapeau2b517692009-12-03 15:53:29100builtins.__NUMPY_SETUP__ = True
David Cournapeau5bb1aa52009-03-27 16:39:01101
rgommers13212a52011-03-03 16:13:08102
David Cournapeaua2ac9852009-03-27 11:15:36103def write_version_py(filename='numpy/version.py'):
104 cnt = """
David Cournapeau914bb152009-03-27 11:15:47105# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
Scott Sinclair0502dab2010-11-10 05:24:57106short_version = '%(version)s'
107version = '%(version)s'
108full_version = '%(full_version)s'
109git_revision = '%(git_revision)s'
110release = %(isrelease)s
David Cournapeaua2ac9852009-03-27 11:15:36111
112if not release:
Scott Sinclair58e63602010-11-09 15:09:15113 version = full_version
David Cournapeaua2ac9852009-03-27 11:15:36114"""
Ralf Gommers87e12c12011-03-24 15:30:06115 # Adding the git rev number needs to be done inside write_version_py(),
116 # otherwise the import of numpy.version messes up the build under Python 3.
117 FULLVERSION = VERSION
118 if os.path.exists('.git'):
119 GIT_REVISION = git_version()
120 elif os.path.exists('numpy/version.py'):
121 # must be a source distribution, use existing version file
Ralf Gommerscd6d53f2011-04-17 14:04:11122 try:
123 from numpy.version import git_revision as GIT_REVISION
124 except ImportError:
125 raise ImportError("Unable to import git_revision. Try removing " \
126 "numpy/version.py and the build directory " \
127 "before building.")
Ralf Gommers87e12c12011-03-24 15:30:06128 else:
129 GIT_REVISION = "Unknown"
130
131 if not ISRELEASED:
132 FULLVERSION += '.dev-' + GIT_REVISION[:7]
133
David Cournapeaua2ac9852009-03-27 11:15:36134 a = open(filename, 'w')
135 try:
Scott Sinclair58e63602010-11-09 15:09:15136 a.write(cnt % {'version': VERSION,
rgommers13212a52011-03-03 16:13:08137 'full_version' : FULLVERSION,
Scott Sinclair58e63602010-11-09 15:09:15138 'git_revision' : GIT_REVISION,
139 'isrelease': str(ISRELEASED)})
David Cournapeaua2ac9852009-03-27 11:15:36140 finally:
141 a.close()
142
Pearu Peterson471196b2006-03-31 08:59:36143def configuration(parent_package='',top_path=None):
144 from numpy.distutils.misc_util import Configuration
145
Pearu Peterson17d7cfe2006-04-04 12:26:14146 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36147 config.set_options(ignore_setup_xxx_py=True,
148 assume_default_configuration=True,
149 delegate_options_to_subpackages=True,
150 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18151
Pearu Peterson471196b2006-03-31 08:59:36152 config.add_subpackage('numpy')
Jarrod Millman0b77f0e2007-10-29 14:58:18153
Pearu Peterson17d7cfe2006-04-04 12:26:14154 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01155
Pearu Peterson471196b2006-03-31 08:59:36156 return config
157
Pearu Petersone8fa0132003-03-07 18:08:28158def setup_package():
Travis Oliphant14db4192005-09-14 22:08:46159
Charles Harrisb4180e32013-04-22 03:26:44160 src_path = os.path.dirname(os.path.abspath(sys.argv[0]))
Pauli Virtanen68159432009-12-06 11:56:18161 old_path = os.getcwd()
162 os.chdir(src_path)
163 sys.path.insert(0, src_path)
164
Pauli Virtanen01312182010-11-23 16:50:54165 # Rewrite the version file everytime
166 write_version_py()
167
168 # Run build
Pauli Virtanen68159432009-12-06 11:56:18169 from numpy.distutils.core import setup
170
Pearu Petersone8fa0132003-03-07 18:08:28171 try:
Pearu Peterson17d7cfe2006-04-04 12:26:14172 setup(
David Cournapeauc253b722009-03-27 11:15:22173 name=NAME,
174 maintainer=MAINTAINER,
175 maintainer_email=MAINTAINER_EMAIL,
176 description=DESCRIPTION,
177 long_description=LONG_DESCRIPTION,
178 url=URL,
179 download_url=DOWNLOAD_URL,
180 license=LICENSE,
181 classifiers=CLASSIFIERS,
182 author=AUTHOR,
183 author_email=AUTHOR_EMAIL,
184 platforms=PLATFORMS,
Pearu Peterson17d7cfe2006-04-04 12:26:14185 configuration=configuration )
Pearu Petersone8fa0132003-03-07 18:08:28186 finally:
187 del sys.path[0]
188 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46189 return
Pearu Petersonc415fd12002-11-18 22:39:31190
Travis Oliphant14db4192005-09-14 22:08:46191if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28192 setup_package()