Skip to content

Commit

Permalink
Merge branch 'jb49761-aarch64' into 'master'
Browse files Browse the repository at this point in the history
Fixes for aarch64

See merge request mer-core/python!14
  • Loading branch information
Matti Kosola committed May 22, 2020
2 parents 50e9df3 + 1baad0f commit 302e09a
Show file tree
Hide file tree
Showing 5 changed files with 306 additions and 6 deletions.
10 changes: 5 additions & 5 deletions rpm/0001-Disable-sqlite3-module.patch
@@ -1,17 +1,17 @@
From 352ecea75591ccf14fbc5c9396f8fa322b43250d Mon Sep 17 00:00:00 2001
From 56be368ad673070a31b6a706c4ca64da1b3ab117 Mon Sep 17 00:00:00 2001
From: Niels Breet <niels.breet@jolla.com>
Date: Tue, 6 Aug 2019 14:03:01 +0300
Subject: [PATCH] Disable sqlite3 module
Subject: [PATCH 1/4] Disable sqlite3 module

---
Makefile.pre.in | 1 -
1 file changed, 1 deletion(-)

diff --git a/Makefile.pre.in b/Makefile.pre.in
index 9297e7f..c8dd856 100644
index 2a14f33..ed547b3 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1060,7 +1060,6 @@ LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
@@ -1066,7 +1066,6 @@ LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
email email/mime email/test email/test/data \
ensurepip ensurepip/_bundled \
json json/tests \
Expand All @@ -20,5 +20,5 @@ index 9297e7f..c8dd856 100644
lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
--
1.9.1
2.7.4

185 changes: 185 additions & 0 deletions rpm/0002-Fix-lib64-for-multilib.patch
@@ -0,0 +1,185 @@
From 7de51a2d130c564901325ced97a750ac93609212 Mon Sep 17 00:00:00 2001
From: Matti Kosola <matti.kosola@jolla.com>
Date: Fri, 22 May 2020 08:01:34 +0200
Subject: [PATCH 2/4] Fix lib64 for multilib

Fixup various paths throughout the build and in distutils from "lib" to "lib64",
and add the /usr/lib64/pythonMAJOR.MINOR/site-packages to sitedirs, in front of
/usr/lib/pythonMAJOR.MINOR/site-packages

Signed-off-by: Matti Kosola <matti.kosola@jolla.com>
---
Lib/distutils/command/install.py | 4 ++--
Lib/distutils/sysconfig.py | 6 +++++-
Lib/site.py | 4 ++++
Lib/test/test_site.py | 11 +++++++----
Makefile.pre.in | 2 +-
Modules/getpath.c | 4 ++--
setup.py | 10 +++++-----
7 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index b9f1c6c..7b23714 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -42,14 +42,14 @@ else:
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/$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 1a4b792..a485419 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -129,8 +129,12 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
prefix = plat_specific and EXEC_PREFIX or PREFIX

if os.name == "posix":
+ if plat_specific or standard_lib:
+ lib = "lib64"
+ else:
+ lib = "lib"
libpython = os.path.join(prefix,
- "lib", "python" + get_python_version())
+ lib, "python" + get_python_version())
if standard_lib:
return libpython
else:
diff --git a/Lib/site.py b/Lib/site.py
index 3b51e81..9fd76c8 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -288,12 +288,16 @@ def getsitepackages():
if sys.platform in ('os2emx', 'riscos'):
sitepackages.append(os.path.join(prefix, "Lib", "site-packages"))
elif os.sep == '/':
+ sitepackages.append(os.path.join(prefix, "lib64",
+ "python" + sys.version[:3],
+ "site-packages"))
sitepackages.append(os.path.join(prefix, "lib",
"python" + sys.version[:3],
"site-packages"))
sitepackages.append(os.path.join(prefix, "lib", "site-python"))
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/Lib/test/test_site.py b/Lib/test/test_site.py
index b4384ee..349f688 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -254,17 +254,20 @@ class HelperFunctionsTests(unittest.TestCase):
self.assertEqual(dirs[0], wanted)
elif os.sep == '/':
# OS X, Linux, FreeBSD, etc
- self.assertEqual(len(dirs), 2)
- wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
+ self.assertEqual(len(dirs), 3)
+ wanted = os.path.join('xoxo', 'lib64', 'python' + sys.version[:3],
'site-packages')
self.assertEqual(dirs[0], wanted)
- wanted = os.path.join('xoxo', 'lib', 'site-python')
+ wanted = os.path.join('xoxo', 'lib', 'python' + sys.version[:3],
+ 'site-packages')
self.assertEqual(dirs[1], wanted)
+ wanted = os.path.join('xoxo', 'lib', 'site-python')
+ self.assertEqual(dirs[2], wanted)
else:
# other platforms
self.assertEqual(len(dirs), 2)
self.assertEqual(dirs[0], 'xoxo')
- wanted = os.path.join('xoxo', 'lib', 'site-packages')
+ wanted = os.path.join('xoxo', 'lib64', 'site-packages')
self.assertEqual(dirs[1], wanted)

