|
13 | 13 | # serve to show the default. |
14 | 14 | from __future__ import absolute_import, division, print_function |
15 | 15 |
|
| 16 | +from contextlib import suppress |
16 | 17 | import datetime |
17 | | -import importlib |
18 | 18 | import os |
| 19 | +import subprocess |
19 | 20 | import sys |
20 | 21 |
|
21 | 22 | import xarray |
|
24 | 25 |
|
25 | 26 | print("python exec:", sys.executable) |
26 | 27 | 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']) |
47 | 35 |
|
48 | 36 | print("xarray: %s, %s" % (xarray.__version__, xarray.__file__)) |
49 | 37 |
|
| 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 | + |
50 | 55 | # -- General configuration ------------------------------------------------ |
51 | 56 |
|
52 | 57 | # If your documentation needs a minimal Sphinx version, state it here. |
|
0 commit comments