Skip to content

Commit 4e09905

Browse files
committed
docs: allow building from verson in PYTHONPATH again
1 parent ee8908a commit 4e09905

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

doc/conf.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,20 @@
3333
sys.version_info[0], sys.version_info[1]
3434
)
3535

36-
if not os.path.exists(build_dir):
37-
print("""
38-
Compiled version of pyosmium not found, please build pyosmium for Python {}.{}
39-
before building the documentation.
40-
""".format(*sys.version_info))
41-
raise RuntimeError("Cannot find pyosmium")
36+
if os.path.exists(build_dir):
37+
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath('.'), build_dir)))
4238

4339
# insert after the current directory
44-
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath('.'), build_dir)))
4540
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath('.'), '../tools')))
4641

47-
from osmium.version import pyosmium_major, pyosmium_release
42+
try:
43+
from osmium.version import pyosmium_major, pyosmium_release
44+
except ImportError:
45+
print("""
46+
Compiled version of pyosmium not found, please build pyosmium for Python {}.{}
47+
before building the documentation.
48+
""".format(*sys.version_info))
49+
raise RuntimeError("Cannot find pyosmium")
4850

4951
# -- General configuration ------------------------------------------------
5052

0 commit comments

Comments
 (0)