20367692 python /usr/gnu/lib runpath considered unnecessary s11-update
authorJohn Beck <John.Beck@Oracle.COM>
Mon, 16 Mar 2015 13:00:40 -0700
branchs11-update
changeset 3978 adf3ab1a234a
parent 3977 3ede7a3f6483
child 3979 46744fa00de4
20367692 python /usr/gnu/lib runpath considered unnecessary
components/python/python27/Makefile
components/python/python27/patches/02-setup.patch
components/python/python34/Makefile
components/python/python34/patches/03-setup.patch
--- a/components/python/python27/Makefile	Thu Mar 19 09:45:43 2015 -0700
+++ b/components/python/python27/Makefile	Mon Mar 16 13:00:40 2015 -0700
@@ -85,11 +85,6 @@
 CFLAGS += -xO5 $(PYFLAGS.$(MACH))
 LDFLAGS += -xO5 $(PYFLAGS.$(MACH))
 
-# add /usr/gnu/lib to the library search/run path
-LDFLAGS.32 = -R/usr/gnu/lib -L/usr/gnu/lib
-LDFLAGS.64 = -R/usr/gnu/lib/$(MACH64) -L/usr/gnu/lib/$(MACH64)
-LDFLAGS += $(LDFLAGS.$(BITS))
-
 # Python puts its header files in a special place.
 LINT_FLAGS +=	-I$(SOURCE_DIR)/Include
 
--- a/components/python/python27/patches/02-setup.patch	Thu Mar 19 09:45:43 2015 -0700
+++ b/components/python/python27/patches/02-setup.patch	Mon Mar 16 13:00:40 2015 -0700
@@ -2,21 +2,33 @@
 As it is Solaris-specific, it is not suitable for upstream.
 
 --- Python-2.7.9/setup.py.~1~	2014-12-10 08:00:01.000000000 -0800
-+++ Python-2.7.9/setup.py	2014-12-17 11:39:50.963351605 -0800
[email protected]@ -439,9 +439,9 @@
++++ Python-2.7.9/setup.py	2015-03-16 12:49:18.632646720 -0700
[email protected]@ -6,6 +6,7 @@
+ import sys, os, imp, re, optparse
+ from glob import glob
+ from platform import machine as platform_machine
++from platform import processor as platform_processor
+ import sysconfig
+ 
+ from distutils import log
[email protected]@ -438,10 +439,13 @@
+             os.unlink(tmpfile)
  
      def detect_modules(self):
-         # Ensure that /usr/local is always used
--        if not cross_compiling:
+-        # Ensure that /usr/local is always used
+         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 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 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')
          if cross_compiling:
              self.add_gcc_paths()
          self.add_multiarch_paths()
[email protected]@ -765,6 +765,13 @@
[email protected]@ -765,6 +769,13 @@
                                                       ['/usr/lib/termcap'],
                                                       'termcap'):
                  readline_libs.append('termcap')
