18
18
DOCLINES = __doc__ .split ("\n " )
19
19
20
20
import os
21
- import shutil
22
21
import sys
23
- import re
24
22
import subprocess
25
23
24
+
26
25
if sys .version_info [:2 ] < (2 , 6 ) or (3 , 0 ) <= sys .version_info [0 :2 ] < (3 , 2 ):
27
26
raise RuntimeError ("Python version 2.6, 2.7 or >= 3.2 required." )
28
27
31
30
else :
32
31
import __builtin__ as builtins
33
32
33
+
34
34
CLASSIFIERS = """\
35
35
Development Status :: 5 - Production/Stable
36
36
Intended Audience :: Science/Research
47
47
Operating System :: MacOS
48
48
"""
49
49
50
- NAME = 'numpy'
51
- MAINTAINER = "NumPy Developers"
52
- MAINTAINER_EMAIL = "[email protected] "
53
- DESCRIPTION = DOCLINES [0 ]
54
- LONG_DESCRIPTION = "\n " .join (DOCLINES [2 :])
55
- URL = "http://www.numpy.org"
56
- DOWNLOAD_URL = "http://sourceforge.net/projects/numpy/files/NumPy/"
57
- LICENSE = 'BSD'
58
- CLASSIFIERS = [_f for _f in CLASSIFIERS .split ('\n ' ) if _f ]
59
- AUTHOR = "Travis E. Oliphant et al."
60
- AUTHOR_EMAIL = "[email protected] "
61
- PLATFORMS = ["Windows" , "Linux" , "Solaris" , "Mac OS-X" , "Unix" ]
62
50
MAJOR = 1
63
51
MINOR = 9
64
52
MICRO = 0
65
53
ISRELEASED = False
66
54
VERSION = '%d.%d.%d' % (MAJOR , MINOR , MICRO )
67
55
56
+
68
57
# Return the git revision as a string
69
58
def git_version ():
70
59
def _minimal_ext_cmd (cmd ):
@@ -100,18 +89,7 @@ def _minimal_ext_cmd(cmd):
100
89
builtins .__NUMPY_SETUP__ = True
101
90
102
91
103
- def write_version_py (filename = 'numpy/version.py' ):
104
- cnt = """
105
- # THIS FILE IS GENERATED FROM NUMPY SETUP.PY
106
- short_version = '%(version)s'
107
- version = '%(version)s'
108
- full_version = '%(full_version)s'
109
- git_revision = '%(git_revision)s'
110
- release = %(isrelease)s
111
-
112
- if not release:
113
- version = full_version
114
- """
92
+ def get_version_info ():
115
93
# Adding the git rev number needs to be done inside write_version_py(),
116
94
# otherwise the import of numpy.version messes up the build under Python 3.
117
95
FULLVERSION = VERSION
@@ -131,6 +109,23 @@ def write_version_py(filename='numpy/version.py'):
131
109
if not ISRELEASED :
132
110
FULLVERSION += '.dev-' + GIT_REVISION [:7 ]
133
111
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
+
134
129
a = open (filename , 'w' )
135
130
try :
136
131
a .write (cnt % {'version' : VERSION ,
@@ -140,6 +135,7 @@ def write_version_py(filename='numpy/version.py'):
140
135
finally :
141
136
a .close ()
142
137
138
+
143
139
def configuration (parent_package = '' ,top_path = None ):
144
140
from numpy .distutils .misc_util import Configuration
145
141
@@ -155,8 +151,8 @@ def configuration(parent_package='',top_path=None):
155
151
156
152
return config
157
153
158
- def setup_package ():
159
154
155
+ def setup_package ():
160
156
src_path = os .path .dirname (os .path .abspath (sys .argv [0 ]))
161
157
old_path = os .getcwd ()
162
158
os .chdir (src_path )
@@ -165,28 +161,50 @@ def setup_package():
165
161
# Rewrite the version file everytime
166
162
write_version_py ()
167
163
164
+ metadata = dict (
165
+ name = 'numpy' ,
166
+ maintainer = "NumPy Developers" ,
167
+ maintainer_email = "[email protected] " ,
168
+ description = DOCLINES [0 ],
169
+ long_description = "\n " .join (DOCLINES [2 :]),
170
+ url = "http://www.numpy.org" ,
171
+ author = "Travis E. Oliphant et al." ,
172
+ download_url = "http://sourceforge.net/projects/numpy/files/NumPy/" ,
173
+ license = 'BSD' ,
174
+ classifiers = [_f for _f in CLASSIFIERS .split ('\n ' ) if _f ],
175
+ platforms = ["Windows" , "Linux" , "Solaris" , "Mac OS-X" , "Unix" ],
176
+ test_suite = 'nose.collector' ,
177
+ )
178
+
168
179
# Run build
169
- from numpy .distutils .core import setup
180
+ if len (sys .argv ) >= 2 and ('--help' in sys .argv [1 :] or
181
+ sys .argv [1 ] in ('--help-commands' , 'egg_info' , '--version' ,
182
+ 'clean' )):
183
+ # Use setuptools for these commands (they don't work well or at all
184
+ # with distutils). For normal builds use distutils.
185
+ try :
186
+ from setuptools import setup
187
+ except ImportError :
188
+ from distutils .core import setup
189
+
190
+ FULLVERSION , GIT_REVISION = get_version_info ()
191
+ metadata ['version' ] = FULLVERSION
192
+ elif len (sys .argv ) >= 2 and sys .argv [1 ] == 'bdist_wheel' :
193
+ # bdist_wheel needs setuptools
194
+ import setuptools
195
+ from numpy .distutils .core import setup
196
+ metadata ['configuration' ] = configuration
197
+ else :
198
+ from numpy .distutils .core import setup
199
+ metadata ['configuration' ] = configuration
170
200
171
201
try :
172
- setup (
173
- name = NAME ,
174
- maintainer = MAINTAINER ,
175
- maintainer_email = MAINTAINER_EMAIL ,
176
- description = DESCRIPTION ,
177
- long_description = LONG_DESCRIPTION ,
178
- url = URL ,
179
- download_url = DOWNLOAD_URL ,
180
- license = LICENSE ,
181
- classifiers = CLASSIFIERS ,
182
- author = AUTHOR ,
183
- author_email = AUTHOR_EMAIL ,
184
- platforms = PLATFORMS ,
185
- configuration = configuration )
202
+ setup (** metadata )
186
203
finally :
187
204
del sys .path [0 ]
188
205
os .chdir (old_path )
189
206
return
190
207
208
+
191
209
if __name__ == '__main__' :
192
210
setup_package ()
0 commit comments