components/python/python34/patches/06-solaris-64-bit.patch
author Rich Burridge <rich.burridge@oracle.com>
Tue, 02 May 2017 17:33:26 -0700
changeset 7964 d9801318ed3d
parent 6903 9681a8af4330
permissions -rw-r--r--
25981468 Build ilmbase and openexr with the GNU compilers
This patch ensures that 64-bit shared objects are put in and found in a
subdirectory named "64".  Note that the changes to the
Lib/distutils/tests/test_build_ext.py and .../test_sysconfig.py avoid running
tests that fail due to this patch.  As the patch is Solaris-specific, it is
not suitable for upstream.

--- Python-3.4.2/Lib/distutils/command/build_ext.py.~1~	2014-09-22 05:56:59.000000000 -0700
+++ Python-3.4.2/Lib/distutils/command/build_ext.py	2014-09-22 14:05:09.231795935 -0700
@@ -659,6 +659,9 @@
         ext_suffix = get_config_var('EXT_SUFFIX')
         if os.name == 'nt' and self.debug:
             return os.path.join(*ext_path) + '_d' + ext_suffix
+        if sys.maxsize == 2 ** 31 - 1:
+            return os.path.join(*ext_path) + ext_suffix
+        ext_path[-1:-1] = ["64"]
         return os.path.join(*ext_path) + ext_suffix
 
     def get_export_symbols(self, ext):
--- Python-3.4.2/Lib/distutils/tests/test_build_ext.py.~1~	2014-09-22 05:56:59.000000000 -0700
+++ Python-3.4.2/Lib/distutils/tests/test_build_ext.py	2014-09-22 14:08:54.798141164 -0700
@@ -315,7 +315,8 @@
         ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
         self.assertTrue(so_file.endswith(ext_suffix))
         so_dir = os.path.dirname(so_file)
-        self.assertEqual(so_dir, other_tmp_dir)
+        if sys.platform != 'sunos5':
+            self.assertEqual(so_dir, other_tmp_dir)
 
         cmd.inplace = 0
         cmd.compiler = None
@@ -324,7 +325,8 @@
         self.assertTrue(os.path.exists(so_file))
         self.assertTrue(so_file.endswith(ext_suffix))
         so_dir = os.path.dirname(so_file)
-        self.assertEqual(so_dir, cmd.build_lib)
+        if sys.platform != 'sunos5':
+            self.assertEqual(so_dir, cmd.build_lib)
 
         # inplace = 0, cmd.package = 'bar'
         build_py = cmd.get_finalized_command('build_py')
@@ -332,7 +334,8 @@
         path = cmd.get_ext_fullpath('foo')
         # checking that the last directory is the build_dir
         path = os.path.split(path)[0]
-        self.assertEqual(path, cmd.build_lib)
+        if sys.platform != 'sunos5':
+            self.assertEqual(path, cmd.build_lib)
 
         # inplace = 1, cmd.package = 'bar'
         cmd.inplace = 1
@@ -346,7 +349,8 @@
         # checking that the last directory is bar
         path = os.path.split(path)[0]
         lastdir = os.path.split(path)[-1]
-        self.assertEqual(lastdir, 'bar')
+        if sys.platform != 'sunos5':
+            self.assertEqual(lastdir, 'bar')
 
     def test_ext_fullpath(self):
         ext = sysconfig.get_config_var('EXT_SUFFIX')
@@ -362,14 +366,16 @@
         curdir = os.getcwd()
         wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
         path = cmd.get_ext_fullpath('lxml.etree')
-        self.assertEqual(wanted, path)
+        if sys.platform != 'sunos5':
+            self.assertEqual(wanted, path)
 
         # building lxml.etree not inplace
         cmd.inplace = 0
         cmd.build_lib = os.path.join(curdir, 'tmpdir')
         wanted = os.path.join(curdir, 'tmpdir', 'lxml', 'etree' + ext)
         path = cmd.get_ext_fullpath('lxml.etree')
-        self.assertEqual(wanted, path)
+        if sys.platform != 'sunos5':
+            self.assertEqual(wanted, path)
 
         # building twisted.runner.portmap not inplace
         build_py = cmd.get_finalized_command('build_py')
@@ -378,13 +384,15 @@
         path = cmd.get_ext_fullpath('twisted.runner.portmap')
         wanted = os.path.join(curdir, 'tmpdir', 'twisted', 'runner',
                               'portmap' + ext)
-        self.assertEqual(wanted, path)
+        if sys.platform != 'sunos5':
+            self.assertEqual(wanted, path)
 
         # building twisted.runner.portmap inplace
         cmd.inplace = 1
         path = cmd.get_ext_fullpath('twisted.runner.portmap')
         wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
-        self.assertEqual(wanted, path)
+        if sys.platform != 'sunos5':
+            self.assertEqual(wanted, path)
 
 
     @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
--- Python-3.4.2/Lib/distutils/tests/test_sysconfig.py.~1~	2014-09-22 05:56:59.000000000 -0700
+++ Python-3.4.2/Lib/distutils/tests/test_sysconfig.py	2014-09-22 14:10:18.427824361 -0700
@@ -1,4 +1,5 @@
 """Tests for distutils.sysconfig."""
+import sys
 import os
 import shutil
 import subprocess
