Salome HOME
Update of products
[tools/install.git] / config_files / patches / python_patch_lib64.patch
1 diff -Naur --exclude=CVS Python-2.4.4/configure.in Python-2.4.4-patched/configure.in
2 --- Python-2.4.4/configure.in   2006-10-17 20:03:36.000000000 +0400
3 +++ Python-2.4.4-patched/configure.in   2007-04-23 19:31:52.000000000 +0400
4 @@ -494,6 +494,41 @@
5      ;;
6  esac
7  
8 +AC_SUBST(ARCH)
9 +AC_MSG_CHECKING(ARCH)
10 +ARCH=`uname -m`
11 +case $ARCH in
12 +i?86) ARCH=i386;;
13 +esac
14 +AC_MSG_RESULT($ARCH)
15 +
16 +AC_SUBST(LIB)
17 +AC_MSG_CHECKING(LIB)
18 +case $ac_sys_system in
19 +Linux*)
20 +  # Test if the compiler is 64bit
21 +  echo 'int i;' > conftest.$ac_ext
22 +  python_cv_cc_64bit_output=no
23 +  if AC_TRY_EVAL(ac_compile); then
24 +    case `/usr/bin/file conftest.$ac_objext` in
25 +    *"ELF 64"*)
26 +      python_cv_cc_64bit_output=yes
27 +      ;;
28 +    esac
29 +  fi
30 +  rm -rf conftest*
31 +  ;;
32 +esac
33 +
34 +case $ARCH:$python_cv_cc_64bit_output in
35 +powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
36 +  LIB="lib64"
37 +  ;;
38 +*:*)
39 +  LIB="lib"
40 +  ;;
41 +esac
42 +AC_MSG_RESULT($LIB)
43  
44  AC_SUBST(LIBRARY)
45  AC_MSG_CHECKING(LIBRARY)
46 diff -Naur --exclude=CVS Python-2.4.4/Include/pythonrun.h Python-2.4.4-patched/Include/pythonrun.h
47 --- Python-2.4.4/Include/pythonrun.h    2004-10-07 07:58:07.000000000 +0400
48 +++ Python-2.4.4-patched/Include/pythonrun.h    2007-04-23 19:10:18.000000000 +0400
49 @@ -93,6 +93,8 @@
50  /* In their own files */
51  PyAPI_FUNC(const char *) Py_GetVersion(void);
52  PyAPI_FUNC(const char *) Py_GetPlatform(void);
53 +PyAPI_FUNC(const char *) Py_GetArch(void);
54 +PyAPI_FUNC(const char *) Py_GetLib(void);
55  PyAPI_FUNC(const char *) Py_GetCopyright(void);
56  PyAPI_FUNC(const char *) Py_GetCompiler(void);
57  PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
58 diff -Naur --exclude=CVS Python-2.4.4/Lib/distutils/command/install.py Python-2.4.4-patched/Lib/distutils/command/install.py
59 --- Python-2.4.4/Lib/distutils/command/install.py       2005-01-20 22:15:39.000000000 +0300
60 +++ Python-2.4.4-patched/Lib/distutils/command/install.py       2007-04-23 19:12:27.000000000 +0400
61 @@ -19,6 +19,8 @@
62  from distutils.errors import DistutilsOptionError
63  from glob import glob
64  
65 +libname = sys.lib
66 +
67  if sys.version < "2.2":
68      WINDOWS_SCHEME = {
69          'purelib': '$base',
70 @@ -38,15 +40,15 @@
71  
72  INSTALL_SCHEMES = {
73      'unix_prefix': {
74 -        'purelib': '$base/lib/python$py_version_short/site-packages',
75 -        'platlib': '$platbase/lib/python$py_version_short/site-packages',
76 +        'purelib': '$base/'+libname+'/python$py_version_short/site-packages',
77 +        'platlib': '$platbase/'+libname+'/python$py_version_short/site-packages',
78          'headers': '$base/include/python$py_version_short/$dist_name',
79          'scripts': '$base/bin',
80          'data'   : '$base',
81          },
82      'unix_home': {
83 -        'purelib': '$base/lib/python',
84 -        'platlib': '$base/lib/python',
85 +        'purelib': '$base/'+libname+'/python',
86 +        'platlib': '$base/'+libname+'/python',
87          'headers': '$base/include/python/$dist_name',
88          'scripts': '$base/bin',
89          'data'   : '$base',
90 diff -Naur --exclude=CVS Python-2.4.4/Lib/distutils/sysconfig.py Python-2.4.4-patched/Lib/distutils/sysconfig.py
91 --- Python-2.4.4/Lib/distutils/sysconfig.py     2006-10-08 21:41:25.000000000 +0400
92 +++ Python-2.4.4-patched/Lib/distutils/sysconfig.py     2007-04-23 19:21:19.000000000 +0400
93 @@ -100,7 +100,7 @@
94  
95      if os.name == "posix":
96          libpython = os.path.join(prefix,
97 -                                 "lib", "python" + get_python_version())
98 +                                 sys.lib, "python" + get_python_version())
99          if standard_lib:
100              return libpython
101          else:
102 diff -Naur --exclude=CVS Python-2.4.4/Lib/distutils/tests/test_install.py Python-2.4.4-patched/Lib/distutils/tests/test_install.py
103 --- Python-2.4.4/Lib/distutils/tests/test_install.py    2004-06-26 03:02:59.000000000 +0400
104 +++ Python-2.4.4-patched/Lib/distutils/tests/test_install.py    2007-04-23 19:20:24.000000000 +0400
105 @@ -1,6 +1,7 @@
106  """Tests for distutils.command.install."""
107  
108  import os
109 +import sys
110  import unittest
111  
112  from distutils.command.install import install
113 @@ -38,7 +39,7 @@
114              expected = os.path.normpath(expected)
115              self.assertEqual(got, expected)
116  
117 -        libdir = os.path.join(destination, "lib", "python")
118 +        libdir = os.path.join(destination, sys.lib, "python")
119          check_path(cmd.install_lib, libdir)
120          check_path(cmd.install_platlib, libdir)
121          check_path(cmd.install_purelib, libdir)
122 diff -Naur --exclude=CVS Python-2.4.4/Lib/site.py Python-2.4.4-patched/Lib/site.py
123 --- Python-2.4.4/Lib/site.py    2004-07-20 06:28:28.000000000 +0400
124 +++ Python-2.4.4-patched/Lib/site.py    2007-04-23 19:23:19.000000000 +0400
125 @@ -179,12 +179,18 @@
126                  sitedirs = [os.path.join(prefix, "Lib", "site-packages")]
127              elif os.sep == '/':
128                  sitedirs = [os.path.join(prefix,
129 -                                         "lib",
130 +                                         sys.lib,
131                                           "python" + sys.version[:3],
132                                           "site-packages"),
133 -                            os.path.join(prefix, "lib", "site-python")]
134 +                            os.path.join(prefix, sys.lib, "site-python")]
135 +                if sys.lib != 'lib':
136 +                    sitedirs.append(os.path.join(prefix,
137 +                                                 'lib',
138 +                                                 "python" + sys.version[:3],
139 +                                                 "site-packages"))
140 +                    sitedirs.append(os.path.join(prefix, 'lib', "site-python"))
141              else:
142 -                sitedirs = [prefix, os.path.join(prefix, "lib", "site-packages")]
143 +                sitedirs = [prefix, os.path.join(prefix, sys.lib, "site-packages")]
144              if sys.platform == 'darwin':
145                  # for framework builds *only* we add the standard Apple
146                  # locations. Currently only per-user, but /Library and
147 diff -Naur --exclude=CVS Python-2.4.4/Makefile.pre.in Python-2.4.4-patched/Makefile.pre.in
148 --- Python-2.4.4/Makefile.pre.in        2006-10-08 21:41:25.000000000 +0400
149 +++ Python-2.4.4-patched/Makefile.pre.in        2007-04-23 19:34:43.000000000 +0400
150 @@ -70,6 +70,8 @@
151  
152  # Machine-dependent subdirectories
153  MACHDEP=       @MACHDEP@
154 +LIB=           @LIB@
155 +ARCH=          @ARCH@
156  
157  # Install prefix for architecture-independent files
158  prefix=                @prefix@
159 @@ -79,11 +81,11 @@
160  
161  # Expanded directories
162  BINDIR=                $(exec_prefix)/bin
163 -LIBDIR=                $(exec_prefix)/lib
164 +LIBDIR=                $(exec_prefix)/$(LIB)
165  MANDIR=                @mandir@
166  INCLUDEDIR=    @includedir@
167  CONFINCLUDEDIR=        $(exec_prefix)/include
168 -SCRIPTDIR=     $(prefix)/lib
169 +SCRIPTDIR=     $(prefix)/$(LIB)
170  
171  # Detailed destination directories
172  BINLIBDEST=    $(LIBDIR)/python$(VERSION)
173 @@ -471,7 +473,7 @@
174  Python/compile.o Python/symtable.o: $(GRAMMAR_H)
175  
176  Python/getplatform.o: $(srcdir)/Python/getplatform.c
177 -               $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
178 +               $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' -o $@ $(srcdir)/Python/getplatform.c
179  
180  Python/importdl.o: $(srcdir)/Python/importdl.c
181                 $(CC) -c $(PY_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
182 diff -Naur --exclude=CVS Python-2.4.4/Modules/getpath.c Python-2.4.4-patched/Modules/getpath.c
183 --- Python-2.4.4/Modules/getpath.c      2006-02-20 20:37:39.000000000 +0300
184 +++ Python-2.4.4-patched/Modules/getpath.c      2007-04-23 19:25:34.000000000 +0400
185 @@ -111,9 +111,17 @@
186  #define EXEC_PREFIX PREFIX
187  #endif
188  
189 +#ifndef LIB_PYTHON
190 +#if defined(__x86_64__)
191 +#define LIB_PYTHON "lib64/python" VERSION
192 +#else
193 +#define LIB_PYTHON "lib/python" VERSION
194 +#endif
195 +#endif
196 +
197  #ifndef PYTHONPATH
198 -#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
199 -              EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
200 +#define PYTHONPATH PREFIX "/" LIB_PYTHON ":" \
201 +              EXEC_PREFIX "/" LIB_PYTHON "/lib-dynload"
202  #endif
203  
204  #ifndef LANDMARK
205 @@ -124,7 +132,7 @@
206  static char exec_prefix[MAXPATHLEN+1];
207  static char progpath[MAXPATHLEN+1];
208  static char *module_search_path = NULL;
209 -static char lib_python[] = "lib/python" VERSION;
210 +static char lib_python[] = LIB_PYTHON;
211  
212  static void
213  reduce(char *dir)
214 diff -Naur --exclude=CVS Python-2.4.4/Python/getplatform.c Python-2.4.4-patched/Python/getplatform.c
215 --- Python-2.4.4/Python/getplatform.c   2000-09-02 03:29:29.000000000 +0400
216 +++ Python-2.4.4-patched/Python/getplatform.c   2007-04-23 19:27:19.000000000 +0400
217 @@ -10,3 +10,23 @@
218  {
219         return PLATFORM;
220  }
221 +
222 +#ifndef ARCH
223 +#define ARCH "unknown"
224 +#endif
225 +
226 +const char *
227 +Py_GetArch(void)
228 +{
229 +       return ARCH;
230 +}
231 +
232 +#ifndef LIB
233 +#define LIB "lib"
234 +#endif
235 +
236 +const char *
237 +Py_GetLib(void)
238 +{
239 +       return LIB;
240 +}
241 diff -Naur --exclude=CVS Python-2.4.4/Python/sysmodule.c Python-2.4.4-patched/Python/sysmodule.c
242 --- Python-2.4.4/Python/sysmodule.c     2006-10-05 22:08:58.000000000 +0400
243 +++ Python-2.4.4-patched/Python/sysmodule.c     2007-04-23 19:29:43.000000000 +0400
244 @@ -1035,6 +1035,10 @@
245                             PyString_FromString(Py_GetCopyright()));
246         SET_SYS_FROM_STRING("platform",
247                             PyString_FromString(Py_GetPlatform()));
248 +       SET_SYS_FROM_STRING("arch",
249 +                           PyString_FromString(Py_GetArch()));
250 +       SET_SYS_FROM_STRING("lib",
251 +                           PyString_FromString(Py_GetLib()));
252         SET_SYS_FROM_STRING("executable",
253                             PyString_FromString(Py_GetProgramFullPath()));
254         SET_SYS_FROM_STRING("prefix",
255 diff -Naur --exclude=CVS Python-2.4.4/setup.py Python-2.4.4-patched/setup.py
256 --- Python-2.4.4/setup.py       2006-10-08 21:41:25.000000000 +0400
257 +++ Python-2.4.4-patched/setup.py       2007-04-23 19:38:02.000000000 +0400
258 @@ -263,12 +263,12 @@
259          except NameError:
260              have_unicode = 0
261  
262 +        libname = sys.lib
263          # lib_dirs and inc_dirs are used to search for files;
264          # if a file is found in one of those directories, it can
265          # be assumed that no additional -I,-L directives are needed.
266          lib_dirs = self.compiler.library_dirs + [
267 -            '/lib64', '/usr/lib64',
268 -            '/lib', '/usr/lib',
269 +            libname, '/usr/'+libname
270              ]
271          inc_dirs = self.compiler.include_dirs + ['/usr/include']
272          exts = []
273 @@ -450,7 +450,7 @@
274              elif self.compiler.find_library_file(lib_dirs, 'curses'):
275                  readline_libs.append('curses')
276              elif self.compiler.find_library_file(lib_dirs +
277 -                                               ['/usr/lib/termcap'],
278 +                                               ['/usr/'+libname+'/termcap'],
279                                                 'termcap'):
280                  readline_libs.append('termcap')
281  
282 @@ -465,7 +465,7 @@
283                  readline_extra_link_args = ()
284  
285              exts.append( Extension('readline', ['readline.c'],
286 -                                   library_dirs=['/usr/lib/termcap'],
287 +                                   library_dirs=['/usr/'+libname+'/termcap'],
288                                     extra_link_args=readline_extra_link_args,
289                                     libraries=readline_libs) )
290          if platform not in ['mac']:
291 @@ -1069,8 +1069,8 @@
292              added_lib_dirs.append('/usr/openwin/lib')
293          elif os.path.exists('/usr/X11R6/include'):
294              include_dirs.append('/usr/X11R6/include')
295 -            added_lib_dirs.append('/usr/X11R6/lib64')
296 -            added_lib_dirs.append('/usr/X11R6/lib')
297 +            added_lib_dirs.append('/usr/X11R6/'+sys.lib)
298 +            #added_lib_dirs.append('/usr/X11R6/lib')
299          elif os.path.exists('/usr/X11R5/include'):
300              include_dirs.append('/usr/X11R5/include')
301              added_lib_dirs.append('/usr/X11R5/lib')