Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 215 lines (182 sloc) 7.233 kB
36d3c16 @fperez Remove MANIFEST file at startup time, since distutils fails to proper…
fperez authored
1 #!/usr/bin/env python
c8b5a7e Fixed error in setflags and added a few unit tests for test_multiarray
Travis Oliphant authored
2 """NumPy: array processing for numbers, strings, records, and objects.
da9c6da Fix-up setup.py
Travis Oliphant authored
3
c8b5a7e Fixed error in setflags and added a few unit tests for test_multiarray
Travis Oliphant authored
4 NumPy is a general-purpose array-processing package designed to
da9c6da Fix-up setup.py
Travis Oliphant authored
5 efficiently manipulate large multi-dimensional arrays of arbitrary
6 records without sacrificing too much speed for small multi-dimensional
c8b5a7e Fixed error in setflags and added a few unit tests for test_multiarray
Travis Oliphant authored
7 arrays. NumPy is built on the Numeric code base and adds features
da9c6da Fix-up setup.py
Travis Oliphant authored
8 introduced by numarray as well as an extended C-API and the ability to
00a3587 Fix some problems with data-files not being added in top-level and ex…
Travis Oliphant authored
9 create arrays of arbitrary type which also makes NumPy suitable for
10 interfacing with general-purpose data-base applications.
da9c6da Fix-up setup.py
Travis Oliphant authored
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")
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
17
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
18 import os
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
19 import shutil
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
20 import sys
5864bd2 @cournape ... and re
cournape authored
21 import re
5623a7c @cournape Revert using setuptools svn revision, it is broken.
cournape authored
22 import subprocess
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
23
2b51769 @cournape Fix __builtin__ import for python3 at top setup.py.
cournape authored
24 if sys.version_info[0] < 3:
25 import __builtin__ as builtins
26 else:
27 import builtins
28
da9c6da Fix-up setup.py
Travis Oliphant authored
29 CLASSIFIERS = """\
19da971 @rkern PyPI metadata fixes.
rkern authored
30 Development Status :: 5 - Production/Stable
da9c6da Fix-up setup.py
Travis Oliphant authored
31 Intended Audience :: Science/Research
32 Intended Audience :: Developers
33 License :: OSI Approved
34 Programming Language :: C
35 Programming Language :: Python
cdac120 @rgommers PY3K: add PyPI classifier for Python 3. Closes #1698.
rgommers authored
36 Programming Language :: Python :: 3
da9c6da Fix-up setup.py
Travis Oliphant authored
37 Topic :: Software Development
38 Topic :: Scientific/Engineering
39 Operating System :: Microsoft :: Windows
40 Operating System :: POSIX
41 Operating System :: Unix
42 Operating System :: MacOS
43 """
44
cc9a446 @cournape Fix metadata incorrectly defined as tuples.
cournape authored
45 NAME = 'numpy'
46 MAINTAINER = "NumPy Developers"
47 MAINTAINER_EMAIL = "numpy-discussion@scipy.org"
48 DESCRIPTION = DOCLINES[0]
49 LONG_DESCRIPTION = "\n".join(DOCLINES[2:])
50 URL = "http://numpy.scipy.org"
51 DOWNLOAD_URL = "http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103"
52 LICENSE = 'BSD'
53 CLASSIFIERS = filter(None, CLASSIFIERS.split('\n'))
54 AUTHOR = "Travis E. Oliphant, et.al."
55 AUTHOR_EMAIL = "oliphant@enthought.com"
56 PLATFORMS = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"]
82bd8f9 @mwiebe VER: Change version to 1.6.0
mwiebe authored
57 MAJOR = 1
58 MINOR = 6
903d9b7 @rgommers MAINT: set version to 1.6.3-dev
rgommers authored
59 MICRO = 3
60 ISRELEASED = False
ca07bce @rgommers REL: set version to 1.6.2.
rgommers authored
61 VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
b9a22d7 @stefanv Continue building even if svn revision detection breaks.
stefanv authored
62
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
63 # Return the git revision as a string
64 def git_version():
44d92ec @cournape BUG #1100: fix svn version detection for localized environments.
cournape authored
65 def _minimal_ext_cmd(cmd):
66 # construct minimal environment
67 env = {}
5032b52 @cournape Fix svn revision parsing under win32.
cournape authored
68 for k in ['SYSTEMROOT', 'PATH']:
69 v = os.environ.get(k)
70 if v is not None:
71 env[k] = v
44d92ec @cournape BUG #1100: fix svn version detection for localized environments.
cournape authored
72 # 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
5623a7c @cournape Revert using setuptools svn revision, it is broken.
cournape authored
79 try:
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
80 out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
d1a184c @pv BUG: setup.py: make git_version() work on Python 3
pv authored
81 GIT_REVISION = out.strip().decode('ascii')
5623a7c @cournape Revert using setuptools svn revision, it is broken.
cournape authored
82 except OSError:
d5ed744 @scottza ENH: Use seven character git hash for dev version string
scottza authored
83 GIT_REVISION = "Unknown"
5bb1aa5 @cournape Fix svn version detection.
cournape authored
84
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
85 return GIT_REVISION
5bb1aa5 @cournape Fix svn version detection.
cournape authored
86
36d3c16 @fperez Remove MANIFEST file at startup time, since distutils fails to proper…
fperez authored
87 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
88 # update it when the contents of directories change.
89 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
90
083ca64 @fperez Modify the setup routine to indicate that it is being run via a system
fperez authored
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.
2b51769 @cournape Fix __builtin__ import for python3 at top setup.py.
cournape authored
95 builtins.__NUMPY_SETUP__ = True
083ca64 @fperez Modify the setup routine to indicate that it is being run via a system
fperez authored
96
13212a5 @rgommers BUG: fix up setup.py and pavement.py so the binary builds work again.
rgommers authored
97
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronize…
cournape authored
98 def write_version_py(filename='numpy/version.py'):
99 cnt = """
914bb15 @cournape Mention that version.py file is now generated.
cournape authored
100 # THIS FILE IS GENERATED FROM NUMPY SETUP.PY
0502dab @scottza REF: Make version.py more readable
scottza authored
101 short_version = '%(version)s'
102 version = '%(version)s'
103 full_version = '%(full_version)s'
104 git_revision = '%(git_revision)s'
105 release = %(isrelease)s
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronize…
cournape authored
106
107 if not release:
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
108 version = full_version
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronize…
cournape authored
109 """
4ff55f0 @rgommers BUG: Py3K: fix setup.py to work from a released tarball.
rgommers authored
110 # 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
ef3f401 @rgommers BLD: raise a clearer warning in case of building without cleaning up …
rgommers authored
117 try:
118 from numpy.version import git_revision as GIT_REVISION
119 except ImportError:
120 raise ImportError("Unable to import git_revision. Try removing " \
121 "numpy/version.py and the build directory " \
122 "before building.")
4ff55f0 @rgommers BUG: Py3K: fix setup.py to work from a released tarball.
rgommers authored
123 else:
124 GIT_REVISION = "Unknown"
125
126 if not ISRELEASED:
127 FULLVERSION += '.dev-' + GIT_REVISION[:7]
128
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronize…
cournape authored
129 a = open(filename, 'w')
130 try:
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
131 a.write(cnt % {'version': VERSION,
13212a5 @rgommers BUG: fix up setup.py and pavement.py so the binary builds work again.
rgommers authored
132 'full_version' : FULLVERSION,
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
133 'git_revision' : GIT_REVISION,
134 'isrelease': str(ISRELEASED)})
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronize…
cournape authored
135 finally:
136 a.close()
137
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
138 def configuration(parent_package='',top_path=None):
139 from numpy.distutils.misc_util import Configuration
140
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
141 config = Configuration(None, parent_package, top_path)
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
142 config.set_options(ignore_setup_xxx_py=True,
143 assume_default_configuration=True,
144 delegate_options_to_subpackages=True,
145 quiet=True)
0b77f0e @jarrodmillman ran reindent.py to clean up whitespace
jarrodmillman authored
146
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
147 config.add_subpackage('numpy')
0b77f0e @jarrodmillman ran reindent.py to clean up whitespace
jarrodmillman authored
148
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
149 config.get_version('numpy/version.py') # sets config.version
00a3587 Fix some problems with data-files not being added in top-level and ex…
Travis Oliphant authored
150
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
151 return config
152
14db419 Fixing for new distutils
Travis Oliphant authored
153 def setup_package():
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
154
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
155 # Perform 2to3 if needed
156 local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
157 src_path = local_path
158
159 if sys.version_info[0] == 3:
160 src_path = os.path.join(local_path, 'build', 'py3k')
161 sys.path.insert(0, os.path.join(local_path, 'tools'))
162 import py3tool
163 print("Converting to Python3 via 2to3...")
164 py3tool.sync_2to3('numpy', os.path.join(src_path, 'numpy'))
165
166 site_cfg = os.path.join(local_path, 'site.cfg')
167 if os.path.isfile(site_cfg):
168 shutil.copy(site_cfg, src_path)
169
6fbddd9 @rgommers BLD: fix build for py3k + pip. Closes #1857. Thanks to Erik Bray.
rgommers authored
170 # Ugly hack to make pip work with Python 3, see #1857.
171 # Explanation: pip messes with __file__ which interacts badly with the
172 # change in directory due to the 2to3 conversion. Therefore we restore
173 # __file__ to what it would have been otherwise.
174 global __file__
175 __file__ = os.path.join(os.curdir, os.path.basename(__file__))
176 if '--egg-base' in sys.argv:
177 # Change pip-egg-info entry to absolute path, so pip can find it
178 # after changing directory.
179 idx = sys.argv.index('--egg-base')
180 if sys.argv[idx + 1] == 'pip-egg-info':
181 sys.argv[idx + 1] = os.path.join(local_path, 'pip-egg-info')
182
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
183 old_path = os.getcwd()
184 os.chdir(src_path)
185 sys.path.insert(0, src_path)
186
0131218 @pv BUG: setup.py: write version.py only after switching to Py3 build dir
pv authored
187 # Rewrite the version file everytime
188 write_version_py()
189
190 # Run build
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
191 from numpy.distutils.core import setup
192
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
193 try:
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
194 setup(
c253b72 @cournape Use global for distutils metat-data, so that we can pull them from pa…
cournape authored
195 name=NAME,
196 maintainer=MAINTAINER,
197 maintainer_email=MAINTAINER_EMAIL,
198 description=DESCRIPTION,
199 long_description=LONG_DESCRIPTION,
200 url=URL,
201 download_url=DOWNLOAD_URL,
202 license=LICENSE,
203 classifiers=CLASSIFIERS,
204 author=AUTHOR,
205 author_email=AUTHOR_EMAIL,
206 platforms=PLATFORMS,
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
207 configuration=configuration )
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
208 finally:
209 del sys.path[0]
210 os.chdir(old_path)
14db419 Fixing for new distutils
Travis Oliphant authored
211 return
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
212
14db419 Fixing for new distutils
Travis Oliphant authored
213 if __name__ == '__main__':
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
214 setup_package()
Something went wrong with that request. Please try again.