components/python/python35/patches/03-setup.patch
author John Beck <John.Beck@Oracle.COM>
Thu, 21 Jul 2016 12:52:32 -0700
changeset 6447 56a2f066191a
parent 5476 f1df93f6aff1
child 7648 20e09cf3cfaa
permissions -rw-r--r--
23858083 Upgrade Python to 3.5.2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     1
This patch modifies the setup script to support Solaris.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
As it is Solaris-specific, it is not suitable for upstream.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     3
6447
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
     4
--- Python-3.5.2/setup.py.~2~	2016-07-08 06:42:55.956132475 -0700
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
     5
+++ Python-3.5.2/setup.py	2016-07-08 06:42:55.983129138 -0700
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
     6
@@ -488,12 +488,15 @@
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
     7
             return ['m']
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
 
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     9
     def detect_modules(self):
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    10
-        # Ensure that /usr/local is always used, but the local build
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
-        # directories (i.e. '.' and 'Include') must be first.  See issue
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
-        # 10520.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    13
         if not cross_compiling:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
-            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
-            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
+            if host_platform != 'sunos5':
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    17
+                # Upstream notes the following for source builds:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
+                #    Ensure that /usr/local is always used, but the local build
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    19
+                #    directories (i.e. '.' and 'Include') must be first.  See
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    20
+                #    issue 10520.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
+                # But we skip that for Solaris system builds.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
+                add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
+                add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
         # only change this for cross builds for 3.3, issues on Mageia
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
         if cross_compiling:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
             self.add_gcc_paths()
6447
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
    27
@@ -786,6 +789,13 @@
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    28
                                                      ['/usr/lib/termcap'],
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    29
                                                      'termcap'):
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    30
                 readline_libs.append('termcap')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    31
+
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    32
+            if host_platform == 'sunos5':
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    33
+                # insert '-zrecord' before the readline libraries that we
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    34
+                # want to link with to avoid rl_insert() elimination
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    35
+                readline_extra_link_args = ('-Wl,-zrecord','-lreadline','-lncurses')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    36
+                readline_libs = ()
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    37
+
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    38
             exts.append( Extension('readline', ['readline.c'],
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    39
                                    library_dirs=['/usr/lib/termcap'],
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    40
                                    extra_link_args=readline_extra_link_args,
6447
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
    41
@@ -809,7 +819,8 @@
4964
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    42
 
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    43
         # socket(2)
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    44
         exts.append( Extension('_socket', ['socketmodule.c'],
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    45
-                               depends = ['socketmodule.h']) )
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    46
+                               depends = ['socketmodule.h'],
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    47
+                               libraries = ['socket', 'nsl']) )
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    48
         # Detect SSL support for the socket module (via _ssl)
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    49
         search_for_ssl_incs_in = [
30f7741bb742 21959680 libsocket tweak needed for python{27,34,35}
John Beck <John.Beck@Oracle.COM>
parents: 4912
diff changeset
    50
                               '/usr/local/ssl/include',
6447
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
    51
@@ -1345,6 +1356,10 @@
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    52
             curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    53
 
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    54
         if curses_library.startswith('ncurses'):
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    55
+            if host_platform == 'sunos5':
5476
f1df93f6aff1 22661864 py3 curses get_wch() returns char in int, upstream returns it in str
John Beck <John.Beck@Oracle.COM>
parents: 4964
diff changeset
    56
+                curses_defines.append(('HAVE_NCURSESW', '1'))
f1df93f6aff1 22661864 py3 curses get_wch() returns char in int, upstream returns it in str
John Beck <John.Beck@Oracle.COM>
parents: 4964
diff changeset
    57
+                curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    58
+                curses_includes.append('/usr/include/ncurses')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    59
             curses_libs = [curses_library]
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    60
             exts.append( Extension('_curses', ['_cursesmodule.c'],
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    61
                                    include_dirs=curses_includes,
6447
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
    62
@@ -1369,10 +1384,32 @@
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    63
         # If the curses module is enabled, check for the panel module
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    64
         if (module_enabled(exts, '_curses') and
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    65
             self.compiler.find_library_file(lib_dirs, panel_library)):
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    66
+            panel_lib_dirs = []
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    67
+            if host_platform == 'sunos5':
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    68
+                # Look for libpanel under /usr/gnu/lib on Solaris.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    69
+                # os.uname() does not include the processor. platform.uname()
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    70
+                # does, but the platform module is not available in setup.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    71
+                # Work around this by parsing os.system('uname -p') output.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    72
+                tmpfile = os.path.join(self.build_temp, 'processor')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    73
+                if not os.path.exists(self.build_temp):
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    74
+                    os.makedirs(self.build_temp)
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    75
+                os.system('/usr/bin/uname -p > %s 2> /dev/null' %tmpfile)
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    76
+                processor = ''
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    77
+                try:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    78
+                    with open(tmpfile) as fp:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    79
+                        processor = fp.readline().strip()
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    80
+                finally:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    81
+                    os.unlink(tmpfile)
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    82
+                if processor == 'sparc':
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    83
+                    panel_lib_dirs.append('/usr/gnu/lib/sparcv9')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    84
+                else:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    85
+                    panel_lib_dirs.append('/usr/gnu/lib/amd64')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    86
             exts.append( Extension('_curses_panel', ['_curses_panel.c'],
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    87
                                    include_dirs=curses_includes,
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    88
                                    define_macros=curses_defines,
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    89
-                                   libraries = [panel_library] + curses_libs) )
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    90
+                                   libraries = [panel_library] + curses_libs,
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    91
+                                   library_dirs = panel_lib_dirs,
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    92
+                                   runtime_library_dirs = panel_lib_dirs) )
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    93
         else:
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    94
             missing.append('_curses_panel')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    95
 
6447
56a2f066191a 23858083 Upgrade Python to 3.5.2
John Beck <John.Beck@Oracle.COM>
parents: 5476
diff changeset
    96
@@ -1969,7 +2006,7 @@
4912
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    97
             # this option. If you want to compile ctypes with the Sun
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    98
             # compiler, please research a proper solution, instead of
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    99
             # finding some -z option for the Sun compiler.
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   100
-            extra_link_args.append('-mimpure-text')
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   101
+            pass
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   102
 
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   103
         elif host_platform.startswith('hp-ux'):
0b79e9575718 PSARC 2015/414 Python 3.5
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   104
             extra_link_args.append('-fPIC')