Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 253 lines (208 sloc) 8.298 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.
6aa264c @charris 2to3: Put `from __future__ import division in every python file.
charris authored
14
da9c6da Fix-up setup.py
Travis Oliphant authored
15 """
bb726ca @charris 2to3: Apply `print` fixer.
charris authored
16 from __future__ import division, print_function
da9c6da Fix-up setup.py
Travis Oliphant authored
17
18 DOCLINES = __doc__.split("\n")
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
19
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
20 import os
21 import sys
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
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
24
28eadc0 @charris MAINT: Remove outdated version checks.
charris authored
25 if sys.version_info[:2] < (2, 6) or (3, 0) <= sys.version_info[0:2] < (3, 2):
26 raise RuntimeError("Python version 2.6, 2.7 or >= 3.2 required.")
27
09a52ed @charris 2to3: Apply `imports` fixer.
charris authored
28 if sys.version_info[0] >= 3:
2b51769 @cournape Fix __builtin__ import for python3 at top setup.py.
cournape authored
29 import builtins
09a52ed @charris 2to3: Apply `imports` fixer.
charris authored
30 else:
31 import __builtin__ as builtins
2b51769 @cournape Fix __builtin__ import for python3 at top setup.py.
cournape authored
32
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
33
da9c6da Fix-up setup.py
Travis Oliphant authored
34 CLASSIFIERS = """\
19da971 @rkern PyPI metadata fixes.
rkern authored
35 Development Status :: 5 - Production/Stable
da9c6da Fix-up setup.py
Travis Oliphant authored
36 Intended Audience :: Science/Research
37 Intended Audience :: Developers
38 License :: OSI Approved
39 Programming Language :: C
40 Programming Language :: Python
cdac120 @rgommers PY3K: add PyPI classifier for Python 3. Closes #1698.
rgommers authored
41 Programming Language :: Python :: 3
da9c6da Fix-up setup.py
Travis Oliphant authored
42 Topic :: Software Development
43 Topic :: Scientific/Engineering
44 Operating System :: Microsoft :: Windows
45 Operating System :: POSIX
46 Operating System :: Unix
47 Operating System :: MacOS
48 """
49
58c1bf7 @rgommers BUG: fix download link in setup.py (which is shown on PyPi).
rgommers authored
50 MAJOR = 1
6f5329f @charris MAINT: start 1.10-devel.
charris authored
51 MINOR = 10
5e041cb @cournape Add svn parse for the full version.
cournape authored
52 MICRO = 0
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronize…
cournape authored
53 ISRELEASED = False
5e041cb @cournape Add svn parse for the full version.
cournape authored
54 VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
b9a22d7 @stefanv Continue building even if svn revision detection breaks.
stefanv authored
55
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
56
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
57 # Return the git revision as a string
58 def git_version():
44d92ec @cournape BUG #1100: fix svn version detection for localized environments.
cournape authored
59 def _minimal_ext_cmd(cmd):
60 # construct minimal environment
61 env = {}
5032b52 @cournape Fix svn revision parsing under win32.
cournape authored
62 for k in ['SYSTEMROOT', 'PATH']:
63 v = os.environ.get(k)
64 if v is not None:
65 env[k] = v
44d92ec @cournape BUG #1100: fix svn version detection for localized environments.
cournape authored
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
5623a7c @cournape Revert using setuptools svn revision, it is broken.
cournape authored
73 try:
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
74 out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
d1a184c @pv BUG: setup.py: make git_version() work on Python 3
pv authored
75 GIT_REVISION = out.strip().decode('ascii')
5623a7c @cournape Revert using setuptools svn revision, it is broken.
cournape authored
76 except OSError:
d5ed744 @scottza ENH: Use seven character git hash for dev version string
scottza authored
77 GIT_REVISION = "Unknown"
5bb1aa5 @cournape Fix svn version detection.
cournape authored
78
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
79 return GIT_REVISION
5bb1aa5 @cournape Fix svn version detection.
cournape authored
80
36d3c16 @fperez Remove MANIFEST file at startup time, since distutils fails to proper…
fperez authored
81 # BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
82 # update it when the contents of directories change.
83 if os.path.exists('MANIFEST'): os.remove('MANIFEST')
84
083ca64 @fperez Modify the setup routine to indicate that it is being run via a system
fperez authored
85 # This is a bit hackish: we are setting a global variable so that the main
86 # numpy __init__ can detect if it is being loaded by the setup routine, to
87 # avoid attempting to load components that aren't built yet. While ugly, it's
88 # a lot more robust than what was previously being used.
2b51769 @cournape Fix __builtin__ import for python3 at top setup.py.
cournape authored
89 builtins.__NUMPY_SETUP__ = True
083ca64 @fperez Modify the setup routine to indicate that it is being run via a system
fperez authored
90
13212a5 @rgommers BUG: fix up setup.py and pavement.py so the binary builds work again.
rgommers authored
91
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
92 def get_version_info():
87e12c1 @rgommers BUG: Py3K: fix setup.py to work from a released tarball.
rgommers authored
93 # Adding the git rev number needs to be done inside write_version_py(),
94 # otherwise the import of numpy.version messes up the build under Python 3.
95 FULLVERSION = VERSION
96 if os.path.exists('.git'):
97 GIT_REVISION = git_version()
98 elif os.path.exists('numpy/version.py'):
99 # must be a source distribution, use existing version file
cd6d53f @rgommers BLD: raise a clearer warning in case of building without cleaning up …
rgommers authored
100 try:
101 from numpy.version import git_revision as GIT_REVISION
102 except ImportError:
103 raise ImportError("Unable to import git_revision. Try removing " \
104 "numpy/version.py and the build directory " \
105 "before building.")
87e12c1 @rgommers BUG: Py3K: fix setup.py to work from a released tarball.
rgommers authored
106 else:
107 GIT_REVISION = "Unknown"
108
109 if not ISRELEASED:
e15f292 @ahjulstad Change to fully PEP440 compliant dev version numbers (always .dev0)
ahjulstad authored
110 FULLVERSION += '.dev0+' + GIT_REVISION[:7]
87e12c1 @rgommers BUG: Py3K: fix setup.py to work from a released tarball.
rgommers authored
111
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
112 return FULLVERSION, GIT_REVISION
113
114
115 def write_version_py(filename='numpy/version.py'):
116 cnt = """
117 # THIS FILE IS GENERATED FROM NUMPY SETUP.PY
118 short_version = '%(version)s'
119 version = '%(version)s'
120 full_version = '%(full_version)s'
121 git_revision = '%(git_revision)s'
122 release = %(isrelease)s
123
124 if not release:
125 version = full_version
126 """
127 FULLVERSION, GIT_REVISION = get_version_info()
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
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
138
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
139 def configuration(parent_package='',top_path=None):
140 from numpy.distutils.misc_util import Configuration
141
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
142 config = Configuration(None, parent_package, top_path)
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
143 config.set_options(ignore_setup_xxx_py=True,
144 assume_default_configuration=True,
145 delegate_options_to_subpackages=True,
146 quiet=True)
0b77f0e @jarrodmillman ran reindent.py to clean up whitespace
jarrodmillman authored
147
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
148 config.add_subpackage('numpy')
0b77f0e @jarrodmillman ran reindent.py to clean up whitespace
jarrodmillman authored
149
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
150 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
151
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted…
pearu authored
152 return config
153
4cd7274 @juliantaylor BLD: check submodules on sdist
juliantaylor authored
154 def check_submodules():
155 """ verify that the submodules are checked out and clean
156 use `git submodule update --init`; on failure
157 """
158 if not os.path.exists('.git'):
159 return
160 with open('.gitmodules') as f:
161 for l in f:
162 if 'path' in l:
163 p = l.split('=')[-1].strip()
164 if not os.path.exists(p):
165 raise ValueError('Submodule %s missing' % p)
166
167
168 proc = subprocess.Popen(['git', 'submodule', 'status'],
169 stdout=subprocess.PIPE)
170 status, _ = proc.communicate()
171 status = status.decode("ascii", "replace")
172 for line in status.splitlines():
173 if line.startswith('-') or line.startswith('+'):
174 raise ValueError('Submodule not clean: %s' % line)
175
176 from distutils.command.sdist import sdist
177 class sdist_checked(sdist):
178 """ check submodules on sdist to prevent incomplete tarballs """
179 def run(self):
180 check_submodules()
181 sdist.run(self)
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
182
c9fd634 @juliantaylor BLD: remove cython c source from git
juliantaylor authored
183 def generate_cython():
184 cwd = os.path.abspath(os.path.dirname(__file__))
185 print("Cythonizing sources")
186 p = subprocess.call([sys.executable,
187 os.path.join(cwd, 'tools', 'cythonize.py'),
188 'numpy/random'],
189 cwd=cwd)
190 if p != 0:
191 raise RuntimeError("Running cythonize failed!")
192
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
193 def setup_package():
b4180e3 @charris 2to3: Stop using 2to3 and remove the tools/py3tool.py file.
charris authored
194 src_path = os.path.dirname(os.path.abspath(sys.argv[0]))
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
195 old_path = os.getcwd()
196 os.chdir(src_path)
197 sys.path.insert(0, src_path)
198
0131218 @pv BUG: setup.py: write version.py only after switching to Py3 build dir
pv authored
199 # Rewrite the version file everytime
200 write_version_py()
201
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
202 metadata = dict(
203 name = 'numpy',
204 maintainer = "NumPy Developers",
205 maintainer_email = "numpy-discussion@scipy.org",
206 description = DOCLINES[0],
207 long_description = "\n".join(DOCLINES[2:]),
208 url = "http://www.numpy.org",
209 author = "Travis E. Oliphant et al.",
210 download_url = "http://sourceforge.net/projects/numpy/files/NumPy/",
211 license = 'BSD',
212 classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
213 platforms = ["Windows", "Linux", "Solaris", "Mac OS-X", "Unix"],
214 test_suite='nose.collector',
4cd7274 @juliantaylor BLD: check submodules on sdist
juliantaylor authored
215 cmdclass={"sdist": sdist_checked},
ae438c3 @carlkl BLD: Add mingw-w64 support for the mingw64static option.
carlkl authored
216 package_data={'numpy.core': ['libopenblaspy.dll']},
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
217 )
218
0131218 @pv BUG: setup.py: write version.py only after switching to Py3 build dir
pv authored
219 # Run build
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
220 if len(sys.argv) >= 2 and ('--help' in sys.argv[1:] or
221 sys.argv[1] in ('--help-commands', 'egg_info', '--version',
222 'clean')):
223 # Use setuptools for these commands (they don't work well or at all
224 # with distutils). For normal builds use distutils.
225 try:
226 from setuptools import setup
227 except ImportError:
228 from distutils.core import setup
229
230 FULLVERSION, GIT_REVISION = get_version_info()
231 metadata['version'] = FULLVERSION
232 else:
99cbdba @matthew-brett BUG: cythonize sources for wheel build
matthew-brett authored
233 if len(sys.argv) >= 2 and sys.argv[1] == 'bdist_wheel':
234 # bdist_wheel needs setuptools
235 import setuptools
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
236 from numpy.distutils.core import setup
c9fd634 @juliantaylor BLD: remove cython c source from git
juliantaylor authored
237 cwd = os.path.abspath(os.path.dirname(__file__))
238 if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
239 # Generate Cython sources, unless building from source release
240 generate_cython()
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
241 metadata['configuration'] = configuration
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
242
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
243 try:
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
244 setup(**metadata)
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
245 finally:
246 del sys.path[0]
247 os.chdir(old_path)
14db419 Fixing for new distutils
Travis Oliphant authored
248 return
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of se…
pearu authored
249
17716d7 @rgommers MAINT: setup.py improvements - allow some setuptools commands to work.
rgommers authored
250
14db419 Fixing for new distutils
Travis Oliphant authored
251 if __name__ == '__main__':
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
252 setup_package()
Something went wrong with that request. Please try again.