Skip to content

Commit 42a910c

Browse files
author
y-p
committed
Merge pull request #6217 from y-p/PR_setuppy_version
BLD: setup.py version strings. handle shallow clones and installing from sdist
2 parents 185b3f1 + f3c44d8 commit 42a910c

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Improvements to existing features
6767
Bug Fixes
6868
~~~~~~~~~
6969

70+
- Bug in version string gen. for dev versions with shallow clones / install from tarball (:issue:`6127`)
71+
7072
pandas 0.13.1
7173
-------------
7274

setup.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import shutil
1212
import warnings
13+
import re
1314

1415
# may need to work around setuptools bug by providing a fake Pyrex
1516
try:
@@ -196,6 +197,8 @@ def build_extensions(self):
196197
QUALIFIER = ''
197198

198199
FULLVERSION = VERSION
200+
write_version = True
201+
199202
if 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

225240
else:
@@ -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

245262
class CleanCommand(Command):
246263
"""Custom distutils command to clean the .so and .pyc files."""
@@ -527,8 +544,6 @@ def pxd(name):
527544
if _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

Comments
 (0)