def test_no_home_directory(self):
diff --git a/Makefile.pre.in b/Makefile.pre.in
index ed547b3..0db0716 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -110,7 +110,7 @@ LIBDIR= @libdir@
MANDIR= @mandir@
INCLUDEDIR= @includedir@
CONFINCLUDEDIR= $(exec_prefix)/include
-SCRIPTDIR= $(prefix)/lib
+SCRIPTDIR= $(prefix)/lib64

# Detailed destination directories
BINLIBDEST= $(LIBDIR)/python$(VERSION)
diff --git a/Modules/getpath.c b/Modules/getpath.c
index c42ce31..2c897ba 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -108,7 +108,7 @@ static char prefix[MAXPATHLEN+1];
static char exec_prefix[MAXPATHLEN+1];
static char progpath[MAXPATHLEN+1];
static char *module_search_path = NULL;
-static char lib_python[] = "lib/python" VERSION;
+static char lib_python[] = "lib64/python" VERSION;

static void
reduce(char *dir)
@@ -530,7 +530,7 @@ calculate_path(void)
fprintf(stderr,
"Could not find platform dependent libraries <exec_prefix>\n");
strncpy(exec_prefix, EXEC_PREFIX, MAXPATHLEN);
- joinpath(exec_prefix, "lib/lib-dynload");
+ joinpath(exec_prefix, "lib64/lib-dynload");
}
/* If we found EXEC_PREFIX do *not* reduce it! (Yet.) */

diff --git a/setup.py b/setup.py
index 52f9918..e1d79eb 100644
--- a/setup.py
+++ b/setup.py
@@ -502,7 +502,7 @@ class PyBuildExt(build_ext):
def detect_modules(self):
# Ensure that /usr/local is always used
if not cross_compiling:
- add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
+ add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib64')
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
if cross_compiling:
self.add_gcc_paths()
@@ -828,11 +828,11 @@ class PyBuildExt(build_ext):
elif curses_library:
readline_libs.append(curses_library)
elif self.compiler.find_library_file(lib_dirs +
- ['/usr/lib/termcap'],
+ ['/usr/lib64/termcap'],
'termcap'):
readline_libs.append('termcap')
exts.append( Extension('readline', ['readline.c'],
- library_dirs=['/usr/lib/termcap'],
+ library_dirs=['/usr/lib64/termcap'],
extra_link_args=readline_extra_link_args,
libraries=readline_libs) )
else:
@@ -867,8 +867,8 @@ class PyBuildExt(build_ext):
if krb5_h:
ssl_incs += krb5_h
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
- ['/usr/local/ssl/lib',
- '/usr/contrib/ssl/lib/'
+ ['/usr/local/ssl/lib64',
+ '/usr/contrib/ssl/lib64/'
] )

