Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Upstream-Status: Pending |
| 2 | |
| 3 | get the sys.lib from python itself and do not use hardcoded value of 'lib' |
| 4 | |
| 5 | 02/2015 Rebased for 3.4.2 |
| 6 | |
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 8 | Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com> |
| 9 | |
| 10 | Index: Python-3.4.2/Include/pythonrun.h |
| 11 | =================================================================== |
| 12 | --- Python-3.4.2.orig/Include/pythonrun.h |
| 13 | +++ Python-3.4.2/Include/pythonrun.h |
| 14 | @@ -220,6 +220,8 @@ int _Py_CheckPython3(); |
| 15 | /* In their own files */ |
| 16 | PyAPI_FUNC(const char *) Py_GetVersion(void); |
| 17 | PyAPI_FUNC(const char *) Py_GetPlatform(void); |
| 18 | +PyAPI_FUNC(const char *) Py_GetArch(void); |
| 19 | +PyAPI_FUNC(const char *) Py_GetLib(void); |
| 20 | PyAPI_FUNC(const char *) Py_GetCopyright(void); |
| 21 | PyAPI_FUNC(const char *) Py_GetCompiler(void); |
| 22 | PyAPI_FUNC(const char *) Py_GetBuildInfo(void); |
| 23 | Index: Python-3.4.2/Lib/distutils/command/install.py |
| 24 | =================================================================== |
| 25 | --- Python-3.4.2.orig/Lib/distutils/command/install.py |
| 26 | +++ Python-3.4.2/Lib/distutils/command/install.py |
| 27 | @@ -19,6 +19,8 @@ from site import USER_BASE |
| 28 | from site import USER_SITE |
| 29 | HAS_USER_SITE = True |
| 30 | |
| 31 | +libname = sys.lib |
| 32 | + |
| 33 | WINDOWS_SCHEME = { |
| 34 | 'purelib': '$base/Lib/site-packages', |
| 35 | 'platlib': '$base/Lib/site-packages', |
| 36 | @@ -30,7 +32,7 @@ WINDOWS_SCHEME = { |
| 37 | INSTALL_SCHEMES = { |
| 38 | 'unix_prefix': { |
| 39 | 'purelib': '$base/lib/python$py_version_short/site-packages', |
| 40 | - 'platlib': '$platbase/lib/python$py_version_short/site-packages', |
| 41 | + 'platlib': '$platbase/'+libname+'/python$py_version_short/site-packages', |
| 42 | 'headers': '$base/include/python$py_version_short$abiflags/$dist_name', |
| 43 | 'scripts': '$base/bin', |
| 44 | 'data' : '$base', |
| 45 | Index: Python-3.4.2/Lib/pydoc.py |
| 46 | =================================================================== |
| 47 | --- Python-3.4.2.orig/Lib/pydoc.py |
| 48 | +++ Python-3.4.2/Lib/pydoc.py |
| 49 | @@ -394,7 +394,7 @@ class Doc: |
| 50 | |
| 51 | docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS) |
| 52 | |
| 53 | - basedir = os.path.join(sys.base_exec_prefix, "lib", |
| 54 | + basedir = os.path.join(sys.base_exec_prefix, sys.lib, |
| 55 | "python%d.%d" % sys.version_info[:2]) |
| 56 | if (isinstance(object, type(os)) and |
| 57 | (object.__name__ in ('errno', 'exceptions', 'gc', 'imp', |
| 58 | Index: Python-3.4.2/Lib/trace.py |
| 59 | =================================================================== |
| 60 | --- Python-3.4.2.orig/Lib/trace.py |
| 61 | +++ Python-3.4.2/Lib/trace.py |
| 62 | @@ -751,10 +751,10 @@ def main(argv=None): |
| 63 | # should I also call expanduser? (after all, could use $HOME) |
| 64 | |
| 65 | s = s.replace("$prefix", |
| 66 | - os.path.join(sys.base_prefix, "lib", |
| 67 | + os.path.join(sys.base_prefix, sys.lib, |
| 68 | "python" + sys.version[:3])) |
| 69 | s = s.replace("$exec_prefix", |
| 70 | - os.path.join(sys.base_exec_prefix, "lib", |
| 71 | + os.path.join(sys.base_exec_prefix, sys.lib, |
| 72 | "python" + sys.version[:3])) |
| 73 | s = os.path.normpath(s) |
| 74 | ignore_dirs.append(s) |
| 75 | Index: Python-3.4.2/Makefile.pre.in |
| 76 | =================================================================== |
| 77 | --- Python-3.4.2.orig/Makefile.pre.in |
| 78 | +++ Python-3.4.2/Makefile.pre.in |
| 79 | @@ -101,6 +101,8 @@ PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS |
| 80 | |
| 81 | # Machine-dependent subdirectories |
| 82 | MACHDEP= @MACHDEP@ |
| 83 | +LIB= @LIB@ |
| 84 | +ARCH= @ARCH@ |
| 85 | |
| 86 | # Multiarch directory (may be empty) |
| 87 | MULTIARCH= @MULTIARCH@ |
| 88 | @@ -120,7 +122,7 @@ LIBDIR= @libdir@ |
| 89 | MANDIR= @mandir@ |
| 90 | INCLUDEDIR= @includedir@ |
| 91 | CONFINCLUDEDIR= $(exec_prefix)/include |
| 92 | -SCRIPTDIR= $(prefix)/lib |
| 93 | +SCRIPTDIR= @libdir@ |
| 94 | ABIFLAGS= @ABIFLAGS@ |
| 95 | |
| 96 | # Detailed destination directories |
| 97 | @@ -712,6 +714,7 @@ Modules/getpath.o: $(srcdir)/Modules/get |
| 98 | -DEXEC_PREFIX='"$(exec_prefix)"' \ |
| 99 | -DVERSION='"$(VERSION)"' \ |
| 100 | -DVPATH='"$(VPATH)"' \ |
| 101 | + -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' \ |
| 102 | -o $@ $(srcdir)/Modules/getpath.c |
| 103 | |
| 104 | Modules/python.o: $(srcdir)/Modules/python.c |
| 105 | @@ -780,7 +783,7 @@ $(AST_C): $(AST_H) $(AST_ASDL) $(ASDLGEN |
| 106 | Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H) |
| 107 | |
| 108 | Python/getplatform.o: $(srcdir)/Python/getplatform.c |
| 109 | - $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c |
| 110 | + $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' -o $@ $(srcdir)/Python/getplatform.c |
| 111 | |
| 112 | Python/importdl.o: $(srcdir)/Python/importdl.c |
| 113 | $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c |
| 114 | Index: Python-3.4.2/Modules/getpath.c |
| 115 | =================================================================== |
| 116 | --- Python-3.4.2.orig/Modules/getpath.c |
| 117 | +++ Python-3.4.2/Modules/getpath.c |
| 118 | @@ -117,9 +117,11 @@ |
| 119 | #define EXEC_PREFIX PREFIX |
| 120 | #endif |
| 121 | |
| 122 | +#define LIB_PYTHON LIB "/python" VERSION |
| 123 | + |
| 124 | #ifndef PYTHONPATH |
| 125 | -#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \ |
| 126 | - EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" |
| 127 | +#define PYTHONPATH PREFIX "/" LIB_PYTHON ":" \ |
| 128 | + EXEC_PREFIX "/" LIB_PYTHON "/lib-dynload" |
| 129 | #endif |
| 130 | |
| 131 | #ifndef LANDMARK |
| 132 | @@ -130,6 +132,7 @@ static wchar_t prefix[MAXPATHLEN+1]; |
| 133 | static wchar_t exec_prefix[MAXPATHLEN+1]; |
| 134 | static wchar_t progpath[MAXPATHLEN+1]; |
| 135 | static wchar_t *module_search_path = NULL; |
| 136 | +static wchar_t *lib_python = L"" LIB_PYTHON; |
| 137 | |
| 138 | static void |
| 139 | reduce(wchar_t *dir) |
| 140 | Index: Python-3.4.2/Python/getplatform.c |
| 141 | =================================================================== |
| 142 | --- Python-3.4.2.orig/Python/getplatform.c |
| 143 | +++ Python-3.4.2/Python/getplatform.c |
| 144 | @@ -10,3 +10,23 @@ Py_GetPlatform(void) |
| 145 | { |
| 146 | return PLATFORM; |
| 147 | } |
| 148 | + |
| 149 | +#ifndef ARCH |
| 150 | +#define ARCH "unknown" |
| 151 | +#endif |
| 152 | + |
| 153 | +const char * |
| 154 | +Py_GetArch(void) |
| 155 | +{ |
| 156 | + return ARCH; |
| 157 | +} |
| 158 | + |
| 159 | +#ifndef LIB |
| 160 | +#define LIB "lib" |
| 161 | +#endif |
| 162 | + |
| 163 | +const char * |
| 164 | +Py_GetLib(void) |
| 165 | +{ |
| 166 | + return LIB; |
| 167 | +} |
| 168 | Index: Python-3.4.2/Python/sysmodule.c |
| 169 | =================================================================== |
| 170 | --- Python-3.4.2.orig/Python/sysmodule.c |
| 171 | +++ Python-3.4.2/Python/sysmodule.c |
| 172 | @@ -1697,6 +1697,10 @@ _PySys_Init(void) |
| 173 | PyUnicode_FromString(Py_GetCopyright())); |
| 174 | SET_SYS_FROM_STRING("platform", |
| 175 | PyUnicode_FromString(Py_GetPlatform())); |
| 176 | + SET_SYS_FROM_STRING("arch", |
| 177 | + PyUnicode_FromString(Py_GetArch())); |
| 178 | + SET_SYS_FROM_STRING("lib", |
| 179 | + PyUnicode_FromString(Py_GetLib())); |
| 180 | SET_SYS_FROM_STRING("executable", |
| 181 | PyUnicode_FromWideChar( |
| 182 | Py_GetProgramFullPath(), -1)); |
| 183 | Index: Python-3.4.2/setup.py |
| 184 | =================================================================== |
| 185 | --- Python-3.4.2.orig/setup.py |
| 186 | +++ Python-3.4.2/setup.py |
| 187 | @@ -454,7 +454,7 @@ class PyBuildExt(build_ext): |
| 188 | # directories (i.e. '.' and 'Include') must be first. See issue |
| 189 | # 10520. |
| 190 | if not cross_compiling: |
| 191 | - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') |
| 192 | + add_dir_to_list(self.compiler.library_dirs, os.path.join('/usr/local', sys.lib)) |
| 193 | add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
| 194 | # only change this for cross builds for 3.3, issues on Mageia |
| 195 | if cross_compiling: |
| 196 | @@ -512,8 +512,7 @@ class PyBuildExt(build_ext): |
| 197 | # be assumed that no additional -I,-L directives are needed. |
| 198 | if not cross_compiling: |
| 199 | lib_dirs = self.compiler.library_dirs + [ |
| 200 | - '/lib64', '/usr/lib64', |
| 201 | - '/lib', '/usr/lib', |
| 202 | + '/' + sys.lib, '/usr/' + sys.lib, |
| 203 | ] |
| 204 | inc_dirs = self.compiler.include_dirs + ['/usr/include'] |
| 205 | else: |
| 206 | @@ -696,11 +695,11 @@ class PyBuildExt(build_ext): |
| 207 | elif curses_library: |
| 208 | readline_libs.append(curses_library) |
| 209 | elif self.compiler.find_library_file(lib_dirs + |
| 210 | - ['/usr/lib/termcap'], |
| 211 | + ['/usr/'+sys.lib+'/termcap'], |
| 212 | 'termcap'): |
| 213 | readline_libs.append('termcap') |
| 214 | exts.append( Extension('readline', ['readline.c'], |
| 215 | - library_dirs=['/usr/lib/termcap'], |
| 216 | + library_dirs=['/usr/'+sys.lib+'/termcap'], |
| 217 | extra_link_args=readline_extra_link_args, |
| 218 | libraries=readline_libs) ) |
| 219 | else: |
| 220 | Index: Python-3.4.2/Lib/sysconfig.py |
| 221 | =================================================================== |
| 222 | --- Python-3.4.2.orig/Lib/sysconfig.py |
| 223 | +++ Python-3.4.2/Lib/sysconfig.py |
| 224 | @@ -20,10 +20,10 @@ __all__ = [ |
| 225 | |
| 226 | _INSTALL_SCHEMES = { |
| 227 | 'posix_prefix': { |
| 228 | - 'stdlib': '{installed_base}/lib/python{py_version_short}', |
| 229 | - 'platstdlib': '{platbase}/lib/python{py_version_short}', |
| 230 | + 'stdlib': '{installed_base}/'+sys.lib+'/python{py_version_short}', |
| 231 | + 'platstdlib': '{platbase}/'+sys.lib+'/python{py_version_short}', |
| 232 | 'purelib': '{base}/lib/python{py_version_short}/site-packages', |
| 233 | - 'platlib': '{platbase}/lib/python{py_version_short}/site-packages', |
| 234 | + 'platlib': '{platbase}/'+sys.lib+'/python{py_version_short}/site-packages', |
| 235 | 'include': |
| 236 | '{installed_base}/include/python{py_version_short}{abiflags}', |
| 237 | 'platinclude': |
| 238 | @@ -32,10 +32,10 @@ _INSTALL_SCHEMES = { |
| 239 | 'data': '{base}', |
| 240 | }, |
| 241 | 'posix_home': { |
| 242 | - 'stdlib': '{installed_base}/lib/python', |
| 243 | - 'platstdlib': '{base}/lib/python', |
| 244 | + 'stdlib': '{installed_base}/'+sys.lib+'/python', |
| 245 | + 'platstdlib': '{base}/'+sys.lib+'/python', |
| 246 | 'purelib': '{base}/lib/python', |
| 247 | - 'platlib': '{base}/lib/python', |
| 248 | + 'platlib': '{base}/'+sys.lib+'/python', |
| 249 | 'include': '{installed_base}/include/python', |
| 250 | 'platinclude': '{installed_base}/include/python', |
| 251 | 'scripts': '{base}/bin', |
| 252 | @@ -61,10 +61,10 @@ _INSTALL_SCHEMES = { |
| 253 | 'data': '{userbase}', |
| 254 | }, |
| 255 | 'posix_user': { |
| 256 | - 'stdlib': '{userbase}/lib/python{py_version_short}', |
| 257 | - 'platstdlib': '{userbase}/lib/python{py_version_short}', |
| 258 | + 'stdlib': '{userbase}/'+sys.lib+'/python{py_version_short}', |
| 259 | + 'platstdlib': '{userbase}/'+sys.lib+'/python{py_version_short}', |
| 260 | 'purelib': '{userbase}/lib/python{py_version_short}/site-packages', |
| 261 | - 'platlib': '{userbase}/lib/python{py_version_short}/site-packages', |
| 262 | + 'platlib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages', |
| 263 | 'include': '{userbase}/include/python{py_version_short}', |
| 264 | 'scripts': '{userbase}/bin', |
| 265 | 'data': '{userbase}', |
| 266 | Index: Python-3.4.2/configure.ac |
| 267 | =================================================================== |
| 268 | --- Python-3.4.2.orig/configure.ac |
| 269 | +++ Python-3.4.2/configure.ac |
| 270 | @@ -791,6 +791,41 @@ esac |
| 271 | MULTIARCH=$($CC --print-multiarch 2>/dev/null) |
| 272 | AC_SUBST(MULTIARCH) |
| 273 | |
| 274 | +AC_SUBST(ARCH) |
| 275 | +AC_MSG_CHECKING(ARCH) |
| 276 | +ARCH=`uname -m` |
| 277 | +case $ARCH in |
| 278 | +i?86) ARCH=i386;; |
| 279 | +esac |
| 280 | +AC_MSG_RESULT($ARCH) |
| 281 | + |
| 282 | +AC_SUBST(LIB) |
| 283 | +AC_MSG_CHECKING(LIB) |
| 284 | +case $ac_sys_system in |
| 285 | +Linux*) |
| 286 | + # Test if the compiler is 64bit |
| 287 | + echo 'int i;' > conftest.$ac_ext |
| 288 | + python_cv_cc_64bit_output=no |
| 289 | + if AC_TRY_EVAL(ac_compile); then |
| 290 | + case `/usr/bin/file conftest.$ac_objext` in |
| 291 | + *"ELF 64"*) |
| 292 | + python_cv_cc_64bit_output=yes |
| 293 | + ;; |
| 294 | + esac |
| 295 | + fi |
| 296 | + rm -rf conftest* |
| 297 | + ;; |
| 298 | +esac |
| 299 | + |
| 300 | +case $ARCH:$python_cv_cc_64bit_output in |
| 301 | +ppc64:yes | powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes) |
| 302 | + LIB="lib64" |
| 303 | + ;; |
| 304 | +*:*) |
| 305 | + LIB="lib" |
| 306 | + ;; |
| 307 | +esac |
| 308 | +AC_MSG_RESULT($LIB) |
| 309 | |
| 310 | AC_SUBST(LIBRARY) |
| 311 | AC_MSG_CHECKING(LIBRARY) |
| 312 | Index: Python-3.4.2/Lib/site.py |
| 313 | =================================================================== |
| 314 | --- Python-3.4.2.orig/Lib/site.py |
| 315 | +++ Python-3.4.2/Lib/site.py |
| 316 | @@ -304,13 +304,19 @@ def getsitepackages(prefixes=None): |
| 317 | seen.add(prefix) |
| 318 | |
| 319 | if os.sep == '/': |
| 320 | - sitepackages.append(os.path.join(prefix, "lib", |
| 321 | + sitepackages.append(os.path.join(prefix, sys.lib, |
| 322 | "python" + sys.version[:3], |
| 323 | "site-packages")) |
| 324 | - sitepackages.append(os.path.join(prefix, "lib", "site-python")) |
| 325 | + if sys.lib != "lib": |
| 326 | + sitepackages.append(os.path.join(prefix, "lib", |
| 327 | + "python" + sys.version[:3], |
| 328 | + "site-packages")) |
| 329 | + sitepackages.append(os.path.join(prefix, sys.lib, "site-python")) |
| 330 | + if sys.lib != "lib": |
| 331 | + sitepackages.append(os.path.join(prefix, sys.lib, "site-python")) |
| 332 | else: |
| 333 | sitepackages.append(prefix) |
| 334 | - sitepackages.append(os.path.join(prefix, "lib", "site-packages")) |
| 335 | + sitepackages.append(os.path.join(prefix, sys.lib, "site-packages")) |
| 336 | if sys.platform == "darwin": |
| 337 | # for framework builds *only* we add the standard Apple |
| 338 | # locations. |