blob: 7da51806e68dfba185e0ae732a3935357ea4ad1f [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
rgommerscdac1202011-01-25 14:02:4036Programming Language :: Python :: 3
Travis Oliphantda9c6da2006-01-04 17:31:0737Topic :: Software Development
38Topic :: Scientific/Engineering
39Operating System :: Microsoft :: Windows
40Operating System :: POSIX
41Operating System :: Unix
42Operating System :: MacOS
43"""
44
David Cournapeaucc9a4462009-03-27 11:16:1345NAME = 'numpy'
46MAINTAINER = "NumPy Developers"
47MAINTAINER_EMAIL = "numpy-discussion@scipy.org"
48DESCRIPTION = DOCLINES[0]
49LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
50URL = "http://numpy.scipy.org"
51DOWNLOAD_URL = "http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103"
52LICENSE = 'BSD'
53CLASSIFIERS = filter(None, CLASSIFIERS.split('\n'))
54AUTHOR = "Travis E. Oliphant, et.al."
55AUTHOR_EMAIL = "oliphant@enthought.com"
56PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
Mark Wiebe82bd8f92011-01-26 21:38:2657MAJOR = 1
58MINOR = 6
Ralf Gommersd1bd08d2011-05-14 09:31:3259MICRO = 1
Ralf Gommers9b46e7b2011-07-01 19:46:3960ISRELEASED = True
Ralf Gommers68538b72011-07-20 18:29:1861VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
Stefan van der Waltb9a22d72009-06-17 14:28:0362
Scott Sinclair58e63602010-11-09 15:09:1563# Return the git revision as a string
64def git_version():
David Cournapeau44d92ec2009-06-01 05:43:1665 def _minimal_ext_cmd(cmd):
66 # construct minimal environment
67 env = {}
David Cournapeau5032b522009-09-18 10:10:3968 for k in ['SYSTEMROOT', 'PATH']:
69 v = os.environ.get(k)
70 if v is not None:
71 env[k] = v
David Cournapeau44d92ec2009-06-01 05:43:1672 # LANGUAGE is used on win32
73 env['LANGUAGE'] = 'C'
74 env['LANG'] = 'C'
75 env['LC_ALL'] = 'C'
76 out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
77 return out
78
David Cournapeau5623a7c2009-04-02 16:21:3079 try:
Scott Sinclair58e63602010-11-09 15:09:1580 out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
Pauli Virtanend1a184c2010-11-15 01:00:0681 GIT_REVISION = out.strip().decode('ascii')
David Cournapeau5623a7c2009-04-02 16:21:3082 except OSError:
Scott Sinclaird5ed7442010-11-10 05:19:1583 GIT_REVISION = "Unknown"
David Cournapeau5e041cb2009-03-27 11:16:0184
Scott Sinclair58e63602010-11-09 15:09:1585 return GIT_REVISION
David Cournapeau5e041cb2009-03-27 11:16:0186
David Cournapeau5bb1aa52009-03-27 16:39:0187# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
88# update it when the contents of directories change.
89if os.path.exists('MANIFEST'): os.remove('MANIFEST')
90
91# This is a bit hackish: we are setting a global variable so that the main
92# numpy __init__ can detect if it is being loaded by the setup routine, to
93# avoid attempting to load components that aren't built yet. While ugly, it's
94# a lot more robust than what was previously being used.
David Cournapeau2b517692009-12-03 15:53:2995builtins.__NUMPY_SETUP__ = True
David Cournapeau5bb1aa52009-03-27 16:39:0196
rgommers13212a52011-03-03 16:13:0897
David Cournapeaua2ac9852009-03-27 11:15:3698def write_version_py(filename='numpy/version.py'):
99 cnt = """
David Cournapeau914bb152009-03-27 11:15:47100# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
Scott Sinclair0502dab2010-11-10 05:24:57101short_version = '%(version)s'
102version = '%(version)s'
103full_version = '%(full_version)s'
104git_revision = '%(git_revision)s'
105release = %(isrelease)s
David Cournapeaua2ac9852009-03-27 11:15:36106
107if not release:
Scott Sinclair58e63602010-11-09 15:09:15108 version = full_version
David Cournapeaua2ac9852009-03-27 11:15:36109"""
Ralf Gommers4ff55f02011-03-24 15:30:06110 # Adding the git rev number needs to be done inside write_version_py(),
111 # otherwise the import of numpy.version messes up the build under Python 3.
112 FULLVERSION = VERSION
113 if os.path.exists('.git'):
114 GIT_REVISION = git_version()
115 elif os.path.exists('numpy/version.py'):
116 # must be a source distribution, use existing version file
117 from numpy.version import git_revision as GIT_REVISION
118 else:
119 GIT_REVISION = "Unknown"
120
121 if not ISRELEASED:
122 FULLVERSION += '.dev-' + GIT_REVISION[:7]
123
David Cournapeaua2ac9852009-03-27 11:15:36124 a = open(filename, 'w')
125 try:
Scott Sinclair58e63602010-11-09 15:09:15126 a.write(cnt % {'version': VERSION,
rgommers13212a52011-03-03 16:13:08127 'full_version' : FULLVERSION,
Scott Sinclair58e63602010-11-09 15:09:15128 'git_revision' : GIT_REVISION,
129 'isrelease': str(ISRELEASED)})
David Cournapeaua2ac9852009-03-27 11:15:36130 finally:
131 a.close()
132
Pearu Peterson471196b2006-03-31 08:59:36133def configuration(parent_package='',top_path=None):
134 from numpy.distutils.misc_util import Configuration
135
Pearu Peterson17d7cfe2006-04-04 12:26:14136 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36137 config.set_options(ignore_setup_xxx_py=True,
138 assume_default_configuration=True,
139 delegate_options_to_subpackages=True,
140 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18141
Pearu Peterson471196b2006-03-31 08:59:36142 config.add_subpackage('numpy')
Jarrod Millman0b77f0e2007-10-29 14:58:18143
Pearu Peterson17d7cfe2006-04-04 12:26:14144 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01145
Pearu Peterson471196b2006-03-31 08:59:36146 return config
147
Pearu Petersone8fa0132003-03-07 18:08:28148def setup_package():
Travis Oliphant14db4192005-09-14 22:08:46149
Pauli Virtanen68159432009-12-06 11:56:18150 # Perform 2to3 if needed
151 local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
152 src_path = local_path
153
154 if sys.version_info[0] == 3:
155 src_path = os.path.join(local_path, 'build', 'py3k')
156 sys.path.insert(0, os.path.join(local_path, 'tools'))
157 import py3tool
158 print("Converting to Python3 via 2to3...")
159 py3tool.sync_2to3('numpy', os.path.join(src_path, 'numpy'))
160
161 site_cfg = os.path.join(local_path, 'site.cfg')
162 if os.path.isfile(site_cfg):
163 shutil.copy(site_cfg, src_path)
164
Pauli Virtanen68159432009-12-06 11:56:18165 old_path = os.getcwd()
166 os.chdir(src_path)
167 sys.path.insert(0, src_path)
168
Pauli Virtanen01312182010-11-23 16:50:54169 # Rewrite the version file everytime
170 write_version_py()
171
172 # Run build
Pauli Virtanen68159432009-12-06 11:56:18173 from numpy.distutils.core import setup
174
Pearu Petersone8fa0132003-03-07 18:08:28175 try:
Pearu Peterson17d7cfe2006-04-04 12:26:14176 setup(
David Cournapeauc253b722009-03-27 11:15:22177 name=NAME,
178 maintainer=MAINTAINER,
179 maintainer_email=MAINTAINER_EMAIL,
180 description=DESCRIPTION,
181 long_description=LONG_DESCRIPTION,
182 url=URL,
183 download_url=DOWNLOAD_URL,
184 license=LICENSE,
185 classifiers=CLASSIFIERS,
186 author=AUTHOR,
187 author_email=AUTHOR_EMAIL,
188 platforms=PLATFORMS,
Pearu Peterson17d7cfe2006-04-04 12:26:14189 configuration=configuration )
Pearu Petersone8fa0132003-03-07 18:08:28190 finally:
191 del sys.path[0]
192 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46193 return
Pearu Petersonc415fd12002-11-18 22:39:31194
Travis Oliphant14db4192005-09-14 22:08:46195if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28196 setup_package()