@@ -30,7 +42,7 @@
              exts.append( Extension('readline', ['readline.c'],
                                     library_dirs=['/usr/lib/termcap'],
                                     extra_link_args=readline_extra_link_args,
[email protected]@ -786,7 +793,7 @@
[email protected]@ -786,7 +797,7 @@
          # socket(2)
          exts.append( Extension('_socket', ['socketmodule.c', 'timemodule.c'],
                                 depends=['socketmodule.h'],
@@ -39,13 +51,50 @@
          # Detect SSL support for the socket module (via _ssl)
          search_for_ssl_incs_in = [
                                '/usr/local/ssl/include',
[email protected]@ -1587,9 +1594,14 @@
[email protected]@ -1350,8 +1361,11 @@
+                 # _curses_panel.so must link with panelw.
+                 panel_library = 'panelw'
+             curses_libs = [curses_library]
+-            curses_incs = find_file('curses.h', inc_dirs,
+-                                    [os.path.join(d, 'ncursesw') for d in inc_dirs])
++            if host_platform == 'sunos5':
++                curses_incs = ['/usr/include/ncurses']
++            else:
++                curses_incs = find_file('curses.h', inc_dirs,
++                                        [os.path.join(d, 'ncursesw') for d in inc_dirs])
+             exts.append( Extension('_curses', ['_cursesmodule.c'],
+                                    include_dirs = curses_incs,
+                                    libraries = curses_libs) )
[email protected]@ -1373,9 +1387,21 @@
+         # 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' and "DFLAGS" in os.environ:
++                # Look for libpanel under /usr/gnu/lib on Solaris.
++                if os.environ["DFLAGS"] == '-32':
++                    panel_lib_dirs.append('/usr/gnu/lib')
++                else:
++                    if platform_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_incs,
+-                                   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')
+ 
[email protected]@ -1587,9 +1613,14 @@
                  sysconfig.get_config_var('POSIX_SEMAPHORES_NOT_ENABLED')):
                  multiprocessing_srcs.append('_multiprocessing/semaphore.c')
  
-+	multiproc_libs = []
-+	if host_platform == 'sunos5':
-+	    multiproc_libs = [ "xnet" ]
++        multiproc_libs = []
++        if host_platform == 'sunos5':
++            multiproc_libs = [ "xnet" ]
 +
          if sysconfig.get_config_var('WITH_THREAD'):
              exts.append ( Extension('_multiprocessing', multiprocessing_srcs,
@@ -54,7 +103,7 @@
                                      include_dirs=["Modules/_multiprocessing"]))
          else:
              missing.append('_multiprocessing')
[email protected]@ -2083,7 +2095,8 @@
[email protected]@ -2083,7 +2114,8 @@
              # 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.
--- a/components/python/python34/Makefile	Thu Mar 19 09:45:43 2015 -0700
+++ b/components/python/python34/Makefile	Mon Mar 16 13:00:40 2015 -0700
@@ -92,10 +92,6 @@
 CFLAGS += -xO5 $(PYFLAGS.$(MACH))
 LDFLAGS += -xO5 $(PYFLAGS.$(MACH))
 
-# add /usr/gnu/lib to the library search/run path
-LDFLAGS.64 = -R/usr/gnu/lib/$(MACH64) -L/usr/gnu/lib/$(MACH64)
-LDFLAGS += $(LDFLAGS.$(BITS))
-
 # Python puts its header files in a special place.
 LINT_FLAGS +=	-I$(SOURCE_DIR)/Include
 
--- a/components/python/python34/patches/03-setup.patch	Thu Mar 19 09:45:43 2015 -0700
+++ b/components/python/python34/patches/03-setup.patch	Mon Mar 16 13:00:40 2015 -0700
@@ -1,9 +1,30 @@
 This patch modifies the setup script to support Solaris.
 As it is Solaris-specific, it is not suitable for upstream.
 
---- Python-3.4.2/setup.py.~2~	2015-02-03 13:28:29.343641665 -0800
-+++ Python-3.4.2/setup.py	2015-02-03 13:47:37.128749230 -0800
[email protected]@ -736,6 +736,13 @@
+--- 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
[email protected]@ -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()
[email protected]@ -736,6 +739,13 @@
                                                       ['/usr/lib/termcap'],
                                                       'termcap'):
                  readline_libs.append('termcap')
@@ -17,7 +38,7 @@
              exts.append( Extension('readline', ['readline.c'],
                                     library_dirs=['/usr/lib/termcap'],
                                     extra_link_args=readline_extra_link_args,
[email protected]@ -759,7 +766,8 @@
[email protected]@ -759,7 +769,8 @@
  
          # socket(2)
          exts.append( Extension('_socket', ['socketmodule.c'],
@@ -27,7 +48,50 @@
          # Detect SSL support for the socket module (via _ssl)
          search_for_ssl_incs_in = [
                                '/usr/local/ssl/include',
[email protected]@ -1918,7 +1926,7 @@
[email protected]@ -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,
[email protected]@ -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')
+ 
[email protected]@ -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.