From b360fea68466e811eea78ac4b496c79032bdf9b0 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Wed, 5 Jun 2019 16:05:20 +0900 Subject: [PATCH] Change lib path "/usr/lib" -> "/usr/lib64" at 64bit env python3 crashed at 64bit env ================================================================ Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] Fatal Python error: initfsencoding: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' ================================================================ Change-Id: Id76694616dfc53cec7547619c6931cb7a47be0a8 Signed-off-by: DongHun Kwak --- packaging/python-3.7.3_lib64.patch | 90 ++++++++++++++++++++++++++++++ packaging/python3-base.spec | 6 ++ packaging/python3.spec | 6 ++ 3 files changed, 102 insertions(+) create mode 100644 packaging/python-3.7.3_lib64.patch diff --git a/packaging/python-3.7.3_lib64.patch b/packaging/python-3.7.3_lib64.patch new file mode 100644 index 00000000..cd030f2d --- /dev/null +++ b/packaging/python-3.7.3_lib64.patch @@ -0,0 +1,90 @@ +diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py +index 0258d3d..4b969bf 100644 +--- a/Lib/distutils/command/install.py ++++ b/Lib/distutils/command/install.py +@@ -30,14 +30,14 @@ WINDOWS_SCHEME = { + INSTALL_SCHEMES = { + 'unix_prefix': { + 'purelib': '$base/lib/python$py_version_short/site-packages', +- 'platlib': '$platbase/lib/python$py_version_short/site-packages', ++ 'platlib': '$platbase/lib64/python$py_version_short/site-packages', + 'headers': '$base/include/python$py_version_short$abiflags/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'unix_home': { + 'purelib': '$base/lib/python', +- 'platlib': '$base/lib/python', ++ 'platlib': '$base/lib64/python', + 'headers': '$base/include/python/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', +diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py +index 83160f8..7aef07c 100644 +--- a/Lib/distutils/sysconfig.py ++++ b/Lib/distutils/sysconfig.py +@@ -142,8 +142,11 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): + prefix = plat_specific and EXEC_PREFIX or PREFIX + + if os.name == "posix": +- libpython = os.path.join(prefix, +- "lib", "python" + get_python_version()) ++ if plat_specific or standard_lib: ++ lib = "lib64" ++ else: ++ lib = "lib" ++ libpython = os.path.join(prefix, lib, "python" + get_python_version()) + if standard_lib: + return libpython + else: +diff --git a/Lib/site.py b/Lib/site.py +index ad11463..f4563fe 100644 +--- a/Lib/site.py ++++ b/Lib/site.py +@@ -334,11 +334,15 @@ def getsitepackages(prefixes=None): + seen.add(prefix) + + if os.sep == '/': ++ sitepackages.append(os.path.join(prefix, "lib64", ++ "python%d.%d" % sys.version_info[:2], ++ "site-packages")) + sitepackages.append(os.path.join(prefix, "lib", + "python%d.%d" % sys.version_info[:2], + "site-packages")) + else: + sitepackages.append(prefix) ++ sitepackages.append(os.path.join(prefix, "lib64", "site-packages")) + sitepackages.append(os.path.join(prefix, "lib", "site-packages")) + return sitepackages + +diff --git a/Modules/getpath.c b/Modules/getpath.c +index 67ceb87..a5b32ae 100644 +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -538,7 +538,7 @@ calculate_exec_prefix(const _PyCoreConfig *core_config, + "Could not find platform dependent libraries \n"); + } + wcsncpy(exec_prefix, calculate->exec_prefix, MAXPATHLEN); +- joinpath(exec_prefix, L"lib/lib-dynload"); ++ joinpath(exec_prefix, L"lib64/lib-dynload"); + } + /* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */ + } +@@ -790,7 +790,7 @@ calculate_zip_path(PyCalculatePath *calculate, const wchar_t *prefix) + else { + wcsncpy(calculate->zip_path, calculate->prefix, MAXPATHLEN); + } +- joinpath(calculate->zip_path, L"lib/python00.zip"); ++ joinpath(calculate->zip_path, L"lib64/python00.zip"); + + /* Replace "00" with version */ + size_t bufsz = wcslen(calculate->zip_path); +@@ -915,7 +915,7 @@ calculate_init(PyCalculatePath *calculate, + if (!calculate->prefix) { + return DECODE_LOCALE_ERR("EXEC_PREFIX define", len); + } +- calculate->lib_python = Py_DecodeLocale("lib/python" VERSION, &len); ++ calculate->lib_python = Py_DecodeLocale("lib64/python" VERSION, &len); + if (!calculate->lib_python) { + return DECODE_LOCALE_ERR("EXEC_PREFIX define", len); + } diff --git a/packaging/python3-base.spec b/packaging/python3-base.spec index 7d1f4285..70d08a6f 100644 --- a/packaging/python3-base.spec +++ b/packaging/python3-base.spec @@ -89,6 +89,7 @@ Source8: macros.python3.py Source9: import_failed.py Source10: import_failed.map + # The following files are not used in the build. # They are listed here to work around missing functionality in rpmbuild, # which would otherwise exclude them from distributed src.rpm files. @@ -96,6 +97,7 @@ Source100: PACKAGING-NOTES Source101: python3-rpmlintrc Source102: pre_checkin.sh Source103: skipped_tests.py +Source104: python-3.7.3_lib64.patch ##### REQURES, PROVIDES, OBSOLETES ##### #Requires: python-rpm-macros @@ -229,6 +231,10 @@ other applications. %prep %setup -q -n %{tarname} +%ifarch x86_64 aarch64 +%{__patch} -p1 < %{SOURCE104} +%endif + ### COMMON-PREP-BEGIN ### # drop Autoconf version requirement diff --git a/packaging/python3.spec b/packaging/python3.spec index 0c740532..4c435110 100644 --- a/packaging/python3.spec +++ b/packaging/python3.spec @@ -68,6 +68,8 @@ Group: Development/Languages/Python Url: http://www.python.org/ Source0: http://www.python.org/ftp/python/%{version}/%{tarname}.tar.xz #Source1: http://www.python.org/ftp/python/%{version}/%{tarname}.tar.xz.asc +Source100: python-3.7.3_lib64.patch + BuildRequires: automake BuildRequires: fdupes BuildRequires: gcc-c++ @@ -154,6 +156,10 @@ Console User Interface. %setup -q -n %{tarname} ### COMMON-PREP-BEGIN ### +%ifarch x86_64 aarch64 +%{__patch} -p1 < %{SOURCE100} +%endif + # drop Autoconf version requirement sed -i 's/^AC_PREREQ/dnl AC_PREREQ/' configure.ac -- 2.34.1