File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 22import shutil
33import sys
44from pathlib import Path
5- from sphinx_polyversion .git import Git
5+
6+ try :
7+ from sphinx_polyversion .git import Git
8+
9+ USE_POLYVERSION = True
10+ except ImportError :
11+ USE_POLYVERSION = False
612
713
814def copy_files (sourcedir ):
@@ -34,8 +40,13 @@ def copy_files(sourcedir):
3440
3541
3642def patch_conf (sourcedir ):
37- root = Git .root (Path (__file__ ).parent )
43+ if USE_POLYVERSION :
44+ root = Git .root (Path (__file__ ).parent )
45+ else :
46+ root = str (Path (sourcedir ).parent .parent )
3847 cursrc = os .path .join (root , "docsrc" , "source" )
48+ if os .path .abspath (cursrc ) == os .path .abspath (sourcedir ):
49+ return
3950 # copy the configuration file: shared for all versions
4051 conf_src = os .path .join (cursrc , "conf.py" )
4152 conf_dst = os .path .join (sourcedir , "conf.py" )
Original file line number Diff line number Diff line change 1111# documentation root, use os.path.abspath to make it absolute, like shown here.
1212import os
1313import sys
14- from sphinx_polyversion import load
15- from sphinx_polyversion .git import GitRef
14+
15+ try :
16+ from sphinx_polyversion import load
17+ from sphinx_polyversion .git import GitRef
18+ from sphinx_polyversion .api import LoadError
19+
20+ USE_POLYVERSION = True
21+ except ImportError :
22+ USE_POLYVERSION = False
23+ print ("sphinx_polyversion not installed, building single version" )
1624
1725sys .path .insert (0 , os .path .abspath ("../.." ))
1826
134142autosummmary_generate = True
135143
136144# versioning data for template
137- data = load (globals ())
138- current : GitRef = data ["current" ]
145+ if USE_POLYVERSION :
146+ try :
147+ data = load (globals ())
148+ current : GitRef = data ["current" ]
149+ except LoadError :
150+ print ("sphinx_polyversion could not load. Building single version" )
You can’t perform that action at this time.
0 commit comments