Skip to content

Commit 4f71542

Browse files
committed
Ensure setup warnings are only printed if building
1 parent b17ed5c commit 4f71542

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

packages/basemap/setup.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,19 @@ def get_geos_install_prefix():
5151
if os.path.isfile(hfile) and libfiles:
5252
return prefix
5353

54-
warnings.warn(" ".join([
55-
"Cannot find GEOS library and/or headers in standard locations",
56-
"('{0}'). Please install the corresponding packages using your",
57-
"software management system or set the environment variable",
58-
"GEOS_DIR to point to the location where GEOS is installed",
59-
"(for example, if 'geos_c.h' is in '/usr/local/include'",
60-
"and 'libgeos_c' is in '/usr/local/lib', then you need to",
61-
"set GEOS_DIR to '/usr/local'",
62-
]).format("', '".join(candidates)), RuntimeWarning)
54+
# At this point, the GEOS library was not found, so we throw a warning if
55+
# the user is trying to build the library.
56+
build_cmds = ("bdist_wheel", "build", "install")
57+
if any(cmd in sys.argv[1:] for cmd in build_cmds):
58+
warnings.warn(" ".join([
59+
"Cannot find GEOS library and/or headers in standard locations",
60+
"('{0}'). Please install the corresponding packages using your",
61+
"software management system or set the environment variable",
62+
"GEOS_DIR to point to the location where GEOS is installed",
63+
"(for example, if 'geos_c.h' is in '/usr/local/include'",
64+
"and 'libgeos_c' is in '/usr/local/lib', then you need to",
65+
"set GEOS_DIR to '/usr/local'",
66+
]).format("', '".join(candidates)), RuntimeWarning)
6367
return None
6468

6569

@@ -96,7 +100,9 @@ def run(self):
96100
import numpy
97101
include_dirs.append(numpy.get_include())
98102
except ImportError as err:
99-
warnings.warn("unable to locate NumPy headers", RuntimeWarning)
103+
build_cmds = ("bdist_wheel", "build", "install")
104+
if any(cmd in sys.argv[1:] for cmd in build_cmds):
105+
warnings.warn("unable to locate NumPy headers", RuntimeWarning)
100106

101107
# Define GEOS include, library and runtime dirs.
102108
geos_install_prefix = get_geos_install_prefix()

0 commit comments

Comments
 (0)