From 526ee113ea4c8003650d7d0611cd736eef01732a Mon Sep 17 00:00:00 2001
From: "Adam J. Stewart" <ajstewart426@gmail.com>
Date: Tue, 22 Oct 2019 10:22:32 -0500
Subject: Default to Python 3.7 (#10319)

* Default to Python 3

* Fix build with Intel compilers
---
 .../builtin/packages/python/intel-3.6.7.patch      | 38 ++++++++++++++++++++++
 var/spack/repos/builtin/packages/python/package.py | 13 ++++----
 2 files changed, 44 insertions(+), 7 deletions(-)
 create mode 100644 var/spack/repos/builtin/packages/python/intel-3.6.7.patch

diff --git a/var/spack/repos/builtin/packages/python/intel-3.6.7.patch b/var/spack/repos/builtin/packages/python/intel-3.6.7.patch
new file mode 100644
index 0000000000..f2277624af
--- /dev/null
+++ b/var/spack/repos/builtin/packages/python/intel-3.6.7.patch
@@ -0,0 +1,38 @@
+From 87ed388f41d761ddddc8447e5104569f2436c005 Mon Sep 17 00:00:00 2001
+From: Victor Stinner <vstinner@python.org>
+Date: Fri, 11 Oct 2019 15:13:51 +0200
+Subject: [PATCH] bpo-37415: Fix stdatomic.h header check for ICC compiler
+
+Fix stdatomic.h header check for ICC compiler: the ICC implementation
+lacks atomic_uintptr_t type which is needed by Python.
+
+Test:
+
+* atomic_int and atomic_uintptr_t types
+* atomic_load_explicit() and atomic_store_explicit()
+* memory_order_relaxed and memory_order_seq_cst constants
+
+But don't test ATOMIC_VAR_INIT(): it's not used in Python.
+---
+ configure                                     | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/configure b/configure
+index f1979c1b8124c..1b30a848a77e7 100755
+--- a/configure
++++ b/configure
+@@ -16734,9 +16722,12 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ 
+ 
+     #include <stdatomic.h>
+-    atomic_int value = ATOMIC_VAR_INIT(1);
++    atomic_int int_var;
++    atomic_uintptr_t uintptr_var;
+     int main() {
+-      int loaded_value = atomic_load(&value);
++      atomic_store_explicit(&int_var, 5, memory_order_relaxed);
++      atomic_store_explicit(&uintptr_var, 0, memory_order_relaxed);
++      int loaded_value = atomic_load_explicit(&int_var, memory_order_seq_cst);
+       return 0;
+     }
+ 
diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py
index 2813121dda..6087ff5be8 100644
--- a/var/spack/repos/builtin/packages/python/package.py
+++ b/var/spack/repos/builtin/packages/python/package.py
@@ -32,7 +32,7 @@ class Python(AutotoolsPackage):
     maintainers = ['adamjstewart']
 
     version('3.8.0',  sha256='f1069ad3cae8e7ec467aa98a6565a62a48ef196cb8f1455a245a08db5e1792df')
-    version('3.7.4',  sha256='d63e63e14e6d29e17490abbe6f7d17afb3db182dbd801229f14e55f4157c4ba3')
+    version('3.7.4',  sha256='d63e63e14e6d29e17490abbe6f7d17afb3db182dbd801229f14e55f4157c4ba3', preferred=True)
     version('3.7.3',  sha256='d62e3015f2f89c970ac52343976b406694931742fbde2fed8d1ce8ebb4e1f8ff')
     version('3.7.2',  sha256='f09d83c773b9cc72421abba2c317e4e6e05d919f9bcf34468e192b6a6c8e328d')
     version('3.7.1',  sha256='36c1b81ac29d0f8341f727ef40864d99d8206897be96be73dc34d4739c9c9f06')
@@ -55,7 +55,7 @@ class Python(AutotoolsPackage):
     version('3.3.6',  sha256='0a58ad1f1def4ecc90b18b0c410a3a0e1a48cf7692c75d1f83d0af080e5d2034')
     version('3.2.6',  sha256='fc1e41296e29d476f696303acae293ae7a2310f0f9d0d637905e722a3f16163e')
     version('3.1.5',  sha256='d12dae6d06f52ef6bf1271db4d5b4d14b5dd39813e324314e72b648ef1bc0103')
-    version('2.7.16', sha256='01da813a3600876f03f46db11cc5c408175e99f03af2ba942ef324389a83bad5', preferred=True)
+    version('2.7.16', sha256='01da813a3600876f03f46db11cc5c408175e99f03af2ba942ef324389a83bad5')
     version('2.7.15', sha256='18617d1f15a380a919d517630a9cd85ce17ea602f9bbdc58ddc672df4b0239db')
     version('2.7.14', sha256='304c9b202ea6fbd0a4a8e0ad3733715fbd4749f2204a9173a58ec53c32ea73e8')
     version('2.7.13', sha256='a4f05a0720ce0fd92626f0278b6b433eee9a6173ddf2bced7957dfb599a5ece1')
@@ -145,6 +145,10 @@ class Python(AutotoolsPackage):
     # https://github.com/python/cpython/commit/0b91f8a668201fc58fa732b8acc496caedfdbae0
     patch('gcc-8-2.7.14.patch', when='@2.7.14 %gcc@8:')
 
+    # Fixes build with the Intel compilers
+    # https://github.com/python/cpython/pull/16717
+    patch('intel-3.6.7.patch', when='@3.6.7:3.6.8,3.7.1: %intel')
+
     # For more information refer to this bug report:
     # https://bugs.python.org/issue29712
     conflicts(
@@ -155,11 +159,6 @@ class Python(AutotoolsPackage):
     conflicts('+tix', when='~tkinter',
               msg='python+tix requires python+tix+tkinter')
 
-    # Python 3.6.7 and above can not be compiled with the Intel compiler
-    # https://bugs.python.org/issue35473
-    # https://bugs.python.org/issue37415
-    conflicts('%intel', when='@3.6.7:')
-
     _DISTUTIL_VARS_TO_SAVE = ['LDSHARED']
     _DISTUTIL_CACHE_FILENAME = 'sysconfig.json'
     _distutil_vars = None
-- 
cgit v1.2.3-70-g09d2