@@ -197,26 +197,30 @@ def build_extensions(self):
197
197
198
198
FULLVERSION = VERSION
199
199
if not ISRELEASED :
200
+ import subprocess
200
201
FULLVERSION += '.dev'
201
- try :
202
- import subprocess
202
+
203
+ for cmd in [ 'git' , 'git.cmd' ]:
203
204
try :
204
- pipe = subprocess .Popen (["git" , "describe" , "--always" ],
205
- stdout = subprocess .PIPE ).stdout
206
- except OSError :
207
- # msysgit compatibility
208
- pipe = subprocess .Popen (
209
- ["git.cmd" , "describe" , "--always" ],
210
- stdout = subprocess .PIPE ).stdout
211
- rev = pipe .read ().strip ()
212
- # makes distutils blow up on Python 2.7
213
- if sys .version_info [0 ] >= 3 :
214
- rev = rev .decode ('ascii' )
215
-
216
- FULLVERSION = rev .lstrip ('v' )
217
-
218
- except :
219
- warnings .warn ("WARNING: Couldn't get git revision" )
205
+ pipe = subprocess .Popen ([cmd , "describe" , "--always" ],
206
+ stdout = subprocess .PIPE )
207
+ (so ,serr ) = pipe .communicate ()
208
+ if pipe .returncode == 0 :
209
+ break
210
+ except :
211
+ pass
212
+
213
+ if pipe .returncode != 0 :
214
+ warnings .warn ("WARNING: Couldn't get git revision, using generic version string" )
215
+ else :
216
+ rev = so .strip ()
217
+ # makes distutils blow up on Python 2.7
218
+ if sys .version_info [0 ] >= 3 :
219
+ rev = rev .decode ('ascii' )
220
+
221
+ # use result og git describe as version string
222
+ FULLVERSION = rev .lstrip ('v' )
223
+
220
224
else :
221
225
FULLVERSION += QUALIFIER
222
226
0 commit comments