Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d12be50

Browse files
dstansbytimhoffm
authored andcommitted
Enable local doc building without git installation (#13015)
* Enable local doc building without git installation * Catch FileNotFoundError
1 parent e1750a8 commit d12be50

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

doc/conf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import os
1313
import shutil
14+
import subprocess
1415
import sys
1516

1617
import matplotlib
@@ -142,8 +143,13 @@ def _check_deps():
142143
master_doc = 'contents'
143144

144145
# General substitutions.
145-
from subprocess import check_output
146-
SHA = check_output(['git', 'describe', '--dirty']).decode('utf-8').strip()
146+
try:
147+
SHA = subprocess.check_output(
148+
['git', 'describe', '--dirty']).decode('utf-8').strip()
149+
# Catch the case where git is not installed locally, and use the versioneer
150+
# version number instead
151+
except (subprocess.CalledProcessError, FileNotFoundError):
152+
SHA = matplotlib.__version__
147153

148154
html_context = {'sha': SHA}
149155

0 commit comments

Comments
 (0)