Skip to content

Commit 2e99c7d

Browse files
authored
Print full environment fron conf.py (#2709)
This should make it easier to debug the doc build environment.
1 parent cc5015a commit 2e99c7d

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

doc/conf.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
# serve to show the default.
1414
from __future__ import absolute_import, division, print_function
1515

16+
from contextlib import suppress
1617
import datetime
17-
import importlib
1818
import os
19+
import subprocess
1920
import sys
2021

2122
import xarray
@@ -24,29 +25,33 @@
2425

2526
print("python exec:", sys.executable)
2627
print("sys.path:", sys.path)
27-
for name in ('numpy scipy pandas matplotlib dask IPython seaborn '
28-
'cartopy netCDF4 rasterio zarr iris flake8 '
29-
'sphinx_gallery cftime').split():
30-
try:
31-
module = importlib.import_module(name)
32-
if name == 'matplotlib':
33-
module.use('Agg')
34-
fname = module.__file__.rstrip('__init__.py')
35-
print("%s: %s, %s" % (name, module.__version__, fname))
36-
except ImportError:
37-
print("no %s" % name)
38-
# neither rasterio nor cartopy should be hard requirements for
39-
# the doc build.
40-
if name == 'rasterio':
41-
allowed_failures.update(['gallery/plot_rasterio_rgb.py',
42-
'gallery/plot_rasterio.py'])
43-
elif name == 'cartopy':
44-
allowed_failures.update(['gallery/plot_cartopy_facetgrid.py',
45-
'gallery/plot_rasterio_rgb.py',
46-
'gallery/plot_rasterio.py'])
28+
29+
if 'conda' in sys.executable:
30+
print('conda environment:')
31+
subprocess.run(['conda', 'list'])
32+
else:
33+
print('pip environment:')
34+
subprocess.run(['pip', 'list'])
4735

4836
print("xarray: %s, %s" % (xarray.__version__, xarray.__file__))
4937

38+
with suppress(ImportError):
39+
import matplotlib
40+
matplotlib.use('Agg')
41+
42+
try:
43+
import rasterio
44+
except ImportError:
45+
allowed_failures.update(['gallery/plot_rasterio_rgb.py',
46+
'gallery/plot_rasterio.py'])
47+
48+
try:
49+
import cartopy
50+
except ImportError:
51+
allowed_failures.update(['gallery/plot_cartopy_facetgrid.py',
52+
'gallery/plot_rasterio_rgb.py',
53+
'gallery/plot_rasterio.py'])
54+
5055
# -- General configuration ------------------------------------------------
5156

5257
# If your documentation needs a minimal Sphinx version, state it here.

0 commit comments

Comments
 (0)