components/python/python34/patches/03-setup.patch
author John Beck <John.Beck@Oracle.COM>
Fri, 02 Oct 2015 09:02:41 -0700
changeset 4964 30f7741bb742
parent 3759 6f5b34e14c5c
child 5476 f1df93f6aff1
permissions -rw-r--r--
21959680 libsocket tweak needed for python{27,34,35}

This patch modifies the setup script to support Solaris.
As it is Solaris-specific, it is not suitable for upstream.

--- Python-3.4.3/setup.py.~2~	2015-03-16 12:52:28.721744829 -0700
+++ Python-3.4.3/setup.py	2015-03-16 12:58:55.474886590 -0700
@@ -447,12 +447,15 @@
             os.unlink(tmpfile)
 
     def detect_modules(self):
-        # Ensure that /usr/local is always used, but the local build
-        # directories (i.e. '.' and 'Include') must be first.  See issue
-        # 10520.
         if not cross_compiling:
-            add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
-            add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
+            if host_platform != 'sunos5':
+                # Upstream notes the following for source builds:
+                #    Ensure that /usr/local is always used, but the local build
+                #    directories (i.e. '.' and 'Include') must be first.  See
+                #    issue 10520.
+                # But we skip that for Solaris system builds.
+                add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+                add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
         # only change this for cross builds for 3.3, issues on Mageia
         if cross_compiling:
             self.add_gcc_paths()
@@ -736,6 +739,13 @@
                                                      ['/usr/lib/termcap'],
                                                      'termcap'):
                 readline_libs.append('termcap')
+
+            if host_platform == 'sunos5':
+                # insert '-zrecord' before the readline libraries that we
+                # want to link with to avoid rl_insert() elimination
+                readline_extra_link_args = ('-Wl,-zrecord','-lreadline','-lncurses')
+                readline_libs = ()
+
             exts.append( Extension('readline', ['readline.c'],
                                    library_dirs=['/usr/lib/termcap'],
                                    extra_link_args=readline_extra_link_args,
@@ -759,7 +769,8 @@
 
         # socket(2)
         exts.append( Extension('_socket', ['socketmodule.c'],
-                               depends = ['socketmodule.h']) )
+                               depends = ['socketmodule.h'],
+                               libraries = ['socket', 'nsl']) )
         # Detect SSL support for the socket module (via _ssl)
         search_for_ssl_incs_in = [
                               '/usr/local/ssl/include',
@@ -1295,6 +1306,8 @@
             curses_defines.append(('_XOPEN_SOURCE_EXTENDED', '1'))
 
         if curses_library.startswith('ncurses'):
+            if host_platform == 'sunos5':
+                curses_includes.append('/usr/include/ncurses')
             curses_libs = [curses_library]
             exts.append( Extension('_curses', ['_cursesmodule.c'],
                                    include_dirs=curses_includes,
@@ -1319,10 +1332,32 @@
         # If the curses module is enabled, check for the panel module
         if (module_enabled(exts, '_curses') and
             self.compiler.find_library_file(lib_dirs, panel_library)):
+            panel_lib_dirs = []
+            if host_platform == 'sunos5':
+                # Look for libpanel under /usr/gnu/lib on Solaris.
+                # os.uname() does not include the processor. platform.uname()
+                # does, but the platform module is not available in setup.
+                # Work around this by parsing os.system('uname -p') output.
+                tmpfile = os.path.join(self.build_temp, 'processor')
+                if not os.path.exists(self.build_temp):
+                    os.makedirs(self.build_temp)
+                os.system('/usr/bin/uname -p > %s 2> /dev/null' %tmpfile)
+                processor = ''
+                try:
+                    with open(tmpfile) as fp:
+                        processor = fp.readline().strip()
+                finally:
+                    os.unlink(tmpfile)
+                if processor == 'sparc':
+                    panel_lib_dirs.append('/usr/gnu/lib/sparcv9')
+                else:
+                    panel_lib_dirs.append('/usr/gnu/lib/amd64')
             exts.append( Extension('_curses_panel', ['_curses_panel.c'],
                                    include_dirs=curses_includes,
                                    define_macros=curses_defines,
-                                   libraries = [panel_library] + curses_libs) )
+                                   libraries = [panel_library] + curses_libs,
+                                   library_dirs = panel_lib_dirs,
+                                   runtime_library_dirs = panel_lib_dirs) )
         else:
             missing.append('_curses_panel')
 
@@ -1918,7 +1953,7 @@
             # this option. If you want to compile ctypes with the Sun
             # compiler, please research a proper solution, instead of
             # finding some -z option for the Sun compiler.
-            extra_link_args.append('-mimpure-text')
+            pass
 
         elif host_platform.startswith('hp-ux'):
             extra_link_args.append('-fPIC')