python-3.3-multilib.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. Upstream-Status: Pending
  2. get the sys.lib from python itself and do not use hardcoded value of 'lib'
  3. 02/2015 Rebased for 3.4.2
  4. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  5. Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com>
  6. Index: Python-3.5.2/Include/pythonrun.h
  7. ===================================================================
  8. --- Python-3.5.2.orig/Include/pythonrun.h
  9. +++ Python-3.5.2/Include/pythonrun.h
  10. @@ -23,6 +23,9 @@ typedef struct {
  11. } PyCompilerFlags;
  12. #endif
  13. +PyAPI_FUNC(const char *) Py_GetArch(void);
  14. +PyAPI_FUNC(const char *) Py_GetLib(void);
  15. +
  16. #ifndef Py_LIMITED_API
  17. PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
  18. PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
  19. Index: Python-3.5.2/Lib/distutils/command/install.py
  20. ===================================================================
  21. --- Python-3.5.2.orig/Lib/distutils/command/install.py
  22. +++ Python-3.5.2/Lib/distutils/command/install.py
  23. @@ -19,6 +19,8 @@ from site import USER_BASE
  24. from site import USER_SITE
  25. HAS_USER_SITE = True
  26. +libname = sys.lib
  27. +
  28. WINDOWS_SCHEME = {
  29. 'purelib': '$base/Lib/site-packages',
  30. 'platlib': '$base/Lib/site-packages',
  31. @@ -30,7 +32,7 @@ WINDOWS_SCHEME = {
  32. INSTALL_SCHEMES = {
  33. 'unix_prefix': {
  34. 'purelib': '$base/lib/python$py_version_short/site-packages',
  35. - 'platlib': '$platbase/lib/python$py_version_short/site-packages',
  36. + 'platlib': '$platbase/'+libname+'/python$py_version_short/site-packages',
  37. 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
  38. 'scripts': '$base/bin',
  39. 'data' : '$base',
  40. Index: Python-3.5.2/Lib/pydoc.py
  41. ===================================================================
  42. --- Python-3.5.2.orig/Lib/pydoc.py
  43. +++ Python-3.5.2/Lib/pydoc.py
  44. @@ -384,7 +384,7 @@ class Doc:
  45. docmodule = docclass = docroutine = docother = docproperty = docdata = fail
  46. def getdocloc(self, object,
  47. - basedir=os.path.join(sys.base_exec_prefix, "lib",
  48. + basedir=os.path.join(sys.base_exec_prefix, sys.lib,
  49. "python%d.%d" % sys.version_info[:2])):
  50. """Return the location of module docs or None"""
  51. Index: Python-3.5.2/Lib/trace.py
  52. ===================================================================
  53. --- Python-3.5.2.orig/Lib/trace.py
  54. +++ Python-3.5.2/Lib/trace.py
  55. @@ -749,10 +749,10 @@ def main(argv=None):
  56. # should I also call expanduser? (after all, could use $HOME)
  57. s = s.replace("$prefix",
  58. - os.path.join(sys.base_prefix, "lib",
  59. + os.path.join(sys.base_prefix, sys.lib,
  60. "python" + sys.version[:3]))
  61. s = s.replace("$exec_prefix",
  62. - os.path.join(sys.base_exec_prefix, "lib",
  63. + os.path.join(sys.base_exec_prefix, sys.lib,
  64. "python" + sys.version[:3]))
  65. s = os.path.normpath(s)
  66. ignore_dirs.append(s)
  67. Index: Python-3.5.2/Makefile.pre.in
  68. ===================================================================
  69. --- Python-3.5.2.orig/Makefile.pre.in
  70. +++ Python-3.5.2/Makefile.pre.in
  71. @@ -106,6 +106,8 @@ PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CFLAGS
  72. # Machine-dependent subdirectories
  73. MACHDEP= @MACHDEP@
  74. +LIB= @LIB@
  75. +ARCH= @ARCH@
  76. # Multiarch directory (may be empty)
  77. MULTIARCH= @MULTIARCH@
  78. @@ -125,7 +127,7 @@ LIBDIR= @libdir@
  79. MANDIR= @mandir@
  80. INCLUDEDIR= @includedir@
  81. CONFINCLUDEDIR= $(exec_prefix)/include
  82. -SCRIPTDIR= $(prefix)/lib
  83. +SCRIPTDIR= @libdir@
  84. ABIFLAGS= @ABIFLAGS@
  85. # Detailed destination directories
  86. @@ -755,6 +757,7 @@ Modules/getpath.o: $(srcdir)/Modules/get
  87. -DEXEC_PREFIX='"$(exec_prefix)"' \
  88. -DVERSION='"$(VERSION)"' \
  89. -DVPATH='"$(VPATH)"' \
  90. + -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' \
  91. -o $@ $(srcdir)/Modules/getpath.c
  92. Programs/python.o: $(srcdir)/Programs/python.c
  93. @@ -835,7 +838,7 @@ $(OPCODE_H): $(srcdir)/Lib/opcode.py $(O
  94. Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
  95. Python/getplatform.o: $(srcdir)/Python/getplatform.c
  96. - $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
  97. + $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -DARCH='"$(ARCH)"' -DLIB='"$(LIB)"' -o $@ $(srcdir)/Python/getplatform.c
  98. Python/importdl.o: $(srcdir)/Python/importdl.c
  99. $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
  100. Index: Python-3.5.2/Modules/getpath.c
  101. ===================================================================
  102. --- Python-3.5.2.orig/Modules/getpath.c
  103. +++ Python-3.5.2/Modules/getpath.c
  104. @@ -105,6 +105,13 @@
  105. #error "PREFIX, EXEC_PREFIX, VERSION, and VPATH must be constant defined"
  106. #endif
  107. +#define LIB_PYTHON LIB "/python" VERSION
  108. +
  109. +#ifndef PYTHONPATH
  110. +#define PYTHONPATH PREFIX "/" LIB_PYTHON ":" \
  111. + EXEC_PREFIX "/" LIB_PYTHON "/lib-dynload"
  112. +#endif
  113. +
  114. #ifndef LANDMARK
  115. #define LANDMARK L"os.py"
  116. #endif
  117. @@ -113,6 +120,7 @@ static wchar_t prefix[MAXPATHLEN+1];
  118. static wchar_t exec_prefix[MAXPATHLEN+1];
  119. static wchar_t progpath[MAXPATHLEN+1];
  120. static wchar_t *module_search_path = NULL;
  121. +static wchar_t *lib_python = L"" LIB_PYTHON;
  122. /* Get file status. Encode the path to the locale encoding. */
  123. @@ -494,7 +502,7 @@ calculate_path(void)
  124. _pythonpath = Py_DecodeLocale(PYTHONPATH, NULL);
  125. _prefix = Py_DecodeLocale(PREFIX, NULL);
  126. _exec_prefix = Py_DecodeLocale(EXEC_PREFIX, NULL);
  127. - lib_python = Py_DecodeLocale("lib/python" VERSION, NULL);
  128. + lib_python = Py_DecodeLocale(LIB_PYTHON, NULL);
  129. if (!_pythonpath || !_prefix || !_exec_prefix || !lib_python) {
  130. Py_FatalError(
  131. Index: Python-3.5.2/Python/getplatform.c
  132. ===================================================================
  133. --- Python-3.5.2.orig/Python/getplatform.c
  134. +++ Python-3.5.2/Python/getplatform.c
  135. @@ -10,3 +10,23 @@ Py_GetPlatform(void)
  136. {
  137. return PLATFORM;
  138. }
  139. +
  140. +#ifndef ARCH
  141. +#define ARCH "unknown"
  142. +#endif
  143. +
  144. +const char *
  145. +Py_GetArch(void)
  146. +{
  147. + return ARCH;
  148. +}
  149. +
  150. +#ifndef LIB
  151. +#define LIB "lib"
  152. +#endif
  153. +
  154. +const char *
  155. +Py_GetLib(void)
  156. +{
  157. + return LIB;
  158. +}
  159. Index: Python-3.5.2/Python/sysmodule.c
  160. ===================================================================
  161. --- Python-3.5.2.orig/Python/sysmodule.c
  162. +++ Python-3.5.2/Python/sysmodule.c
  163. @@ -1790,6 +1790,10 @@ _PySys_Init(void)
  164. PyUnicode_FromString(Py_GetCopyright()));
  165. SET_SYS_FROM_STRING("platform",
  166. PyUnicode_FromString(Py_GetPlatform()));
  167. + SET_SYS_FROM_STRING("arch",
  168. + PyUnicode_FromString(Py_GetArch()));
  169. + SET_SYS_FROM_STRING("lib",
  170. + PyUnicode_FromString(Py_GetLib()));
  171. SET_SYS_FROM_STRING("executable",
  172. PyUnicode_FromWideChar(
  173. Py_GetProgramFullPath(), -1));
  174. Index: Python-3.5.2/setup.py
  175. ===================================================================
  176. --- Python-3.5.2.orig/setup.py
  177. +++ Python-3.5.2/setup.py
  178. @@ -495,7 +495,7 @@ class PyBuildExt(build_ext):
  179. # directories (i.e. '.' and 'Include') must be first. See issue
  180. # 10520.
  181. if not cross_compiling:
  182. - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
  183. + add_dir_to_list(self.compiler.library_dirs, os.path.join('/usr/local', sys.lib))
  184. add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
  185. # only change this for cross builds for 3.3, issues on Mageia
  186. if cross_compiling:
  187. @@ -553,8 +553,7 @@ class PyBuildExt(build_ext):
  188. # be assumed that no additional -I,-L directives are needed.
  189. if not cross_compiling:
  190. lib_dirs = self.compiler.library_dirs + [
  191. - '/lib64', '/usr/lib64',
  192. - '/lib', '/usr/lib',
  193. + '/' + sys.lib, '/usr/' + sys.lib,
  194. ]
  195. inc_dirs = self.compiler.include_dirs + ['/usr/include']
  196. else:
  197. @@ -746,11 +745,11 @@ class PyBuildExt(build_ext):
  198. elif curses_library:
  199. readline_libs.append(curses_library)
  200. elif self.compiler.find_library_file(lib_dirs +
  201. - ['/usr/lib/termcap'],
  202. + ['/usr/'+sys.lib+'/termcap'],
  203. 'termcap'):
  204. readline_libs.append('termcap')
  205. exts.append( Extension('readline', ['readline.c'],
  206. - library_dirs=['/usr/lib/termcap'],
  207. + library_dirs=['/usr/'+sys.lib+'/termcap'],
  208. extra_link_args=readline_extra_link_args,
  209. libraries=readline_libs) )
  210. else:
  211. Index: Python-3.5.2/Lib/sysconfig.py
  212. ===================================================================
  213. --- Python-3.5.2.orig/Lib/sysconfig.py
  214. +++ Python-3.5.2/Lib/sysconfig.py
  215. @@ -20,10 +20,10 @@ __all__ = [
  216. _INSTALL_SCHEMES = {
  217. 'posix_prefix': {
  218. - 'stdlib': '{installed_base}/lib/python{py_version_short}',
  219. - 'platstdlib': '{platbase}/lib/python{py_version_short}',
  220. + 'stdlib': '{installed_base}/'+sys.lib+'/python{py_version_short}',
  221. + 'platstdlib': '{platbase}/'+sys.lib+'/python{py_version_short}',
  222. 'purelib': '{base}/lib/python{py_version_short}/site-packages',
  223. - 'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
  224. + 'platlib': '{platbase}/'+sys.lib+'/python{py_version_short}/site-packages',
  225. 'include':
  226. '{installed_base}/include/python{py_version_short}{abiflags}',
  227. 'platinclude':
  228. @@ -32,10 +32,10 @@ _INSTALL_SCHEMES = {
  229. 'data': '{base}',
  230. },
  231. 'posix_home': {
  232. - 'stdlib': '{installed_base}/lib/python',
  233. - 'platstdlib': '{base}/lib/python',
  234. + 'stdlib': '{installed_base}/'+sys.lib+'/python',
  235. + 'platstdlib': '{base}/'+sys.lib+'/python',
  236. 'purelib': '{base}/lib/python',
  237. - 'platlib': '{base}/lib/python',
  238. + 'platlib': '{base}/'+sys.lib+'/python',
  239. 'include': '{installed_base}/include/python',
  240. 'platinclude': '{installed_base}/include/python',
  241. 'scripts': '{base}/bin',
  242. @@ -61,10 +61,10 @@ _INSTALL_SCHEMES = {
  243. 'data': '{userbase}',
  244. },
  245. 'posix_user': {
  246. - 'stdlib': '{userbase}/lib/python{py_version_short}',
  247. - 'platstdlib': '{userbase}/lib/python{py_version_short}',
  248. + 'stdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
  249. + 'platstdlib': '{userbase}/'+sys.lib+'/python{py_version_short}',
  250. 'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
  251. - 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
  252. + 'platlib': '{userbase}/'+sys.lib+'/python{py_version_short}/site-packages',
  253. 'include': '{userbase}/include/python{py_version_short}',
  254. 'scripts': '{userbase}/bin',
  255. 'data': '{userbase}',
  256. Index: Python-3.5.2/configure.ac
  257. ===================================================================
  258. --- Python-3.5.2.orig/configure.ac
  259. +++ Python-3.5.2/configure.ac
  260. @@ -883,6 +883,41 @@ PLATDIR=plat-$MACHDEP
  261. AC_SUBST(PLATDIR)
  262. AC_SUBST(PLATFORM_TRIPLET)
  263. +AC_SUBST(ARCH)
  264. +AC_MSG_CHECKING(ARCH)
  265. +ARCH=`uname -m`
  266. +case $ARCH in
  267. +i?86) ARCH=i386;;
  268. +esac
  269. +AC_MSG_RESULT($ARCH)
  270. +
  271. +AC_SUBST(LIB)
  272. +AC_MSG_CHECKING(LIB)
  273. +case $ac_sys_system in
  274. +Linux*)
  275. + # Test if the compiler is 64bit
  276. + echo 'int i;' > conftest.$ac_ext
  277. + python_cv_cc_64bit_output=no
  278. + if AC_TRY_EVAL(ac_compile); then
  279. + case `/usr/bin/file conftest.$ac_objext` in
  280. + *"ELF 64"*)
  281. + python_cv_cc_64bit_output=yes
  282. + ;;
  283. + esac
  284. + fi
  285. + rm -rf conftest*
  286. + ;;
  287. +esac
  288. +
  289. +case $ARCH:$python_cv_cc_64bit_output in
  290. +ppc64:yes | powerpc64:yes | s390x:yes | sparc64:yes | x86_64:yes)
  291. + LIB="lib64"
  292. + ;;
  293. +*:*)
  294. + LIB="lib"
  295. + ;;
  296. +esac
  297. +AC_MSG_RESULT($LIB)
  298. AC_MSG_CHECKING([for -Wl,--no-as-needed])
  299. save_LDFLAGS="$LDFLAGS"