1010import sys
1111import shutil
1212import warnings
13+ import re
1314
1415# may need to work around setuptools bug by providing a fake Pyrex
1516try :
@@ -196,6 +197,8 @@ def build_extensions(self):
196197QUALIFIER = ''
197198
198199FULLVERSION = VERSION
200+ write_version = True
201+
199202if not ISRELEASED :
200203 import subprocess
201204 FULLVERSION += '.dev'
@@ -212,14 +215,26 @@ def build_extensions(self):
212215 pass
213216
214217 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" )
216224 else :
225+ # have git, in git dir, but may have used a shallow clone (travis does this)
217226 rev = so .strip ()
218227 # makes distutils blow up on Python 2.7
219228 if sys .version_info [0 ] >= 3 :
220229 rev = rev .decode ('ascii' )
221230
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
223238 FULLVERSION = rev .lstrip ('v' )
224239
225240else :
@@ -241,6 +256,8 @@ def write_version_py(filename=None):
241256 finally :
242257 a .close ()
243258
259+ if write_version :
260+ write_version_py ()
244261
245262class CleanCommand (Command ):
246263 """Custom distutils command to clean the .so and .pyc files."""
@@ -527,8 +544,6 @@ def pxd(name):
527544if _have_setuptools :
528545 setuptools_kwargs ["test_suite" ] = "nose.collector"
529546
530- write_version_py ()
531-
532547# The build cache system does string matching below this point.
533548# if you change something, be careful.
534549
0 commit comments