blob: b2c6e9845afca32edec209e49811106553affbcf [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
Fernando Perez083ca642007-12-30 03:04:1718import __builtin__
Pearu Petersone8fa0132003-03-07 18:08:2819import os
20import sys
David Cournapeau5864bd22009-03-27 16:39:3421import re
David Cournapeau5623a7c2009-04-02 16:21:3022import subprocess
Pearu Petersonc415fd12002-11-18 22:39:3123
Travis Oliphantda9c6da2006-01-04 17:31:0724CLASSIFIERS = """\
Robert Kern19da9712008-06-18 22:53:4425Development Status :: 5 - Production/Stable
Travis Oliphantda9c6da2006-01-04 17:31:0726Intended Audience :: Science/Research
27Intended Audience :: Developers
28License :: OSI Approved
29Programming Language :: C
30Programming Language :: Python
31Topic :: Software Development
32Topic :: Scientific/Engineering
33Operating System :: Microsoft :: Windows
34Operating System :: POSIX
35Operating System :: Unix
36Operating System :: MacOS
37"""
38
David Cournapeaucc9a4462009-03-27 11:16:1339NAME = 'numpy'
40MAINTAINER = "NumPy Developers"
41MAINTAINER_EMAIL = "numpy-discussion@scipy.org"
42DESCRIPTION = DOCLINES[0]
43LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
44URL = "http://numpy.scipy.org"
45DOWNLOAD_URL = "http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103"
46LICENSE = 'BSD'
47CLASSIFIERS = filter(None, CLASSIFIERS.split('\n'))
48AUTHOR = "Travis E. Oliphant, et.al."
49AUTHOR_EMAIL = "oliphant@enthought.com"
50PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
David Cournapeau5e041cb2009-03-27 11:16:0151MAJOR = 1
52MINOR = 4
rgommersc7ba5002010-04-18 08:47:1953MICRO = 1
David Cournapeau4b42c8f2009-12-28 01:25:0854ISRELEASED = True
rgommers351726a2010-04-22 10:35:1655VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
Stefan van der Waltb9a22d72009-06-17 14:28:0356
David Cournapeau5623a7c2009-04-02 16:21:3057# Return the svn version as a string, raise a ValueError otherwise
58def svn_version():
David Cournapeau44d92ec2009-06-01 05:43:1659 def _minimal_ext_cmd(cmd):
60 # construct minimal environment
61 env = {}
David Cournapeau5032b522009-09-18 10:10:3962 for k in ['SYSTEMROOT', 'PATH']:
63 v = os.environ.get(k)
64 if v is not None:
65 env[k] = v
David Cournapeau44d92ec2009-06-01 05:43:1666 # LANGUAGE is used on win32
67 env['LANGUAGE'] = 'C'
68 env['LANG'] = 'C'
69 env['LC_ALL'] = 'C'
70 out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
71 return out
72
David Cournapeau5623a7c2009-04-02 16:21:3073 try:
David Cournapeau44d92ec2009-06-01 05:43:1674 out = _minimal_ext_cmd(['svn', 'info'])
David Cournapeau5623a7c2009-04-02 16:21:3075 except OSError:
David Cournapeau44d92ec2009-06-01 05:43:1676 print(" --- Could not run svn info --- ")
David Cournapeau5623a7c2009-04-02 16:21:3077 return ""
David Cournapeau5e041cb2009-03-27 11:16:0178
David Cournapeau5623a7c2009-04-02 16:21:3079 r = re.compile('Revision: ([0-9]+)')
Stefan van der Waltb9a22d72009-06-17 14:28:0380 svnver = ""
David Cournapeau5623a7c2009-04-02 16:21:3081 for line in out.split('\n'):
Stefan van der Waltb9a22d72009-06-17 14:28:0382 m = r.match(line.strip())
David Cournapeau5623a7c2009-04-02 16:21:3083 if m:
84 svnver = m.group(1)
David Cournapeau52fb78d2009-03-27 18:37:0785
David Cournapeau5623a7c2009-04-02 16:21:3086 if not svnver:
Stefan van der Waltb9a22d72009-06-17 14:28:0387 print("Error while parsing svn version")
88
David Cournapeau5623a7c2009-04-02 16:21:3089 return svnver
David Cournapeau5e041cb2009-03-27 11:16:0190
David Cournapeau5bb1aa52009-03-27 16:39:0191# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
92# update it when the contents of directories change.
93if os.path.exists('MANIFEST'): os.remove('MANIFEST')
94
95# This is a bit hackish: we are setting a global variable so that the main
96# numpy __init__ can detect if it is being loaded by the setup routine, to
97# avoid attempting to load components that aren't built yet. While ugly, it's
98# a lot more robust than what was previously being used.
99__builtin__.__NUMPY_SETUP__ = True
100
David Cournapeaud8fc4ad2009-04-01 16:18:55101FULLVERSION = VERSION
102if not ISRELEASED:
103 FULLVERSION += '.dev'
104 # If in git or something, bypass the svn rev
105 if os.path.exists('.svn'):
David Cournapeau5623a7c2009-04-02 16:21:30106 FULLVERSION += svn_version()
David Cournapeaud8fc4ad2009-04-01 16:18:55107
David Cournapeaua2ac9852009-03-27 11:15:36108def write_version_py(filename='numpy/version.py'):
109 cnt = """
David Cournapeau914bb152009-03-27 11:15:47110# THIS FILE IS GENERATED FROM NUMPY SETUP.PY
David Cournapeaua70c4832009-03-27 12:07:37111short_version='%(version)s'
David Cournapeaua2ac9852009-03-27 11:15:36112version='%(version)s'
113release=%(isrelease)s
114
115if not release:
116 version += '.dev'
117 import os
118 svn_version_file = os.path.join(os.path.dirname(__file__),
119 'core','__svn_version__.py')
120 if os.path.isfile(svn_version_file):
121 import imp
122 svn = imp.load_module('numpy.core.__svn_version__',
123 open(svn_version_file),
124 svn_version_file,
125 ('.py','U',1))
126 version += svn.version
127"""
128 a = open(filename, 'w')
129 try:
130 a.write(cnt % {'version': VERSION, 'isrelease': str(ISRELEASED)})
131 finally:
132 a.close()
133
Pearu Peterson471196b2006-03-31 08:59:36134def configuration(parent_package='',top_path=None):
135 from numpy.distutils.misc_util import Configuration
136
Pearu Peterson17d7cfe2006-04-04 12:26:14137 config = Configuration(None, parent_package, top_path)
Pearu Peterson471196b2006-03-31 08:59:36138 config.set_options(ignore_setup_xxx_py=True,
139 assume_default_configuration=True,
140 delegate_options_to_subpackages=True,
141 quiet=True)
Jarrod Millman0b77f0e2007-10-29 14:58:18142
Pearu Peterson471196b2006-03-31 08:59:36143 config.add_subpackage('numpy')
Jarrod Millman0b77f0e2007-10-29 14:58:18144
Pearu Peterson7b76ca72007-06-05 18:54:28145 config.add_data_files(('numpy','*.txt'),
146 ('numpy','COMPATIBILITY'),
Pearu Peterson7b76ca72007-06-05 18:54:28147 ('numpy','site.cfg.example'))
Pearu Peterson17d7cfe2006-04-04 12:26:14148
149 config.get_version('numpy/version.py') # sets config.version
Travis Oliphant00a35872007-05-31 04:57:01150
Pearu Peterson471196b2006-03-31 08:59:36151 return config
152
Pearu Petersone8fa0132003-03-07 18:08:28153def setup_package():
Travis Oliphant14db4192005-09-14 22:08:46154
Travis Oliphantda9c6da2006-01-04 17:31:07155 from numpy.distutils.core import setup
Travis Oliphant14db4192005-09-14 22:08:46156
Pearu Petersone8fa0132003-03-07 18:08:28157 old_path = os.getcwd()
Pearu Petersond1906742003-11-24 22:50:40158 local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
159 os.chdir(local_path)
Travis Oliphant14db4192005-09-14 22:08:46160 sys.path.insert(0,local_path)
Pearu Petersone8fa0132003-03-07 18:08:28161
David Cournapeaua2ac9852009-03-27 11:15:36162 # Rewrite the version file everytime
163 if os.path.exists('numpy/version.py'): os.remove('numpy/version.py')
164 write_version_py()
165
Pearu Petersone8fa0132003-03-07 18:08:28166 try:
Pearu Peterson17d7cfe2006-04-04 12:26:14167 setup(
David Cournapeauc253b722009-03-27 11:15:22168 name=NAME,
169 maintainer=MAINTAINER,
170 maintainer_email=MAINTAINER_EMAIL,
171 description=DESCRIPTION,
172 long_description=LONG_DESCRIPTION,
173 url=URL,
174 download_url=DOWNLOAD_URL,
175 license=LICENSE,
176 classifiers=CLASSIFIERS,
177 author=AUTHOR,
178 author_email=AUTHOR_EMAIL,
179 platforms=PLATFORMS,
Pearu Peterson17d7cfe2006-04-04 12:26:14180 configuration=configuration )
Pearu Petersone8fa0132003-03-07 18:08:28181 finally:
182 del sys.path[0]
183 os.chdir(old_path)
Travis Oliphant14db4192005-09-14 22:08:46184 return
Pearu Petersonc415fd12002-11-18 22:39:31185
Travis Oliphant14db4192005-09-14 22:08:46186if __name__ == '__main__':
Pearu Petersone8fa0132003-03-07 18:08:28187 setup_package()