Skip to content

Commit

Permalink
Merge pull request #695 from QuLogic/optional-pillow
Browse files Browse the repository at this point in the history
Make cartopy.feature.WFSFeature imports lazier.
  • Loading branch information
pelson committed Nov 12, 2015
2 parents b684ecf + b9914b6 commit fc5fb8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/cartopy/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import shapely.geometry
import six

from cartopy.io.ogc_clients import WFSGeometrySource
import cartopy.io.shapereader as shapereader
import cartopy.crs

Expand Down Expand Up @@ -298,6 +297,8 @@ class WFSFeature(Feature):
A class capable of drawing a collection of geometries
obtained from an OGC Web Feature Service (WFS).
This feature requires additional dependencies. If installed via pip,
try ``pip install cartopy[ows]``.
"""
def __init__(self, wfs, features, **kwargs):
"""
Expand All @@ -315,6 +316,12 @@ def __init__(self, wfs, features, **kwargs):
Keyword arguments to be used when drawing this feature.
"""
try:
from cartopy.io.ogc_clients import WFSGeometrySource
except ImportError as e:
six.raise_from(ImportError(
'WFSFeature requires additional dependencies. If installed '
'via pip, try `pip install cartopy[ows]`.\n'), e)

self.source = WFSGeometrySource(wfs, features)
crs = self.source.default_projection()
Expand Down
1 change: 1 addition & 0 deletions requirements/ows.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
OWSLib>=0.8.7
pillow>=1.7.8

0 comments on commit fc5fb8f

Please sign in to comment.