Skip to content

Commit

Permalink
BLD: setup.py version strings. handle shallow clones and installing f…
Browse files Browse the repository at this point in the history
…rom sdist
  • Loading branch information
y-p committed Feb 4, 2014
1 parent 185b3f1 commit f3c44d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------

Expand Down
23 changes: 19 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -196,6 +197,8 @@ def build_extensions(self):
QUALIFIER = ''

FULLVERSION = VERSION
write_version = True

if not ISRELEASED:
import subprocess
FULLVERSION += '.dev'
Expand All @@ -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:
Expand All @@ -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."""
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit f3c44d8

Please sign in to comment.