blob: 44ec424cd23231e5b486f2ac2d10c0ad0182387d [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Upstream-Status: Pending
2
3get the sys.lib from python itself and do not use hardcoded value of 'lib'
4
502/2015 Rebased for 3.4.2
6
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
8Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com>
9
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050010Index: Python-3.5.0/Include/pythonrun.h
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050012--- Python-3.5.0.orig/Include/pythonrun.h
13+++ Python-3.5.0/Include/pythonrun.h
14@@ -23,6 +23,9 @@ typedef struct {
15 } PyCompilerFlags;
16 #endif
17
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018+PyAPI_FUNC(const char *) Py_GetArch(void);
19+PyAPI_FUNC(const char *) Py_GetLib(void);
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020+
21 #ifndef Py_LIMITED_API
22 PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
23 PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
24Index: Python-3.5.0/Lib/distutils/command/install.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050026--- Python-3.5.0.orig/Lib/distutils/command/install.py
27+++ Python-3.5.0/Lib/distutils/command/install.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028@@ -19,6 +19,8 @@ from site import USER_BASE
29 from site import USER_SITE
30 HAS_USER_SITE = True
31
32+libname = sys.lib
33+
34 WINDOWS_SCHEME = {
35 'purelib': '$base/Lib/site-packages',
36 'platlib': '$base/Lib/site-packages',
37@@ -30,7 +32,7 @@ WINDOWS_SCHEME = {
38 INSTALL_SCHEMES = {
39 'unix_prefix': {
40 'purelib': '$base/lib/python$py_version_short/site-packages',
41- 'platlib': '$platbase/lib/python$py_version_short/site-packages',
42+ 'platlib': '$platbase/'+libname+'/python$py_version_short/site-packages',
43 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
44 'scripts': '$base/bin',
45 'data' : '$base',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046Index: Python-3.5.0/Lib/pydoc.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -050047===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050048--- Python-3.5.0.orig/Lib/pydoc.py
49+++ Python-3.5.0/Lib/pydoc.py
50@@ -393,7 +393,7 @@ class Doc:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
52 docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS)
53
54- basedir = os.path.join(sys.base_exec_prefix, "lib",
55+ basedir = os.path.join(sys.base_exec_prefix, sys.lib,
56 "python%d.%d" % sys.version_info[:2])
57 if (isinstance(object, type(os)) and
58 (object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050059Index: Python-3.5.0/Lib/trace.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050061--- Python-3.5.0.orig/Lib/trace.py
62+++ Python-3.5.0/Lib/trace.py
63@@ -749,10 +749,10 @@ def main(argv=None):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064 # should I also call expanduser? (after all, could use $HOME)
65
66 s = s.replace("$prefix",
67- os.path.join(sys.base_prefix, "lib",
68+ os.path.join(sys.base_prefix, sys.lib,
69 "python" + sys.version[:3]))
70 s = s.replace("$exec_prefix",
71- os.path.join(sys.base_exec_prefix, "lib",
72+ os.path.join(sys.base_exec_prefix, sys.lib,
73 "python" + sys.version[:3]))
74 s = os.path.normpath(s)
75 ignore_dirs.append(s)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050076Index: Python-3.5.0/Makefile.pre.in
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050078--- Python-3.5.0.orig/Makefile.pre.in
79+++ Python-3.5.0/Makefile.pre.in
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080@@ -101,6 +101,8 @@ PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS
81
82 # Machine-dependent subdirectories
83 MACHDEP= @MACHDEP@
84+LIB= @LIB@
85+ARCH= @ARCH@
86
87 # Multiarch directory (may be empty)
88 MULTIARCH= @MULTIARCH@
89@@ -120,7 +122,7 @@ LIBDIR= @libdir@
90 MANDIR= @mandir@
91 INCLUDEDIR= @includedir@
92 CONFINCLUDEDIR= $(exec_prefix)/include
93-SCRIPTDIR= $(prefix)/lib
94+SCRIPTDIR= @libdir@
95 ABIFLAGS= @ABIFLAGS@
96
97 # Detailed destination directories
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050098@@ -729,6 +731,7 @@ Modules/getpath.o: $(srcdir)/Modules/get
Patrick Williamsc124f4f2015-09-15 14:41:29 -050099 -DEXEC_PREFIX='"$(exec_prefix)"' \
100 -DVERSION='"$(VERSION)"' \
101 -DVPATH='"$(VPATH)"' \
102+ -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' \
103 -o $@ $(srcdir)/Modules/getpath.c
104
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500105 Programs/python.o: $(srcdir)/Programs/python.c
106@@ -798,7 +801,7 @@ $(OPCODE_H): $(srcdir)/Lib/opcode.py $(O
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107 Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
108
109 Python/getplatform.o: $(srcdir)/Python/getplatform.c
110- $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
111+ $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' -o $@ $(srcdir)/Python/getplatform.c
112
113 Python/importdl.o: $(srcdir)/Python/importdl.c
114 $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500115Index: Python-3.5.0/Modules/getpath.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500116===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500117--- Python-3.5.0.orig/Modules/getpath.c
118+++ Python-3.5.0/Modules/getpath.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119@@ -117,9 +117,11 @@
120 #define EXEC_PREFIX PREFIX
121 #endif
122
123+#define LIB_PYTHON LIB "/python" VERSION
124+
125 #ifndef PYTHONPATH
126-#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \
127- EXEC_PREFIX "/lib/python" VERSION "/lib-dynload"
128+#define PYTHONPATH PREFIX "/" LIB_PYTHON ":" \
129+ EXEC_PREFIX "/" LIB_PYTHON "/lib-dynload"
130 #endif
131
132 #ifndef LANDMARK
133@@ -130,6 +132,7 @@ static wchar_t prefix[MAXPATHLEN+1];
134 static wchar_t exec_prefix[MAXPATHLEN+1];
135 static wchar_t progpath[MAXPATHLEN+1];
136 static wchar_t *module_search_path = NULL;
137+static wchar_t *lib_python = L"" LIB_PYTHON;
138
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500139 /* Get file status. Encode the path to the locale encoding. */
140
141Index: Python-3.5.0/Python/getplatform.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500142===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500143--- Python-3.5.0.orig/Python/getplatform.c
144+++ Python-3.5.0/Python/getplatform.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145@@ -10,3 +10,23 @@ Py_GetPlatform(void)
146 {
147 return PLATFORM;
148 }
149+
150+#ifndef ARCH
151+#define ARCH "unknown"
152+#endif
153+
154+const char *
155+Py_GetArch(void)
156+{
157+ return ARCH;
158+}
159+
160+#ifndef LIB
161+#define LIB "lib"
162+#endif
163+
164+const char *
165+Py_GetLib(void)
166+{
167+ return LIB;
168+}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500169Index: Python-3.5.0/Python/sysmodule.c
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500170===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500171--- Python-3.5.0.orig/Python/sysmodule.c
172+++ Python-3.5.0/Python/sysmodule.c
173@@ -1767,6 +1767,10 @@ _PySys_Init(void)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174 PyUnicode_FromString(Py_GetCopyright()));
175 SET_SYS_FROM_STRING("platform",
176 PyUnicode_FromString(Py_GetPlatform()));
177+ SET_SYS_FROM_STRING("arch",
178+ PyUnicode_FromString(Py_GetArch()));
179+ SET_SYS_FROM_STRING("lib",
180+ PyUnicode_FromString(Py_GetLib()));
181 SET_SYS_FROM_STRING("executable",
182 PyUnicode_FromWideChar(
183 Py_GetProgramFullPath(), -1));
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500184Index: Python-3.5.0/setup.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500185===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500186--- Python-3.5.0.orig/setup.py
187+++ Python-3.5.0/setup.py
188@@ -472,7 +472,7 @@ class PyBuildExt(build_ext):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189 # directories (i.e. '.' and 'Include') must be first. See issue
190 # 10520.
191 if not cross_compiling:
192- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
193+ add_dir_to_list(self.compiler.library_dirs, os.path.join('/usr/local', sys.lib))
194 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
195 # only change this for cross builds for 3.3, issues on Mageia
196 if cross_compiling:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500197@@ -530,8 +530,7 @@ class PyBuildExt(build_ext):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198 # be assumed that no additional -I,-L directives are needed.
199 if not cross_compiling:
200 lib_dirs = self.compiler.library_dirs + [
201- '/lib64', '/usr/lib64',
202- '/lib', '/usr/lib',
203+ '/' + sys.lib, '/usr/' + sys.lib,
204 ]
205 inc_dirs = self.compiler.include_dirs + ['/usr/include']
206 else:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500207@@ -716,11 +715,11 @@ class PyBuildExt(build_ext):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208 elif curses_library:
209 readline_libs.append(curses_library)
210 elif self.compiler.find_library_file(lib_dirs +
211- ['/usr/lib/termcap'],
212+ ['/usr/'+sys.lib+'/termcap'],
213 'termcap'):
214 readline_libs.append('termcap')
215 exts.append( Extension('readline', ['readline.c'],
216- library_dirs=['/usr/lib/termcap'],
217+ library_dirs=['/usr/'+sys.lib+'/termcap'],
218 extra_link_args=readline_extra_link_args,
219 libraries=readline_libs) )
220 else:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500221Index: Python-3.5.0/Lib/sysconfig.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500222===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500223--- Python-3.5.0.orig/Lib/sysconfig.py
224+++ Python-3.5.0/Lib/sysconfig.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500225@@ -20,10 +20,10 @@ __all__ = [
226
227 _INSTALL_SCHEMES = {
228 'posix_prefix': {
229- 'stdlib': '{installed_base}/lib/python{py_version_short}',
230- 'platstdlib': '{platbase}/lib/python{py_version_short}',
231+ 'stdlib': '{installed_base}/'+sys.lib+'/python{py_version_short}',
232+ 'platstdlib': '{platbase}/'+sys.lib+'/python{py_version_short}',
233 'purelib': '{base}/lib/python{py_version_short}/site-packages',
234- 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
235+ 'platlib': '{platbase}/'+sys.lib+'/python{py_version_short}/site-packages',
236 'include':
237 '{installed_base}/include/python{py_version_short}{abiflags}',
238 'platinclude':
239@@ -32,10 +32,10 @@ _INSTALL_SCHEMES = {
240 'data': '{base}',
241 },
242 'posix_home': {
243- 'stdlib': '{installed_base}/lib/python',
244- 'platstdlib': '{base}/lib/python',
245+ 'stdlib': '{installed_base}/'+sys.lib+'/python',
246+ 'platstdlib': '{base}/'+sys.lib+'/python',
247 'purelib': '{base}/lib/python',
248- 'platlib': '{base}/lib/python',
249+ 'platlib': '{base}/'+sys.lib+'/python',
250 'include': '{installed_base}/include/python',
251 'platinclude': '{installed_base}/include/python',
252 'scripts': '{base}/bin',
253@@ -61,10 +61,10 @@ _INSTALL_SCHEMES = {
254 'data': '{userbase}',
255 },
256 'posix_user': {
257- 'stdlib': '{userbase}/lib/python{py_version_short}',
258- 'platstdlib': '{userbase}/lib/python{py_version_short}',
259+ 'stdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
260+ 'platstdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
261 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
262- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
263+ 'platlib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages',
264 'include': '{userbase}/include/python{py_version_short}',
265 'scripts': '{userbase}/bin',
266 'data': '{userbase}',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500267Index: Python-3.5.0/configure.ac
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500268===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500269--- Python-3.5.0.orig/configure.ac
270+++ Python-3.5.0/configure.ac
271@@ -858,6 +858,41 @@ PLATDIR=plat-$MACHDEP
272 AC_SUBST(PLATDIR)
273 AC_SUBST(PLATFORM_TRIPLET)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500274
275+AC_SUBST(ARCH)
276+AC_MSG_CHECKING(ARCH)
277+ARCH=`uname -m`
278+case $ARCH in
279+i?86) ARCH=i386;;
280+esac
281+AC_MSG_RESULT($ARCH)
282+
283+AC_SUBST(LIB)
284+AC_MSG_CHECKING(LIB)
285+case $ac_sys_system in
286+Linux*)
287+ # Test if the compiler is 64bit
288+ echo 'int i;' > conftest.$ac_ext
289+ python_cv_cc_64bit_output=no
290+ if AC_TRY_EVAL(ac_compile); then
291+ case `/usr/bin/file conftest.$ac_objext` in
292+ *"ELF 64"*)
293+ python_cv_cc_64bit_output=yes
294+ ;;
295+ esac
296+ fi
297+ rm -rf conftest*
298+ ;;
299+esac
300+
301+case $ARCH:$python_cv_cc_64bit_output in
302+ppc64:yes | powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
303+ LIB="lib64"
304+ ;;
305+*:*)
306+ LIB="lib"
307+ ;;
308+esac
309+AC_MSG_RESULT($LIB)
310
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500311 AC_MSG_CHECKING([for -Wl,--no-as-needed])
312 save_LDFLAGS="$LDFLAGS"