Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 203 lines (170 sloc) 6.516 kb
36d3c16 @fperez Remove MANIFEST file at startup time, since distutils fails to properly ...
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 extra...
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 setup...
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 setup...
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"]
1fe8136 @rgommers REL: 1.6.x branch created, master open for development of Numpy 2.0
rgommers authored
57 MAJOR = 2
58 MINOR = 0
5e041cb @cournape Add svn parse for the full version.
cournape authored
59 MICRO = 0
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronized e...
cournape authored
60 ISRELEASED = False
5e041cb @cournape Add svn parse for the full version.
cournape 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 properly ...
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 synchronized e...
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 synchronized e...
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 synchronized e...
cournape authored
109 """
87e12c1 @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
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
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronized e...
cournape authored
124 a = open(filename, 'w')
125 try:
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
126 a.write(cnt % {'version': VERSION,
13212a5 @rgommers BUG: fix up setup.py and pavement.py so the binary builds work again.
rgommers authored
127 'full_version' : FULLVERSION,
58e6360 @scottza ENH: Add Git revision hash to numpy dev version string
scottza authored
128 'git_revision' : GIT_REVISION,
129 'isrelease': str(ISRELEASED)})
a2ac985 @cournape Generate the version.py file, to help keeping the version synchronized e...
cournape authored
130 finally:
131 a.close()
132
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted lo...
pearu authored
133 def configuration(parent_package='',top_path=None):
134 from numpy.distutils.misc_util import Configuration
135
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
136 config = Configuration(None, parent_package, top_path)
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted lo...
pearu authored
137 config.set_options(ignore_setup_xxx_py=True,
138 assume_default_configuration=True,
139 delegate_options_to_subpackages=True,
140 quiet=True)
0b77f0e @jarrodmillman ran reindent.py to clean up whitespace
jarrodmillman authored
141
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted lo...
pearu authored
142 config.add_subpackage('numpy')
0b77f0e @jarrodmillman ran reindent.py to clean up whitespace
jarrodmillman authored
143
9752b73 @rgommers Add doc/swig, doc/cython and doc/pyrex dirs back. Closes #1088.
rgommers authored
144 # we want these files also in binaries/installed files, so it belongs here
145 # instead of in Manifest.in
146 config.add_data_files(('doc/cython/'),
147 ('doc/pyrex/'),
148 ('doc/swig/'))
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 extra...
Travis Oliphant authored
151
471196b @pearu Introduced configuration kw argument to setup. This fixes long lasted lo...
pearu authored
152 return config
153
14db419 Fixing for new distutils
Travis Oliphant authored
154 def setup_package():
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of setup...
pearu authored
155
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
156 # Perform 2to3 if needed
157 local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
158 src_path = local_path
159
160 if sys.version_info[0] == 3:
161 src_path = os.path.join(local_path, 'build', 'py3k')
162 sys.path.insert(0, os.path.join(local_path, 'tools'))
163 import py3tool
164 print("Converting to Python3 via 2to3...")
165 py3tool.sync_2to3('numpy', os.path.join(src_path, 'numpy'))
166
167 site_cfg = os.path.join(local_path, 'site.cfg')
168 if os.path.isfile(site_cfg):
169 shutil.copy(site_cfg, src_path)
170
171 old_path = os.getcwd()
172 os.chdir(src_path)
173 sys.path.insert(0, src_path)
174
0131218 @pv BUG: setup.py: write version.py only after switching to Py3 build dir
pv authored
175 # Rewrite the version file everytime
176 write_version_py()
177
178 # Run build
6815943 @pv 3K: make setup.py call 2to3 automatically -- place sources to build/py3k
pv authored
179 from numpy.distutils.core import setup
180
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
181 try:
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
182 setup(
c253b72 @cournape Use global for distutils metat-data, so that we can pull them from paver...
cournape authored
183 name=NAME,
184 maintainer=MAINTAINER,
185 maintainer_email=MAINTAINER_EMAIL,
186 description=DESCRIPTION,
187 long_description=LONG_DESCRIPTION,
188 url=URL,
189 download_url=DOWNLOAD_URL,
190 license=LICENSE,
191 classifiers=CLASSIFIERS,
192 author=AUTHOR,
193 author_email=AUTHOR_EMAIL,
194 platforms=PLATFORMS,
17d7cfe @pearu Fix version machinery and pkg information requests.
pearu authored
195 configuration=configuration )
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
196 finally:
197 del sys.path[0]
198 os.chdir(old_path)
14db419 Fixing for new distutils
Travis Oliphant authored
199 return
c415fd1 @pearu Bundle scipy_test,scipy_distutils to scipy_core. See the header of setup...
pearu authored
200
14db419 Fixing for new distutils
Travis Oliphant authored
201 if __name__ == '__main__':
e8fa013 @pearu scipy_core package is now functional. Usage:
pearu authored
202 setup_package()
Something went wrong with that request. Please try again.