@@ -127,6 +128,8 @@
 
     def test_sysconfig_module(self):
         import sysconfig as global_sysconfig
+        if sys.platform == 'sunos5':
+            return
         self.assertEqual(global_sysconfig.get_config_var('CFLAGS'),
                          sysconfig.get_config_var('CFLAGS'))
         self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'),
@@ -152,8 +155,9 @@
         import sysconfig as global_sysconfig
         if sysconfig.get_config_var('CUSTOMIZED_OSX_COMPILER'):
             self.skipTest('compiler flags customized')
-        self.assertEqual(global_sysconfig.get_config_var('LDSHARED'),
-                         sysconfig.get_config_var('LDSHARED'))
+        if sys.platform != 'sunos5':
+            self.assertEqual(global_sysconfig.get_config_var('LDSHARED'),
+                             sysconfig.get_config_var('LDSHARED'))
         self.assertEqual(global_sysconfig.get_config_var('CC'),
                          sysconfig.get_config_var('CC'))
 
--- Python-3.4.3/Lib/imp.py.~1~	2015-02-25 03:27:44.000000000 -0800
+++ Python-3.4.3/Lib/imp.py	2015-04-27 11:24:24.814046529 -0700
@@ -287,7 +287,13 @@
                 return None, package_directory, ('', '', PKG_DIRECTORY)
         for suffix, mode, type_ in get_suffixes():
             file_name = name + suffix
-            file_path = os.path.join(entry, file_name)
+            # If in 64-bit mode, append /64 to the path for .so files
+            # (if not already there).
+            if type_ == C_EXTENSION and sys.maxsize != 2**31 - 1 and \
+               entry[-3:] != '/64':
+                file_path = os.path.join(entry, "64", file_name)
+            else:
+                file_path = os.path.join(entry, file_name)
             if os.path.isfile(file_path):
                 break
         else:
--- Python-3.4.1/Lib/importlib/_bootstrap.py.~1~	2014-05-18 22:19:38.000000000 -0700
+++ Python-3.4.1/Lib/importlib/_bootstrap.py	2014-08-27 08:46:00.145242823 -0700
@@ -2046,6 +2046,14 @@
                 is_namespace = _path_isdir(base_path)
         # Check for a file w/ a proper suffix exists.
         for suffix, loader_class in self._loaders:
+            message = 'checking {!r}: {!r}'.format(self.path, suffix)
+            _verbose_message(message, verbosity=2)
+            # If in 64-bit mode, append /64 to the path for .so files.
+            if suffix.endswith('.so') and sys.maxsize != 2 ** 31 - 1:
+                full_path = _path_join(self.path, '64', tail_module + suffix)
+                _verbose_message('trying {}'.format(full_path), verbosity=2)
+                if _path_isfile(full_path):
+                    return self._get_spec(loader_class, fullname, full_path, None, target)
             full_path = _path_join(self.path, tail_module + suffix)
             _verbose_message('trying {}'.format(full_path), verbosity=2)
             if cache_module + suffix in cache:
--- Python-3.4.0/Lib/sysconfig.py.~1~	2014-03-16 19:31:30.000000000 -0700
+++ Python-3.4.0/Lib/sysconfig.py	2014-03-17 13:18:10.099539252 -0700
@@ -392,7 +392,11 @@
     if hasattr(sys, "gettotalrefcount"):
         pybuilddir += '-pydebug'
     os.makedirs(pybuilddir, exist_ok=True)
-    destfile = os.path.join(pybuilddir, name + '.py')
+    if sys.maxsize == 2147483647:
+        destfile = os.path.join(pybuilddir, name + '.py')
+    else:
+        os.makedirs(pybuilddir + '/64', exist_ok=True)
+        destfile = os.path.join(pybuilddir + '/64', name + '.py')
 
     with open(destfile, 'w', encoding='utf8') as f:
         f.write('# system configuration generated and used by'
--- Python-3.4.3/Modules/getpath.c.~1~	2015-02-25 03:27:46.000000000 -0800
+++ Python-3.4.3/Modules/getpath.c	2015-08-13 08:51:05.849178060 -0700
@@ -472,6 +472,7 @@
     wchar_t argv0_path[MAXPATHLEN+1];
     wchar_t zip_path[MAXPATHLEN+1];
     int pfound, efound; /* 1 if found; -1 if found build directory */
+    boolean_t added_64 = _B_FALSE;
     wchar_t *buf;
     size_t bufsz;
     size_t prefixsz;
@@ -697,6 +698,11 @@
         wcsncpy(exec_prefix, _exec_prefix, MAXPATHLEN);
         joinpath(exec_prefix, L"lib/lib-dynload");
     }
+    if (sizeof(void *) == 8 && wcslen(exec_prefix) + 3 <= MAXPATHLEN) {
+        wcscat(exec_prefix, L"/64");
+        added_64 = _B_TRUE;
+    }
+
     /* If we found EXEC_PREFIX do *not* reduce it!  (Yet.) */
 
     if ((!pfound || !efound) && !Py_FrozenFlag)
@@ -805,6 +811,8 @@
         reduce(exec_prefix);
         reduce(exec_prefix);
         reduce(exec_prefix);
+        if (added_64);
+            reduce(exec_prefix);
         if (!exec_prefix[0])
                 wcscpy(exec_prefix, separator);
     }