Skip to content

BLD: setup.py version strings. handle shallow clones and installing from sdist #6217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from Feb 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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