Fernando Perez | 36d3c16 | 2006-07-12 06:02:28 | [diff] [blame] | 1 | #!/usr/bin/env python |
Travis Oliphant | c8b5a7e | 2006-01-06 02:12:50 | [diff] [blame] | 2 | """NumPy: array processing for numbers, strings, records, and objects. |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 3 | |
Travis Oliphant | c8b5a7e | 2006-01-06 02:12:50 | [diff] [blame] | 4 | NumPy is a general-purpose array-processing package designed to |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 5 | efficiently manipulate large multi-dimensional arrays of arbitrary |
| 6 | records without sacrificing too much speed for small multi-dimensional |
Travis Oliphant | c8b5a7e | 2006-01-06 02:12:50 | [diff] [blame] | 7 | arrays. NumPy is built on the Numeric code base and adds features |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 8 | introduced by numarray as well as an extended C-API and the ability to |
Travis Oliphant | 00a3587 | 2007-05-31 04:57:01 | [diff] [blame] | 9 | create arrays of arbitrary type which also makes NumPy suitable for |
| 10 | interfacing with general-purpose data-base applications. |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 11 | |
| 12 | There are also basic facilities for discrete fourier transform, |
| 13 | basic linear algebra and random number generation. |
| 14 | """ |
| 15 | |
| 16 | DOCLINES = __doc__.split("\n") |
Pearu Peterson | c415fd1 | 2002-11-18 22:39:31 | [diff] [blame] | 17 | |
Fernando Perez | 083ca64 | 2007-12-30 03:04:17 | [diff] [blame] | 18 | import __builtin__ |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 19 | import os |
| 20 | import sys |
David Cournapeau | 5864bd2 | 2009-03-27 16:39:34 | [diff] [blame] | 21 | import re |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 22 | import subprocess |
Pearu Peterson | c415fd1 | 2002-11-18 22:39:31 | [diff] [blame] | 23 | |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 24 | CLASSIFIERS = """\ |
Robert Kern | 19da971 | 2008-06-18 22:53:44 | [diff] [blame] | 25 | Development Status :: 5 - Production/Stable |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 26 | Intended Audience :: Science/Research |
| 27 | Intended Audience :: Developers |
| 28 | License :: OSI Approved |
| 29 | Programming Language :: C |
| 30 | Programming Language :: Python |
| 31 | Topic :: Software Development |
| 32 | Topic :: Scientific/Engineering |
| 33 | Operating System :: Microsoft :: Windows |
| 34 | Operating System :: POSIX |
| 35 | Operating System :: Unix |
| 36 | Operating System :: MacOS |
| 37 | """ |
| 38 | |
David Cournapeau | cc9a446 | 2009-03-27 11:16:13 | [diff] [blame] | 39 | NAME = 'numpy' |
| 40 | MAINTAINER = "NumPy Developers" |
| 41 | MAINTAINER_EMAIL = "numpy-discussion@scipy.org" |
| 42 | DESCRIPTION = DOCLINES[0] |
| 43 | LONG_DESCRIPTION = "\n".join(DOCLINES[2:]) |
| 44 | URL = "http://numpy.scipy.org" |
| 45 | DOWNLOAD_URL = "http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103" |
| 46 | LICENSE = 'BSD' |
| 47 | CLASSIFIERS = filter(None, CLASSIFIERS.split('\n')) |
| 48 | AUTHOR = "Travis E. Oliphant, et.al." |
| 49 | AUTHOR_EMAIL = "oliphant@enthought.com" |
| 50 | PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"] |
David Cournapeau | 5e041cb | 2009-03-27 11:16:01 | [diff] [blame] | 51 | MAJOR = 1 |
| 52 | MINOR = 4 |
rgommers | c7ba500 | 2010-04-18 08:47:19 | [diff] [blame] | 53 | MICRO = 1 |
David Cournapeau | 4b42c8f | 2009-12-28 01:25:08 | [diff] [blame] | 54 | ISRELEASED = True |
rgommers | 351726a | 2010-04-22 10:35:16 | [diff] [blame] | 55 | VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) |
Stefan van der Walt | b9a22d7 | 2009-06-17 14:28:03 | [diff] [blame] | 56 | |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 57 | # Return the svn version as a string, raise a ValueError otherwise |
| 58 | def svn_version(): |
David Cournapeau | 44d92ec | 2009-06-01 05:43:16 | [diff] [blame] | 59 | def _minimal_ext_cmd(cmd): |
| 60 | # construct minimal environment |
| 61 | env = {} |
David Cournapeau | 5032b52 | 2009-09-18 10:10:39 | [diff] [blame] | 62 | for k in ['SYSTEMROOT', 'PATH']: |
| 63 | v = os.environ.get(k) |
| 64 | if v is not None: |
| 65 | env[k] = v |
David Cournapeau | 44d92ec | 2009-06-01 05:43:16 | [diff] [blame] | 66 | # 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 Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 73 | try: |
David Cournapeau | 44d92ec | 2009-06-01 05:43:16 | [diff] [blame] | 74 | out = _minimal_ext_cmd(['svn', 'info']) |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 75 | except OSError: |
David Cournapeau | 44d92ec | 2009-06-01 05:43:16 | [diff] [blame] | 76 | print(" --- Could not run svn info --- ") |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 77 | return "" |
David Cournapeau | 5e041cb | 2009-03-27 11:16:01 | [diff] [blame] | 78 | |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 79 | r = re.compile('Revision: ([0-9]+)') |
Stefan van der Walt | b9a22d7 | 2009-06-17 14:28:03 | [diff] [blame] | 80 | svnver = "" |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 81 | for line in out.split('\n'): |
Stefan van der Walt | b9a22d7 | 2009-06-17 14:28:03 | [diff] [blame] | 82 | m = r.match(line.strip()) |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 83 | if m: |
| 84 | svnver = m.group(1) |
David Cournapeau | 52fb78d | 2009-03-27 18:37:07 | [diff] [blame] | 85 | |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 86 | if not svnver: |
Stefan van der Walt | b9a22d7 | 2009-06-17 14:28:03 | [diff] [blame] | 87 | print("Error while parsing svn version") |
| 88 | |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 89 | return svnver |
David Cournapeau | 5e041cb | 2009-03-27 11:16:01 | [diff] [blame] | 90 | |
David Cournapeau | 5bb1aa5 | 2009-03-27 16:39:01 | [diff] [blame] | 91 | # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly |
| 92 | # update it when the contents of directories change. |
| 93 | if 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 Cournapeau | d8fc4ad | 2009-04-01 16:18:55 | [diff] [blame] | 101 | FULLVERSION = VERSION |
| 102 | if not ISRELEASED: |
| 103 | FULLVERSION += '.dev' |
| 104 | # If in git or something, bypass the svn rev |
| 105 | if os.path.exists('.svn'): |
David Cournapeau | 5623a7c | 2009-04-02 16:21:30 | [diff] [blame] | 106 | FULLVERSION += svn_version() |
David Cournapeau | d8fc4ad | 2009-04-01 16:18:55 | [diff] [blame] | 107 | |
David Cournapeau | a2ac985 | 2009-03-27 11:15:36 | [diff] [blame] | 108 | def write_version_py(filename='numpy/version.py'): |
| 109 | cnt = """ |
David Cournapeau | 914bb15 | 2009-03-27 11:15:47 | [diff] [blame] | 110 | # THIS FILE IS GENERATED FROM NUMPY SETUP.PY |
David Cournapeau | a70c483 | 2009-03-27 12:07:37 | [diff] [blame] | 111 | short_version='%(version)s' |
David Cournapeau | a2ac985 | 2009-03-27 11:15:36 | [diff] [blame] | 112 | version='%(version)s' |
| 113 | release=%(isrelease)s |
| 114 | |
| 115 | if 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 Peterson | 471196b | 2006-03-31 08:59:36 | [diff] [blame] | 134 | def configuration(parent_package='',top_path=None): |
| 135 | from numpy.distutils.misc_util import Configuration |
| 136 | |
Pearu Peterson | 17d7cfe | 2006-04-04 12:26:14 | [diff] [blame] | 137 | config = Configuration(None, parent_package, top_path) |
Pearu Peterson | 471196b | 2006-03-31 08:59:36 | [diff] [blame] | 138 | config.set_options(ignore_setup_xxx_py=True, |
| 139 | assume_default_configuration=True, |
| 140 | delegate_options_to_subpackages=True, |
| 141 | quiet=True) |
Jarrod Millman | 0b77f0e | 2007-10-29 14:58:18 | [diff] [blame] | 142 | |
Pearu Peterson | 471196b | 2006-03-31 08:59:36 | [diff] [blame] | 143 | config.add_subpackage('numpy') |
Jarrod Millman | 0b77f0e | 2007-10-29 14:58:18 | [diff] [blame] | 144 | |
Pearu Peterson | 7b76ca7 | 2007-06-05 18:54:28 | [diff] [blame] | 145 | config.add_data_files(('numpy','*.txt'), |
| 146 | ('numpy','COMPATIBILITY'), |
Pearu Peterson | 7b76ca7 | 2007-06-05 18:54:28 | [diff] [blame] | 147 | ('numpy','site.cfg.example')) |
Pearu Peterson | 17d7cfe | 2006-04-04 12:26:14 | [diff] [blame] | 148 | |
| 149 | config.get_version('numpy/version.py') # sets config.version |
Travis Oliphant | 00a3587 | 2007-05-31 04:57:01 | [diff] [blame] | 150 | |
Pearu Peterson | 471196b | 2006-03-31 08:59:36 | [diff] [blame] | 151 | return config |
| 152 | |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 153 | def setup_package(): |
Travis Oliphant | 14db419 | 2005-09-14 22:08:46 | [diff] [blame] | 154 | |
Travis Oliphant | da9c6da | 2006-01-04 17:31:07 | [diff] [blame] | 155 | from numpy.distutils.core import setup |
Travis Oliphant | 14db419 | 2005-09-14 22:08:46 | [diff] [blame] | 156 | |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 157 | old_path = os.getcwd() |
Pearu Peterson | d190674 | 2003-11-24 22:50:40 | [diff] [blame] | 158 | local_path = os.path.dirname(os.path.abspath(sys.argv[0])) |
| 159 | os.chdir(local_path) |
Travis Oliphant | 14db419 | 2005-09-14 22:08:46 | [diff] [blame] | 160 | sys.path.insert(0,local_path) |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 161 | |
David Cournapeau | a2ac985 | 2009-03-27 11:15:36 | [diff] [blame] | 162 | # Rewrite the version file everytime |
| 163 | if os.path.exists('numpy/version.py'): os.remove('numpy/version.py') |
| 164 | write_version_py() |
| 165 | |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 166 | try: |
Pearu Peterson | 17d7cfe | 2006-04-04 12:26:14 | [diff] [blame] | 167 | setup( |
David Cournapeau | c253b72 | 2009-03-27 11:15:22 | [diff] [blame] | 168 | 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 Peterson | 17d7cfe | 2006-04-04 12:26:14 | [diff] [blame] | 180 | configuration=configuration ) |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 181 | finally: |
| 182 | del sys.path[0] |
| 183 | os.chdir(old_path) |
Travis Oliphant | 14db419 | 2005-09-14 22:08:46 | [diff] [blame] | 184 | return |
Pearu Peterson | c415fd1 | 2002-11-18 22:39:31 | [diff] [blame] | 185 | |
Travis Oliphant | 14db419 | 2005-09-14 22:08:46 | [diff] [blame] | 186 | if __name__ == '__main__': |
Pearu Peterson | e8fa013 | 2003-03-07 18:08:28 | [diff] [blame] | 187 | setup_package() |