summary refs log tree commit diff
path: root/pkgs/development/python-modules/cartopy
diff options
context:
space:
mode:
authorRobert Scott <code@humanleg.org.uk>2019-05-04 23:16:06 +0100
committerRobert Scott <code@humanleg.org.uk>2019-05-06 19:28:23 +0100
commitcb0028b44974f661d6e2699209ab7045cd6349ab (patch)
treebd3a581f2fcacea6c50699737c4e32ad7de5ea5a /pkgs/development/python-modules/cartopy
parentc910fe9d2929ba22b2dec9576213579d69dcb500 (diff)
downloadnixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.tar
nixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.tar.gz
nixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.tar.bz2
nixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.tar.lz
nixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.tar.xz
nixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.tar.zst
nixpkgs-cb0028b44974f661d6e2699209ab7045cd6349ab.zip
pythonPackages.cartopy: fix tests for py2.7 by supplying them with xvfb
python 2.7's tk is over-eager in trying to open an x display,
so run it in xvfb. xvfb is quite a heavy dependency (albeit only
a build-time one), so ensure this is only used when needed.
Diffstat (limited to 'pkgs/development/python-modules/cartopy')
-rw-r--r--pkgs/development/python-modules/cartopy/default.nix13
1 files changed, 9 insertions, 4 deletions
diff --git a/pkgs/development/python-modules/cartopy/default.nix b/pkgs/development/python-modules/cartopy/default.nix
index 3fc4c3e84ed..28148450f07 100644
--- a/pkgs/development/python-modules/cartopy/default.nix
+++ b/pkgs/development/python-modules/cartopy/default.nix
@@ -1,8 +1,9 @@
 { buildPythonPackage, lib, fetchPypi
 , pytest, filelock, mock, pep8
-, cython, isPy37, glibcLocales
+, cython, isPy27, isPy37, glibcLocales
 , six, pyshp, shapely, geos, proj, numpy
 , gdal, pillow, matplotlib, pyepsg, pykdtree, scipy, owslib, fiona
+, xvfb_run
 }:
 
 buildPythonPackage rec {
@@ -17,10 +18,14 @@ buildPythonPackage rec {
 
   checkInputs = [ filelock mock pytest pep8 ];
 
-  # several tests require network connectivity: we disable them
-  checkPhase = ''
+  # several tests require network connectivity: we disable them.
+  # also py2.7's tk is over-eager in trying to open an x display,
+  # so give it xvfb
+  checkPhase = let
+    maybeXvfbRun = lib.optionalString isPy27 "${xvfb_run}/bin/xvfb-run";
+  in ''
     export HOME=$(mktemp -d)
-    pytest --pyargs cartopy \
+    ${maybeXvfbRun} pytest --pyargs cartopy \
       -m "not network and not natural_earth" \
       -k "not test_nightshade_image"
   '';