Skip to content

BLD: Handle git describe failure more cleanly in setup.py GH5495 #5739

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 Dec 30, 2013
Merged
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
40 changes: 22 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,30 @@ def build_extensions(self):

FULLVERSION = VERSION
if not ISRELEASED:
import subprocess
FULLVERSION += '.dev'
try:
import subprocess

for cmd in ['git','git.cmd']:
try:
pipe = subprocess.Popen(["git", "describe", "--always"],
stdout=subprocess.PIPE).stdout
except OSError:
# msysgit compatibility
pipe = subprocess.Popen(
["git.cmd", "describe", "--always"],
stdout=subprocess.PIPE).stdout
rev = pipe.read().strip()
# makes distutils blow up on Python 2.7
if sys.version_info[0] >= 3:
rev = rev.decode('ascii')

FULLVERSION = rev.lstrip('v')

except:
warnings.warn("WARNING: Couldn't get git revision")
pipe = subprocess.Popen([cmd, "describe", "--always"],
stdout=subprocess.PIPE)
(so,serr) = pipe.communicate()
if pipe.returncode == 0:
break
except:
pass

if pipe.returncode != 0:
warnings.warn("WARNING: Couldn't get git revision, using generic version string")
else:
rev = so.strip()
# makes distutils blow up on Python 2.7
if sys.version_info[0] >= 3:
rev = rev.decode('ascii')

# use result og git describe as version string
FULLVERSION = rev.lstrip('v')

else:
FULLVERSION += QUALIFIER

Expand Down