13
13
import re
14
14
from distutils .version import LooseVersion
15
15
16
+ # versioning
17
+ import versioneer
18
+ cmdclass = versioneer .get_cmdclass ()
19
+
16
20
# may need to work around setuptools bug by providing a fake Pyrex
17
21
min_cython_ver = '0.19.1'
18
22
try :
74
78
75
79
from distutils .extension import Extension
76
80
from distutils .command .build import build
77
- from distutils .command .sdist import sdist
78
81
from distutils .command .build_ext import build_ext as _build_ext
79
82
80
83
try :
@@ -191,76 +194,6 @@ def build_extensions(self):
191
194
'Topic :: Scientific/Engineering' ,
192
195
]
193
196
194
- MAJOR = 0
195
- MINOR = 16
196
- MICRO = 2
197
- ISRELEASED = False
198
- VERSION = '%d.%d.%d' % (MAJOR , MINOR , MICRO )
199
- QUALIFIER = ''
200
-
201
- FULLVERSION = VERSION
202
- write_version = True
203
-
204
- if not ISRELEASED :
205
- import subprocess
206
- FULLVERSION += '.dev'
207
-
208
- pipe = None
209
- for cmd in ['git' ,'git.cmd' ]:
210
- try :
211
- pipe = subprocess .Popen ([cmd , "describe" , "--always" , "--match" , "v[0-9]*" ],
212
- stdout = subprocess .PIPE )
213
- (so ,serr ) = pipe .communicate ()
214
- if pipe .returncode == 0 :
215
- break
216
- except :
217
- pass
218
-
219
- if pipe is None or pipe .returncode != 0 :
220
- # no git, or not in git dir
221
- if os .path .exists ('pandas/version.py' ):
222
- warnings .warn ("WARNING: Couldn't get git revision, using existing pandas/version.py" )
223
- write_version = False
224
- else :
225
- warnings .warn ("WARNING: Couldn't get git revision, using generic version string" )
226
- else :
227
- # have git, in git dir, but may have used a shallow clone (travis does this)
228
- rev = so .strip ()
229
- # makes distutils blow up on Python 2.7
230
- if sys .version_info [0 ] >= 3 :
231
- rev = rev .decode ('ascii' )
232
-
233
- if not rev .startswith ('v' ) and re .match ("[a-zA-Z0-9]{7,9}" ,rev ):
234
- # partial clone, manually construct version string
235
- # this is the format before we started using git-describe
236
- # to get an ordering on dev version strings.
237
- rev = "v%s.dev-%s" % (VERSION , rev )
238
-
239
- # Strip leading v from tags format "vx.y.z" to get th version string
240
- FULLVERSION = rev .lstrip ('v' )
241
-
242
- else :
243
- FULLVERSION += QUALIFIER
244
-
245
-
246
- def write_version_py (filename = None ):
247
- cnt = """\
248
- version = '%s'
249
- short_version = '%s'
250
- """
251
- if not filename :
252
- filename = os .path .join (
253
- os .path .dirname (__file__ ), 'pandas' , 'version.py' )
254
-
255
- a = open (filename , 'w' )
256
- try :
257
- a .write (cnt % (FULLVERSION , VERSION ))
258
- finally :
259
- a .close ()
260
-
261
- if write_version :
262
- write_version_py ()
263
-
264
197
class CleanCommand (Command ):
265
198
"""Custom distutils command to clean the .so and .pyc files."""
266
199
@@ -323,7 +256,11 @@ def run(self):
323
256
pass
324
257
325
258
326
- class CheckSDist (sdist ):
259
+ # we need to inherit from the versioneer
260
+ # class as it encodes the version info
261
+ sdist_class = cmdclass ['sdist' ]
262
+
263
+ class CheckSDist (sdist_class ):
327
264
"""Custom sdist that ensures Cython has compiled all pyx files to c."""
328
265
329
266
_pyxfiles = ['pandas/lib.pyx' ,
@@ -336,7 +273,7 @@ class CheckSDist(sdist):
336
273
'pandas/src/testing.pyx' ]
337
274
338
275
def initialize_options (self ):
339
- sdist .initialize_options (self )
276
+ sdist_class .initialize_options (self )
340
277
341
278
'''
342
279
self._pyxfiles = []
@@ -355,7 +292,7 @@ def run(self):
355
292
msg = "C-source file '%s' not found." % (cfile ) + \
356
293
" Run 'setup.py cython' before sdist."
357
294
assert os .path .isfile (cfile ), msg
358
- sdist .run (self )
295
+ sdist_class .run (self )
359
296
360
297
361
298
class CheckingBuildExt (build_ext ):
@@ -397,9 +334,8 @@ def finalize_options(self):
397
334
def run (self ):
398
335
pass
399
336
400
- cmdclass = {'clean' : CleanCommand ,
401
- 'build' : build ,
402
- 'sdist' : CheckSDist }
337
+ cmdclass .update ({'clean' : CleanCommand ,
338
+ 'build' : build })
403
339
404
340
try :
405
341
from wheel .bdist_wheel import bdist_wheel
@@ -575,8 +511,8 @@ def pxd(name):
575
511
# if you change something, be careful.
576
512
577
513
setup (name = DISTNAME ,
578
- version = FULLVERSION ,
579
514
maintainer = AUTHOR ,
515
+ version = versioneer .get_version (),
580
516
packages = ['pandas' ,
581
517
'pandas.compat' ,
582
518
'pandas.computation' ,
0 commit comments