From 791df75775e5083738716919538b135057d7f61a Mon Sep 17 00:00:00 2001
From: caron <j.caron@fz-juelich.de>
Date: Tue, 3 Mar 2020 16:14:11 +0100
Subject: [PATCH] Added test_install to test stage setup.py: use matplotlib
 AFTER setup() (otherwise matplotlib is not available, despite being in
 setup_requires)

---
 .gitlab-ci.yml |  6 ++++++
 setup.py       | 12 +++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 847b0e0..1b9c670 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -47,6 +47,12 @@ test_docs:
             - build/sphinx
         expire_in: 1 week
 
+test_install:
+    stage: test
+    image: continuumio/miniconda3:latest
+    script:
+        - pip install .[all]
+
 pages:
     stage: deploy
     image: busybox
diff --git a/setup.py b/setup.py
index 092bcc7..bf06da1 100644
--- a/setup.py
+++ b/setup.py
@@ -8,8 +8,6 @@ import shutil
 import subprocess
 from setuptools import setup, config
 
-import matplotlib as mpl
-
 
 # Read version from setup.py:
 version = config.read_configuration('setup.cfg')['metadata']['version']
@@ -25,6 +23,13 @@ with open(os.path.join(os.path.dirname(__file__), 'src', 'empyre', 'version.py')
                 '""""This file was automatically generated by `setup.py`"""\n' +
                 f'version = "{version}"\n' +
                 f'git_revision = "{git_rev}"\n')
+
+# Run setup (reads metadata & options from setup.cfg):
+print(R'running setup.py')
+setup()
+
+
+import matplotlib as mpl
 # Find matplotlib styles:
 BASE_LIBRARY_PATH = os.path.join(mpl.get_data_path(), 'stylelib')
 STYLE_PATH = os.path.join(os.getcwd(), 'mplstyles')
@@ -35,6 +40,3 @@ for style_path in style_files:
     _, fname = os.path.split(style_path)
     dest = os.path.join(BASE_LIBRARY_PATH, fname)
     shutil.copy(style_path, dest)
-# Run setup (reads metadata & options from setup.cfg):
-print(R'running setup.py')
-setup()
-- 
GitLab