Skip to content

Commit 9b6cf96

Browse files
committed
doc/conf.py: Clear sys.path before importing Roundup __version__
This ensures that 'unkown version' is inserted when `roundup` is importable from other location in sys.path
1 parent 11adeeb commit 9b6cf96

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

doc/conf.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@
1313

1414
import sys, os
1515

16+
17+
# Read Roundup version by importing it from parent directory,
18+
# this ensures that 'unkown version' is inserted even if
19+
# `roundup` is importable from other location in sys.path
20+
SYSSAVE = sys.path
21+
DOCROOT = os.path.abspath(os.path.dirname(__file__))
22+
sys.path = [os.path.dirname(DOCROOT)]
1623
try:
17-
sys.path.insert(0, os.pardir)
18-
from roundup import __version__ as roundupversion
19-
sys.path.pop(0)
24+
from roundup import __version__ as VERSION
25+
SHORTVER = '.'.join(VERSION.split('.', 2)[:2])
2026
except ImportError:
21-
roundupversion = '(unknown version)'
27+
VERSION = SHORTVER = '(unknown version)'
28+
finally:
29+
sys.path = SYSSAVE
30+
2231

2332
# If your extensions are in another directory, add it here. If the directory
2433
# is relative to the documentation root, use os.path.abspath to make it
@@ -53,9 +62,9 @@
5362
# built documents.
5463
#
5564
# The short X.Y version.
56-
version = '.'.join(roundupversion.split('.', 2)[:2])
65+
version = SHORTVER
5766
# The full version, including alpha/beta/rc tags.
58-
release = roundupversion
67+
release = VERSION
5968

6069
# The language for content autogenerated by Sphinx. Refer to documentation
6170
# for a list of supported languages.

0 commit comments

Comments
 (0)