blob: cc35dc1617dd8ab0c4a94cfc4f0dc4059d57cc07 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001From 51fe6f22d0ba113674fb358bd11d75fe659bd26e Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 14 May 2013 15:00:26 -0700
4Subject: [PATCH 01/13] get the sys.lib from python itself and do not use
5 hardcoded value of 'lib'
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006
702/2015 Rebased for 3.4.2
8
Brad Bishop6e60e8b2018-02-01 10:27:11 -05009Upstream-Status: Pending
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010Signed-off-by: Khem Raj <raj.khem@gmail.com>
11Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com>
12
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013---
14 Include/pythonrun.h | 3 +++
15 Lib/distutils/command/install.py | 4 +++-
16 Lib/pydoc.py | 2 +-
17 Lib/site.py | 4 ++--
18 Lib/sysconfig.py | 18 +++++++++---------
19 Lib/trace.py | 4 ++--
20 Makefile.pre.in | 7 +++++--
21 Modules/getpath.c | 10 +++++++++-
22 Python/getplatform.c | 20 ++++++++++++++++++++
23 Python/sysmodule.c | 4 ++++
24 configure.ac | 35 +++++++++++++++++++++++++++++++++++
25 setup.py | 9 ++++-----
26 12 files changed, 97 insertions(+), 23 deletions(-)
27
Brad Bishop316dfdd2018-06-25 12:45:53 -040028Index: Python-3.5.4/Include/pythonrun.h
29===================================================================
30--- Python-3.5.4.orig/Include/pythonrun.h
31+++ Python-3.5.4/Include/pythonrun.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050032@@ -23,6 +23,9 @@ typedef struct {
33 } PyCompilerFlags;
34 #endif
35
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036+PyAPI_FUNC(const char *) Py_GetArch(void);
37+PyAPI_FUNC(const char *) Py_GetLib(void);
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050038+
39 #ifndef Py_LIMITED_API
40 PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
41 PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
Brad Bishop316dfdd2018-06-25 12:45:53 -040042Index: Python-3.5.4/Lib/distutils/command/install.py
43===================================================================
44--- Python-3.5.4.orig/Lib/distutils/command/install.py
45+++ Python-3.5.4/Lib/distutils/command/install.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046@@ -19,6 +19,8 @@ from site import USER_BASE
47 from site import USER_SITE
48 HAS_USER_SITE = True
49
50+libname = sys.lib
51+
52 WINDOWS_SCHEME = {
53 'purelib': '$base/Lib/site-packages',
54 'platlib': '$base/Lib/site-packages',
Brad Bishop316dfdd2018-06-25 12:45:53 -040055@@ -29,8 +31,8 @@ WINDOWS_SCHEME = {
56
Patrick Williamsc124f4f2015-09-15 14:41:29 -050057 INSTALL_SCHEMES = {
58 'unix_prefix': {
Brad Bishop316dfdd2018-06-25 12:45:53 -040059- 'purelib': '$base/lib/python$py_version_short/site-packages',
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060- 'platlib': '$platbase/lib/python$py_version_short/site-packages',
Brad Bishop316dfdd2018-06-25 12:45:53 -040061+ 'purelib': '$platbase/'+libname+'/python$py_version_short/site-packages',
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062+ 'platlib': '$platbase/'+libname+'/python$py_version_short/site-packages',
63 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
64 'scripts': '$base/bin',
65 'data' : '$base',
Brad Bishop316dfdd2018-06-25 12:45:53 -040066Index: Python-3.5.4/Lib/pydoc.py
67===================================================================
68--- Python-3.5.4.orig/Lib/pydoc.py
69+++ Python-3.5.4/Lib/pydoc.py
70@@ -389,7 +389,7 @@ class Doc:
Patrick Williamsc0f7c042017-02-23 20:41:17 -060071 docmodule = docclass = docroutine = docother = docproperty = docdata = fail
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072
Patrick Williamsc0f7c042017-02-23 20:41:17 -060073 def getdocloc(self, object,
74- basedir=os.path.join(sys.base_exec_prefix, "lib",
75+ basedir=os.path.join(sys.base_exec_prefix, sys.lib,
76 "python%d.%d" % sys.version_info[:2])):
77 """Return the location of module docs or None"""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078
Brad Bishop316dfdd2018-06-25 12:45:53 -040079Index: Python-3.5.4/Lib/site.py
80===================================================================
81--- Python-3.5.4.orig/Lib/site.py
82+++ Python-3.5.4/Lib/site.py
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083@@ -303,12 +303,12 @@ def getsitepackages(prefixes=None):
84 seen.add(prefix)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085
Brad Bishop6e60e8b2018-02-01 10:27:11 -050086 if os.sep == '/':
87- sitepackages.append(os.path.join(prefix, "lib",
88+ sitepackages.append(os.path.join(prefix, sys.lib,
89 "python" + sys.version[:3],
90 "site-packages"))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050092 sitepackages.append(prefix)
93- sitepackages.append(os.path.join(prefix, "lib", "site-packages"))
94+ sitepackages.append(os.path.join(prefix, sys.lib, "site-packages"))
95 if sys.platform == "darwin":
96 # for framework builds *only* we add the standard Apple
97 # locations.
Brad Bishop316dfdd2018-06-25 12:45:53 -040098Index: Python-3.5.4/Lib/sysconfig.py
99===================================================================
100--- Python-3.5.4.orig/Lib/sysconfig.py
101+++ Python-3.5.4/Lib/sysconfig.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102@@ -20,10 +20,10 @@ __all__ = [
103
104 _INSTALL_SCHEMES = {
105 'posix_prefix': {
106- 'stdlib': '{installed_base}/lib/python{py_version_short}',
107- 'platstdlib': '{platbase}/lib/python{py_version_short}',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400108- 'purelib': '{base}/lib/python{py_version_short}/site-packages',
109- 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110+ 'stdlib': '{installed_base}/'+sys.lib+'/python{py_version_short}',
111+ 'platstdlib': '{platbase}/'+sys.lib+'/python{py_version_short}',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400112+ 'purelib': '{platbase}/'+sys.lib+'/python{py_version_short}/site-packages',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113+ 'platlib': '{platbase}/'+sys.lib+'/python{py_version_short}/site-packages',
114 'include':
115 '{installed_base}/include/python{py_version_short}{abiflags}',
116 'platinclude':
117@@ -32,10 +32,10 @@ _INSTALL_SCHEMES = {
118 'data': '{base}',
119 },
120 'posix_home': {
121- 'stdlib': '{installed_base}/lib/python',
122- 'platstdlib': '{base}/lib/python',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400123- 'purelib': '{base}/lib/python',
124- 'platlib': '{base}/lib/python',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125+ 'stdlib': '{installed_base}/'+sys.lib+'/python',
126+ 'platstdlib': '{base}/'+sys.lib+'/python',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400127+ 'purelib': '{base}/'+sys.lib+'/python',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128+ 'platlib': '{base}/'+sys.lib+'/python',
129 'include': '{installed_base}/include/python',
130 'platinclude': '{installed_base}/include/python',
131 'scripts': '{base}/bin',
132@@ -61,10 +61,10 @@ _INSTALL_SCHEMES = {
133 'data': '{userbase}',
134 },
135 'posix_user': {
136- 'stdlib': '{userbase}/lib/python{py_version_short}',
137- 'platstdlib': '{userbase}/lib/python{py_version_short}',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400138- 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
139- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140+ 'stdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
141+ 'platstdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400142+ 'purelib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages',
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500143+ 'platlib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages',
144 'include': '{userbase}/include/python{py_version_short}',
145 'scripts': '{userbase}/bin',
146 'data': '{userbase}',
Brad Bishop316dfdd2018-06-25 12:45:53 -0400147Index: Python-3.5.4/Lib/trace.py
148===================================================================
149--- Python-3.5.4.orig/Lib/trace.py
150+++ Python-3.5.4/Lib/trace.py
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500151@@ -749,10 +749,10 @@ def main(argv=None):
152 # should I also call expanduser? (after all, could use $HOME)
153
154 s = s.replace("$prefix",
155- os.path.join(sys.base_prefix, "lib",
156+ os.path.join(sys.base_prefix, sys.lib,
157 "python" + sys.version[:3]))
158 s = s.replace("$exec_prefix",
159- os.path.join(sys.base_exec_prefix, "lib",
160+ os.path.join(sys.base_exec_prefix, sys.lib,
161 "python" + sys.version[:3]))
162 s = os.path.normpath(s)
163 ignore_dirs.append(s)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400164Index: Python-3.5.4/Makefile.pre.in
165===================================================================
166--- Python-3.5.4.orig/Makefile.pre.in
167+++ Python-3.5.4/Makefile.pre.in
168@@ -109,6 +109,8 @@ CFLAGS_ALIASING=@CFLAGS_ALIASING@
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500169
170 # Machine-dependent subdirectories
171 MACHDEP= @MACHDEP@
172+LIB= @LIB@
173+ARCH= @ARCH@
174
175 # Multiarch directory (may be empty)
176 MULTIARCH= @MULTIARCH@
Brad Bishop316dfdd2018-06-25 12:45:53 -0400177@@ -128,7 +130,7 @@ LIBDIR= @libdir@
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500178 MANDIR= @mandir@
179 INCLUDEDIR= @includedir@
180 CONFINCLUDEDIR= $(exec_prefix)/include
181-SCRIPTDIR= $(prefix)/lib
182+SCRIPTDIR= @libdir@
183 ABIFLAGS= @ABIFLAGS@
184
185 # Detailed destination directories
Brad Bishop316dfdd2018-06-25 12:45:53 -0400186@@ -731,6 +733,7 @@ Modules/getpath.o: $(srcdir)/Modules/get
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500187 -DEXEC_PREFIX='"$(exec_prefix)"' \
188 -DVERSION='"$(VERSION)"' \
189 -DVPATH='"$(VPATH)"' \
190+ -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' \
191 -o $@ $(srcdir)/Modules/getpath.c
192
193 Programs/python.o: $(srcdir)/Programs/python.c
Brad Bishop316dfdd2018-06-25 12:45:53 -0400194@@ -813,7 +816,7 @@ regen-opcode:
195 Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196
197 Python/getplatform.o: $(srcdir)/Python/getplatform.c
198- $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
199+ $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' -o $@ $(srcdir)/Python/getplatform.c
200
201 Python/importdl.o: $(srcdir)/Python/importdl.c
202 $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
Brad Bishop316dfdd2018-06-25 12:45:53 -0400203Index: Python-3.5.4/Modules/getpath.c
204===================================================================
205--- Python-3.5.4.orig/Modules/getpath.c
206+++ Python-3.5.4/Modules/getpath.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500207@@ -105,6 +105,13 @@
208 #error "PREFIX, EXEC_PREFIX, VERSION, and VPATH must be constant defined"
209 #endif
210
211+#define LIB_PYTHON LIB "/python" VERSION
212+
213+#ifndef PYTHONPATH
214+#define PYTHONPATH PREFIX "/" LIB_PYTHON ":" \
215+ EXEC_PREFIX "/" LIB_PYTHON "/lib-dynload"
216+#endif
217+
218 #ifndef LANDMARK
219 #define LANDMARK L"os.py"
220 #endif
221@@ -113,6 +120,7 @@ static wchar_t prefix[MAXPATHLEN+1];
222 static wchar_t exec_prefix[MAXPATHLEN+1];
223 static wchar_t progpath[MAXPATHLEN+1];
224 static wchar_t *module_search_path = NULL;
225+static wchar_t *lib_python = L"" LIB_PYTHON;
226
227 /* Get file status. Encode the path to the locale encoding. */
228
229@@ -494,7 +502,7 @@ calculate_path(void)
230 _pythonpath = Py_DecodeLocale(PYTHONPATH, NULL);
231 _prefix = Py_DecodeLocale(PREFIX, NULL);
232 _exec_prefix = Py_DecodeLocale(EXEC_PREFIX, NULL);
233- lib_python = Py_DecodeLocale("lib/python" VERSION, NULL);
234+ lib_python = Py_DecodeLocale(LIB_PYTHON, NULL);
235
236 if (!_pythonpath || !_prefix || !_exec_prefix || !lib_python) {
237 Py_FatalError(
Brad Bishop316dfdd2018-06-25 12:45:53 -0400238Index: Python-3.5.4/Python/getplatform.c
239===================================================================
240--- Python-3.5.4.orig/Python/getplatform.c
241+++ Python-3.5.4/Python/getplatform.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500242@@ -10,3 +10,23 @@ Py_GetPlatform(void)
243 {
244 return PLATFORM;
245 }
246+
247+#ifndef ARCH
248+#define ARCH "unknown"
249+#endif
250+
251+const char *
252+Py_GetArch(void)
253+{
254+ return ARCH;
255+}
256+
257+#ifndef LIB
258+#define LIB "lib"
259+#endif
260+
261+const char *
262+Py_GetLib(void)
263+{
264+ return LIB;
265+}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400266Index: Python-3.5.4/Python/sysmodule.c
267===================================================================
268--- Python-3.5.4.orig/Python/sysmodule.c
269+++ Python-3.5.4/Python/sysmodule.c
270@@ -1827,6 +1827,10 @@ _PySys_Init(void)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500271 PyUnicode_FromString(Py_GetCopyright()));
272 SET_SYS_FROM_STRING("platform",
273 PyUnicode_FromString(Py_GetPlatform()));
274+ SET_SYS_FROM_STRING("arch",
275+ PyUnicode_FromString(Py_GetArch()));
276+ SET_SYS_FROM_STRING("lib",
277+ PyUnicode_FromString(Py_GetLib()));
278 SET_SYS_FROM_STRING("executable",
279 PyUnicode_FromWideChar(
280 Py_GetProgramFullPath(), -1));
Brad Bishop316dfdd2018-06-25 12:45:53 -0400281Index: Python-3.5.4/configure.ac
282===================================================================
283--- Python-3.5.4.orig/configure.ac
284+++ Python-3.5.4/configure.ac
285@@ -885,6 +885,41 @@ PLATDIR=plat-$MACHDEP
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500286 AC_SUBST(PLATDIR)
287 AC_SUBST(PLATFORM_TRIPLET)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500288
289+AC_SUBST(ARCH)
290+AC_MSG_CHECKING(ARCH)
291+ARCH=`uname -m`
292+case $ARCH in
293+i?86) ARCH=i386;;
294+esac
295+AC_MSG_RESULT($ARCH)
296+
297+AC_SUBST(LIB)
298+AC_MSG_CHECKING(LIB)
299+case $ac_sys_system in
300+Linux*)
301+ # Test if the compiler is 64bit
302+ echo 'int i;' > conftest.$ac_ext
303+ python_cv_cc_64bit_output=no
304+ if AC_TRY_EVAL(ac_compile); then
305+ case `/usr/bin/file conftest.$ac_objext` in
306+ *"ELF 64"*)
307+ python_cv_cc_64bit_output=yes
308+ ;;
309+ esac
310+ fi
311+ rm -rf conftest*
312+ ;;
313+esac
314+
315+case $ARCH:$python_cv_cc_64bit_output in
316+ppc64:yes | powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
317+ LIB="lib64"
318+ ;;
319+*:*)
320+ LIB="lib"
321+ ;;
322+esac
323+AC_MSG_RESULT($LIB)
324
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500325 AC_MSG_CHECKING([for -Wl,--no-as-needed])
326 save_LDFLAGS="$LDFLAGS"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400327Index: Python-3.5.4/setup.py
328===================================================================
329--- Python-3.5.4.orig/setup.py
330+++ Python-3.5.4/setup.py
331@@ -494,7 +494,7 @@ class PyBuildExt(build_ext):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500332 # directories (i.e. '.' and 'Include') must be first. See issue
333 # 10520.
334 if not cross_compiling:
335- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
336+ add_dir_to_list(self.compiler.library_dirs, os.path.join('/usr/local', sys.lib))
337 add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
338 # only change this for cross builds for 3.3, issues on Mageia
339 if cross_compiling:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400340@@ -552,8 +552,7 @@ class PyBuildExt(build_ext):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500341 # be assumed that no additional -I,-L directives are needed.
342 if not cross_compiling:
343 lib_dirs = self.compiler.library_dirs + [
344- '/lib64', '/usr/lib64',
345- '/lib', '/usr/lib',
346+ '/' + sys.lib, '/usr/' + sys.lib,
347 ]
348 inc_dirs = self.compiler.include_dirs + ['/usr/include']
349 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400350@@ -745,11 +744,11 @@ class PyBuildExt(build_ext):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500351 elif curses_library:
352 readline_libs.append(curses_library)
353 elif self.compiler.find_library_file(lib_dirs +
354- ['/usr/lib/termcap'],
355+ ['/usr/'+sys.lib+'/termcap'],
356 'termcap'):
357 readline_libs.append('termcap')
358 exts.append( Extension('readline', ['readline.c'],
359- library_dirs=['/usr/lib/termcap'],
360+ library_dirs=['/usr/'+sys.lib+'/termcap'],
361 extra_link_args=readline_extra_link_args,
362 libraries=readline_libs) )
363 else: