[Distutils] bdist_rpm and bdist on x86-64

M.-A. Lemburg mal at egenix.com
Mon Apr 18 20:05:15 CEST 2005


Jeremy Sanders wrote:
> On Fri, 15 Apr 2005, M.-A. Lemburg wrote:
> 
>>> All linux x86-64 distributions use lib64 instead of lib for 64 bit 
>>> libraries. It looks like this code needs to be cleverer.
>>
>>
>> Patches are welcome :-)
> 
> 
> Attached is a patch which allows distutils to find the lib directory on 
> x86-64. It uses sys.path to search for the Makefile.
 >
> It also changes command/install.py to change platlib to lib64 if lib64 
> was returned by get_python_lib.
> 
> It might be a bit messy for distutils of course, but it shouldn't affect 
> non-x86-64 platforms.
> 
> Opinions?
> 
> Jeremy
> 
> 
> ------------------------------------------------------------------------
> 
> --- sysconfig.py~	2005-03-03 11:08:02.000000000 +0000
> +++ sysconfig.py	2005-04-16 12:20:03.499916704 +0100
> @@ -99,8 +99,17 @@
>          prefix = plat_specific and EXEC_PREFIX or PREFIX
>  
>      if os.name == "posix":
> -        libpython = os.path.join(prefix,
> -                                 "lib", "python" + get_python_version())
> +        # search for Makefile in path to locate lib directory, in case
> +        # python isn't in /prefix/lib (e.g. /prefix/lib64)
> +        for i in sys.path:
> +            if os.access( os.path.join(i, "config", "Makefile"), os.F_OK ):

Why not os.exists() ?

> +                libpython = i
> +                break
> +        else:
> +            # Makefile not found in path
> +            libpython = os.path.join(prefix,
> +                                     "lib", "python" + get_python_version())
> +

Wouldn't checking for the lib file in either lib64
or lib be more reliable ?

>          if standard_lib:
>              return libpython
>          else:
> --- command/install.py~	2005-01-20 19:14:17.000000000 +0000
> +++ command/install.py	2005-04-16 13:12:07.264032376 +0100
> @@ -10,6 +10,7 @@
>  
>  import sys, os, string
>  from types import *
> +from distutils.sysconfig import get_python_lib
>  from distutils.core import Command
>  from distutils.debug import DEBUG
>  from distutils.sysconfig import get_config_vars
> @@ -36,17 +37,25 @@
>          'data'   : '$base',
>      }
>  
> +
> +# Normally unix distributions use lib to store python platlib
> +# However, under x86-64, platlib uses lib64
> +unix_platlib = 'lib'
> +if get_python_lib().find('lib64') != -1:
> +    unix_platlib = 'lib64'
> +

Hmm, this is not entirely correct, e.g. Suse 9.2 puts
the site-packages directory and all the other .py files
into /usr/lib64 as well - not only the platforma dependent
files.

Not sure what other AMD64 distros do... but I have a feeling
the /lib/ should *always* be replaced by unix_platlib.

>  INSTALL_SCHEMES = {
>      'unix_prefix': {
>          'purelib': '$base/lib/python$py_version_short/site-packages',
> -        'platlib': '$platbase/lib/python$py_version_short/site-packages',
> +        'platlib':
> +        '$platbase/%s/python$py_version_short/site-packages' % unix_platlib,
>          'headers': '$base/include/python$py_version_short/$dist_name',
>          'scripts': '$base/bin',
>          'data'   : '$base',
>          },
>      'unix_home': {
>          'purelib': '$base/lib/python',
> -        'platlib': '$base/lib/python',
> +        'platlib': '$base/%s/python' % unix_platlib,
>          'headers': '$base/include/python/$dist_name',
>          'scripts': '$base/bin',
>          'data'   : '$base',
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG at python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 18 2005)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the Distutils-SIG mailing list