if (ssl_incs is not None and
--
2.7.4

63 changes: 63 additions & 0 deletions rpm/0003-Fix-sysconfig-for-multilib.patch
@@ -0,0 +1,63 @@
From bf3ea7be7221e01e3af790324039b1fe4b0467eb Mon Sep 17 00:00:00 2001
From: Matti Kosola <matti.kosola@jolla.com>
Date: Fri, 22 May 2020 08:03:57 +0200
Subject: [PATCH 3/4] Fix sysconfig for multilib

Python 2.7 split out much of the path-handling from distutils/sysconfig.py to
a new sysconfig.py (in r77704).
We need to make equivalent changes to that new file to ensure that the stdlib
and platform-specific code go to /usr/lib64 not /usr/lib, on 64-bit archs

Signed-off-by: Matti Kosola <matti.kosola@jolla.com>
---
Lib/sysconfig.py | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 9c8350d..1ff812f 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -7,20 +7,20 @@ from os.path import pardir, realpath

_INSTALL_SCHEMES = {
'posix_prefix': {
- 'stdlib': '{base}/lib/python{py_version_short}',
- 'platstdlib': '{platbase}/lib/python{py_version_short}',
+ 'stdlib': '{base}/lib64/python{py_version_short}',
+ 'platstdlib': '{platbase}/lib64/python{py_version_short}',
'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',
'include': '{base}/include/python{py_version_short}',
'platinclude': '{platbase}/include/python{py_version_short}',
'scripts': '{base}/bin',
'data': '{base}',
},
'posix_home': {
- 'stdlib': '{base}/lib/python',
- 'platstdlib': '{base}/lib/python',
+ 'stdlib': '{base}/lib64/python',
+ 'platstdlib': '{base}/lib64/python',
'purelib': '{base}/lib/python',
- 'platlib': '{base}/lib/python',
+ 'platlib': '{base}/lib64/python',
'include': '{base}/include/python',
'platinclude': '{base}/include/python',
'scripts': '{base}/bin',
@@ -65,10 +65,10 @@ _INSTALL_SCHEMES = {
'data' : '{userbase}',
},
'posix_user': {
- 'stdlib': '{userbase}/lib/python{py_version_short}',
- 'platstdlib': '{userbase}/lib/python{py_version_short}',
+ 'stdlib': '{userbase}/lib64/python{py_version_short}',
+ 'platstdlib': '{userbase}/lib64/python{py_version_short}',
'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
- 'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
+ 'platlib': '{userbase}/lib64/python{py_version_short}/site-packages',
'include': '{userbase}/include/python{py_version_short}',
'scripts': '{userbase}/bin',
'data' : '{userbase}',
--
2.7.4

30 changes: 30 additions & 0 deletions rpm/0004-Fix-test-installation-for-multilib.patch
@@ -0,0 +1,30 @@
From 9e91d78d6dc2b645d3905f19b0648505128f89a9 Mon Sep 17 00:00:00 2001
From: Matti Kosola <matti.kosola@jolla.com>
Date: Fri, 22 May 2020 08:06:25 +0200
Subject: [PATCH 4/4] Fix test installation for multilib

Another lib64 fix, for distutils/tests/test_install.py

Signed-off-by: Matti Kosola <matti.kosola@jolla.com>
---
Lib/distutils/tests/test_install.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
index 397e2a7..c72ae0b 100644
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -58,8 +58,9 @@ class InstallTestCase(support.TempdirManager,
self.assertEqual(got, expected)

libdir = os.path.join(destination, "lib", "python")
+ platlibdir = os.path.join(destination, "lib64", "python")
check_path(cmd.install_lib, libdir)
- check_path(cmd.install_platlib, libdir)
+ check_path(cmd.install_platlib, platlibdir)
check_path(cmd.install_purelib, libdir)
check_path(cmd.install_headers,
os.path.join(destination, "include", "python", "foopkg"))
--
2.7.4

24 changes: 23 additions & 1 deletion rpm/python.spec
Expand Up @@ -6,6 +6,10 @@ Name: python
%global dynload_dir %{pylibdir}/lib-dynload
%global soversion 1.0
%global pyversion %{pybasever}.17
# Disable automatic bytecompilation. The python2.7 binary is not yet
# available in /usr/bin when Python is built. Also, the bytecompilation fails
# on files that test invalid syntax.
%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g')

Summary: An interpreted, interactive, object-oriented programming language
Version: 2.7.17
Expand All @@ -19,6 +23,9 @@ Patch0: cgi-py-shebang.patch
Patch1: notimestamp.patch
Patch3: disable_modules.patch
Patch4: 0001-Disable-sqlite3-module.patch
Patch5: 0002-Fix-lib64-for-multilib.patch
Patch6: 0003-Fix-sysconfig-for-multilib.patch
Patch7: 0004-Fix-test-installation-for-multilib.patch
BuildRequires: pkgconfig(libffi)
BuildRequires: pkgconfig(ncursesw)
BuildRequires: pkgconfig(openssl)
Expand Down Expand Up @@ -54,7 +61,6 @@ Python modules.
This package provides the "python" executable; most of the actual
implementation is within the "python-libs" package.


%package libs
Summary: Runtime libraries for Python
Group: Applications/System
Expand Down Expand Up @@ -144,6 +150,13 @@ This package provides man pages for %{name}.
# disable sqlite3 module
%patch4 -p1

# multilib support
%if "%{_lib}" == "lib64"
%patch5 -p1
%patch6 -p1
%patch7 -p1
%endif

%build
export CC=gcc

Expand Down Expand Up @@ -304,6 +317,11 @@ rm -rf %{buildroot}%{pylibdir}/lib-tk
#we already have a LICENSE file elsewhere
rm -f %{buildroot}%{pylibdir}/LICENSE.txt

# Python should own /usr/lib/python2.x on 64-bit machines
%if "%{_lib}" == "lib64"
install -d %{buildroot}/%{_prefix}/lib/python%{pybasever}/site-packages
%endif

#TODO:
#rpmlint warnings (executable bits), e.g.:
#find -name '*.py' -exec if doesn't have +x perm && if has shebang: remove shebang
Expand Down Expand Up @@ -399,6 +417,10 @@ rm -f %{buildroot}%{pylibdir}/LICENSE.txt
%{dynload_dir}/unicodedata.so
%{dynload_dir}/zlib.so
%dir %{pylibdir}/site-packages
%if "%{_lib}" == "lib64"
%attr(0755,root,root) %dir %{_prefix}/lib/python%{pybasever}
%attr(0755,root,root) %dir %{_prefix}/lib/python%{pybasever}/site-packages
%endif
%{pylibdir}/site-packages/README
%{pylibdir}/*.py*
%dir %{pylibdir}/bsddb
Expand Down

0 comments on commit 302e09a

Please sign in to comment.