#10359: Let PIL search '.../lib64' directories for optional libraries if
appropriate
------------------------------+---------------------------------------------
   Reporter:  leif            |       Owner:  tbd                               
 
       Type:  defect          |      Status:  needs_review                      
 
   Priority:  major           |   Milestone:  sage-4.6.1                        
 
  Component:  packages        |    Keywords:  Python Imaging libary JPEG TIFF 
PNG
     Author:  Leif Leonhardy  |    Upstream:  N/A                               
 
   Reviewer:                  |      Merged:                                    
 
Work_issues:                  |  
------------------------------+---------------------------------------------

Comment(by leif):

 For convenience, here's the new, second patch we now apply to `setup.py`:
 {{{
 #!patch
 diff -Nur src-dont-add-system-libs-if-binary-build/setup.py src-search-
 lib64-dirs-if-appropriate/setup.py
 --- src-dont-add-system-libs-if-binary-build/setup.py   2010-12-01
 05:02:59.000000000 +0100
 +++ src-search-lib64-dirs-if-appropriate/setup.py       2010-12-01
 06:16:25.000000000 +0100
 @@ -34,12 +34,12 @@
  #
  # TIFF_ROOT = libinclude("/opt/tiff")

 -SAGE_BINARY_BUILD = False
 -if 'SAGE_BINARY_BUILD' in os.environ and os.environ['SAGE_BINARY_BUILD']
 == 'yes':
 -    SAGE_BINARY_BUILD = True
 +SAGE_BINARY_BUILD = os.environ.get('SAGE_BINARY_BUILD','no') == 'yes'

  if SAGE_BINARY_BUILD:
 -    print("Installing in binary build mode.")
 +    print("Installing in binary build mode, i.e. not including system
 libraries.")
 +    print("Copy the desired system libraries to SAGE_LOCAL/lib before
 building")
 +    print("Sage if you want them to be included in your binary
 distribution.")
      FREETYPE_ROOT = JPEG_ROOT = TIFF_ROOT = ZLIB_ROOT = TCL_ROOT = \
          libinclude(os.environ['SAGE_LOCAL'])
  else:
 @@ -99,11 +99,27 @@
  except ImportError:
      _tkinter = None

 -if 'SAGE_PIL_NOTK' in os.environ and os.environ['SAGE_PIL_NOTK'] ==
 'yes':
 -    print("Disabling TK in PIL build.")
 +if os.environ.get('SAGE_PIL_NOTK','no') == 'yes':
 +    print("Disabling Tkinter (Tcl/Tk) support in PIL build.")
      # Force None, so don't build tk -- this helps on some platforms.
      _tkinter = None

 +
 +# On 64-bit Fedora etc., search e.g. /usr/lib64 rather than the (32-bit)
 +# /usr/lib directory (cf. #10359):
 +check_lib64 = sysconfig.get_config_var("SIZEOF_VOID_P") == 8 # 64-bit
 pointers
 +
 +def lib_or_lib64(prefix):
 +    lib = os.path.join(prefix, "lib")
 +    lib64 = os.path.join(prefix, "lib64")
 +
 +    if ( check_lib64 and os.path.exists(lib64) and
 +         os.path.realpath(lib64) != os.path.realpath(lib) ):
 +        return lib64
 +    else:
 +        return lib
 +
 +
  def add_directory(path, dir, where=None):
      if dir and os.path.isdir(dir) and dir not in path:
          if where is None:
 @@ -159,6 +175,7 @@
  #            add_directory(library_dirs, "/usr/local/lib")
              # FIXME: check /opt/stuff directories here?

 +            # Note: Within Sage, prefix is SAGE_LOCAL.
              prefix = sysconfig.get_config_var("prefix")
              if prefix:
                  add_directory(library_dirs, os.path.join(prefix, "lib"))
 @@ -210,10 +227,12 @@
          # add standard directories

          if not SAGE_BINARY_BUILD:
 -            add_directory(library_dirs, "/usr/local/lib")
 +            # Only add / search system directories if we're not building
 +            # a binary distribution, and if at all, add the proper ones
 (#10359):
 +            add_directory(library_dirs, lib_or_lib64("/usr/local"))
              add_directory(include_dirs, "/usr/local/include")

 -            add_directory(library_dirs, "/usr/lib")
 +            add_directory(library_dirs, lib_or_lib64("/usr"))
              add_directory(include_dirs, "/usr/include")

          #
 @@ -223,6 +242,10 @@
          self.compiler.library_dirs = library_dirs +
 self.compiler.library_dirs
          self.compiler.include_dirs = include_dirs +
 self.compiler.include_dirs

 +        # DEBUG;
 +        print "Searching the following library directories:\n",
 self.compiler.library_dirs
 +        print "Searching the following include directories:\n",
 self.compiler.include_dirs
 +
          #
          # look for available libraries
 }}}

 (Note that this one is ''based on the first one''; both affect similar
 parts, so the second one cannot be applied independently of the previous,
 first one. We ''may'' merge them later, though they fix different issues.)

 P.S.: Note also that #9864 (which this spkg is based on) currently still
 needs review, too.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10359#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to