From d207dceb3a05ffbe54a096a89591e4469a3f880e Mon Sep 17 00:00:00 2001
From: Oliver Breitwieser <oliver.breitwieser@kip.uni-heidelberg.de>
Date: Wed, 27 Nov 2019 15:30:53 +0100
Subject: [PATCH] Fix py-line-profiler incompatible decorators (#13911)

`@run_after` and `@when` are incompatible, issue #12736.
---
 var/spack/repos/builtin/packages/py-line-profiler/package.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/var/spack/repos/builtin/packages/py-line-profiler/package.py b/var/spack/repos/builtin/packages/py-line-profiler/package.py
index c06a8968ea..a40b1a3e15 100644
--- a/var/spack/repos/builtin/packages/py-line-profiler/package.py
+++ b/var/spack/repos/builtin/packages/py-line-profiler/package.py
@@ -24,8 +24,11 @@ class PyLineProfiler(PythonPackage):
 
     # See https://github.com/rkern/line_profiler/issues/166
     @run_before('build')
-    @when('^python@3.7:')
     def fix_cython(self):
+        # TODO: Replace the check with a `@when('^python@3.7:')` decorator once
+        # https://github.com/spack/spack/issues/12736 is resolved
+        if not self.spec.satisfies("^python@3.7:"):
+            return
         cython = self.spec['py-cython'].command
         for root, _, files in os.walk('.'):
             for fn in files:
-- 
GitLab