From 19d10291bfeae45315fcef852baddec63b69247a Mon Sep 17 00:00:00 2001
From: "Gregory L. Lee" <lee218@surface86.llnl.gov>
Date: Thu, 18 Feb 2016 15:45:29 -0800
Subject: [PATCH] modify compiler commands in python config files, fix for #431

---
 var/spack/repos/builtin/packages/python/package.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
index a1ce06feb0..58d401244e 100644
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -55,6 +55,20 @@ def install(self, spec, prefix):
         make()
         make("install")
 
+        # Modify compiler paths in configuration files. This is necessary for
+        # building site packages outside of spack
+        filter_file(r'([/s]=?)([\S=]*)/lib/spack/env(/[^\s/]*)?/(\S*)(\s)',
+                    (r'\4\5'),
+                    join_path(prefix.lib, 'python%d.%d' % self.version[:2], '_sysconfigdata.py'))
+
+        python3_version = ''
+        if spec.satisfies('@3:'):
+            python3_version = '-%d.%dm' % self.version[:2]
+        makefile_filepath = join_path(prefix.lib, 'python%d.%d' % self.version[:2], 'config%s' % python3_version, 'Makefile')
+        filter_file(r'([/s]=?)([\S=]*)/lib/spack/env(/[^\s/]*)?/(\S*)(\s)',
+                    (r'\4\5'),
+                    makefile_filepath)
+
 
     # ========================================================================
     # Set up environment to make install easy for python extensions.
-- 
GitLab