From f3c44d8b31596841fe76c6f73b00388558660e46 Mon Sep 17 00:00:00 2001 From: y-p Date: Sat, 1 Feb 2014 07:35:52 +0200 Subject: [PATCH] BLD: setup.py version strings. handle shallow clones and installing from sdist --- doc/source/release.rst | 2 ++ setup.py | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 247bd896809a7..35c22fdf03d9a 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -67,6 +67,8 @@ Improvements to existing features Bug Fixes ~~~~~~~~~ +- Bug in version string gen. for dev versions with shallow clones / install from tarball (:issue:`6127`) + pandas 0.13.1 ------------- diff --git a/setup.py b/setup.py index f820f3deb8a3e..6713e52733fd1 100755 --- a/setup.py +++ b/setup.py @@ -10,6 +10,7 @@ import sys import shutil import warnings +import re # may need to work around setuptools bug by providing a fake Pyrex try: @@ -196,6 +197,8 @@ def build_extensions(self): QUALIFIER = '' FULLVERSION = VERSION +write_version = True + if not ISRELEASED: import subprocess FULLVERSION += '.dev' @@ -212,14 +215,26 @@ def build_extensions(self): pass if pipe is None or pipe.returncode != 0: - warnings.warn("WARNING: Couldn't get git revision, using generic version string") + # no git, or not in git dir + if os.path.exists('pandas/version.py'): + warnings.warn("WARNING: Couldn't get git revision, using existing pandas/version.py") + write_version = False + else: + warnings.warn("WARNING: Couldn't get git revision, using generic version string") else: + # have git, in git dir, but may have used a shallow clone (travis does this) rev = so.strip() # makes distutils blow up on Python 2.7 if sys.version_info[0] >= 3: rev = rev.decode('ascii') - # use result of git describe as version string + if not rev.startswith('v') and re.match("[a-zA-Z0-9]{7,9}",rev): + # partial clone, manually construct version string + # this is the format before we started using git-describe + # to get an ordering on dev version strings. + rev ="v%s.dev-%s" % (VERSION, rev) + + # Strip leading v from tags format "vx.y.z" to get th version string FULLVERSION = rev.lstrip('v') else: @@ -241,6 +256,8 @@ def write_version_py(filename=None): finally: a.close() +if write_version: + write_version_py() class CleanCommand(Command): """Custom distutils command to clean the .so and .pyc files.""" @@ -527,8 +544,6 @@ def pxd(name): if _have_setuptools: setuptools_kwargs["test_suite"] = "nose.collector" -write_version_py() - # The build cache system does string matching below this point. # if you change something, be careful.