10
10
import sys
11
11
import shutil
12
12
import warnings
13
+ import re
13
14
14
15
# may need to work around setuptools bug by providing a fake Pyrex
15
16
try :
@@ -196,6 +197,8 @@ def build_extensions(self):
196
197
QUALIFIER = ''
197
198
198
199
FULLVERSION = VERSION
200
+ write_version = True
201
+
199
202
if not ISRELEASED :
200
203
import subprocess
201
204
FULLVERSION += '.dev'
@@ -212,14 +215,26 @@ def build_extensions(self):
212
215
pass
213
216
214
217
if pipe is None or pipe .returncode != 0 :
215
- warnings .warn ("WARNING: Couldn't get git revision, using generic version string" )
218
+ # no git, or not in git dir
219
+ if os .path .exists ('pandas/version.py' ):
220
+ warnings .warn ("WARNING: Couldn't get git revision, using existing pandas/version.py" )
221
+ write_version = False
222
+ else :
223
+ warnings .warn ("WARNING: Couldn't get git revision, using generic version string" )
216
224
else :
225
+ # have git, in git dir, but may have used a shallow clone (travis does this)
217
226
rev = so .strip ()
218
227
# makes distutils blow up on Python 2.7
219
228
if sys .version_info [0 ] >= 3 :
220
229
rev = rev .decode ('ascii' )
221
230
222
- # use result of git describe as version string
231
+ if not rev .startswith ('v' ) and re .match ("[a-zA-Z0-9]{7,9}" ,rev ):
232
+ # partial clone, manually construct version string
233
+ # this is the format before we started using git-describe
234
+ # to get an ordering on dev version strings.
235
+ rev = "v%s.dev-%s" % (VERSION , rev )
236
+
237
+ # Strip leading v from tags format "vx.y.z" to get th version string
223
238
FULLVERSION = rev .lstrip ('v' )
224
239
225
240
else :
@@ -241,6 +256,8 @@ def write_version_py(filename=None):
241
256
finally :
242
257
a .close ()
243
258
259
+ if write_version :
260
+ write_version_py ()
244
261
245
262
class CleanCommand (Command ):
246
263
"""Custom distutils command to clean the .so and .pyc files."""
@@ -527,8 +544,6 @@ def pxd(name):
527
544
if _have_setuptools :
528
545
setuptools_kwargs ["test_suite" ] = "nose.collector"
529
546
530
- write_version_py ()
531
-
532
547
# The build cache system does string matching below this point.
533
548
# if you change something, be careful.
534
549
0 commit comments