From de8f339b540df344c131d41f01598b2441b794af Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Tue, 4 Aug 2020 08:30:04 +0100 Subject: [PATCH] `libpython3.8m.so` should not have `m` suffix --- .../java/org/kivy/android/PythonUtil.java | 2 +- pythonforandroid/recipe.py | 9 ++----- pythonforandroid/recipes/boost/__init__.py | 6 +---- pythonforandroid/recipes/cffi/__init__.py | 4 +--- pythonforandroid/recipes/opencv/__init__.py | 4 +--- pythonforandroid/recipes/python3/__init__.py | 24 +++++++++++++------ tests/recipes/test_python3.py | 2 +- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java b/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java index ebb3286024..14d44bab40 100644 --- a/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java +++ b/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java @@ -43,7 +43,7 @@ protected static ArrayList getLibraries(File libsDir) { libsList.add("python3.5m"); libsList.add("python3.6m"); libsList.add("python3.7m"); - libsList.add("python3.8m"); + libsList.add("python3.8"); libsList.add("main"); return libsList; } diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py index 9236c96864..a287c011a4 100644 --- a/pythonforandroid/recipe.py +++ b/pythonforandroid/recipe.py @@ -757,9 +757,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=False): env['PYTHON_INCLUDE_ROOT'] = self.ctx.python_recipe.include_root(arch.arch) env['PYTHON_LINK_ROOT'] = self.ctx.python_recipe.link_root(arch.arch) env['EXTRA_LDLIBS'] = ' -lpython{}'.format( - self.ctx.python_recipe.major_minor_version_string) - if 'python3' in self.ctx.python_recipe.name: - env['EXTRA_LDLIBS'] += 'm' + self.ctx.python_recipe.link_version) return env @@ -896,16 +894,13 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True): env['LANG'] = "en_GB.UTF-8" if not self.call_hostpython_via_targetpython: - python_name = self.ctx.python_recipe.name env['CFLAGS'] += ' -I{}'.format( self.ctx.python_recipe.include_root(arch.arch) ) env['LDFLAGS'] += ' -L{} -lpython{}'.format( self.ctx.python_recipe.link_root(arch.arch), - self.ctx.python_recipe.major_minor_version_string, + self.ctx.python_recipe.link_version, ) - if python_name == 'python3': - env['LDFLAGS'] += 'm' hppath = [] hppath.append(join(dirname(self.hostpython_location), 'Lib')) diff --git a/pythonforandroid/recipes/boost/__init__.py b/pythonforandroid/recipes/boost/__init__.py index 47f91b8a4a..cebbd5ca83 100644 --- a/pythonforandroid/recipes/boost/__init__.py +++ b/pythonforandroid/recipes/boost/__init__.py @@ -92,11 +92,7 @@ def get_recipe_env(self, arch): env['PYTHON_ROOT'] = self.ctx.python_recipe.link_root(arch.arch) env['PYTHON_INCLUDE'] = self.ctx.python_recipe.include_root(arch.arch) env['PYTHON_MAJOR_MINOR'] = self.ctx.python_recipe.version[:3] - env[ - 'PYTHON_LINK_VERSION' - ] = self.ctx.python_recipe.major_minor_version_string - if 'python3' in self.ctx.python_recipe.name: - env['PYTHON_LINK_VERSION'] += 'm' + env['PYTHON_LINK_VERSION'] = self.ctx.python_recipe.link_version env['ARCH'] = arch.arch.replace('-', '') env['TARGET_TRIPLET'] = arch.target diff --git a/pythonforandroid/recipes/cffi/__init__.py b/pythonforandroid/recipes/cffi/__init__.py index 3416fec620..dbe805eced 100644 --- a/pythonforandroid/recipes/cffi/__init__.py +++ b/pythonforandroid/recipes/cffi/__init__.py @@ -43,9 +43,7 @@ def get_recipe_env(self, arch=None): env['BUILDLIB_PATH'], ]) env['LDFLAGS'] += ' -L{}'.format(self.ctx.python_recipe.link_root(arch.arch)) - env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.major_minor_version_string) - if 'python3' in self.ctx.python_recipe.name: - env['LDFLAGS'] += 'm' + env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.link_version) return env diff --git a/pythonforandroid/recipes/opencv/__init__.py b/pythonforandroid/recipes/opencv/__init__.py index a90ddda925..8a7999d424 100644 --- a/pythonforandroid/recipes/opencv/__init__.py +++ b/pythonforandroid/recipes/opencv/__init__.py @@ -63,9 +63,7 @@ def build_arch(self, arch): python_include_root = self.ctx.python_recipe.include_root(arch.arch) python_site_packages = self.ctx.get_site_packages_dir() python_link_root = self.ctx.python_recipe.link_root(arch.arch) - python_link_version = self.ctx.python_recipe.major_minor_version_string - if 'python3' in self.ctx.python_recipe.name: - python_link_version += 'm' + python_link_version = self.ctx.python_recipe.link_version python_library = join(python_link_root, 'libpython{}.so'.format(python_link_version)) python_include_numpy = join(python_site_packages, diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index b6ef9021a6..114f168332 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -155,10 +155,22 @@ def __init__(self, *args, **kwargs): @property def _libpython(self): '''return the python's library name (with extension)''' - py_version = self.major_minor_version_string - if self.major_minor_version_string[0] == '3': - py_version += 'm' - return 'libpython{version}.so'.format(version=py_version) + return 'libpython{link_version}.so'.format( + link_version=self.link_version + ) + + @property + def link_version(self): + '''return the python's library link version e.g. 3.7m, 3.8''' + major, minor = self.major_minor_version_string.split('.') + flags = '' + if major == '3' and int(minor) < 8: + flags += 'm' + return '{major}.{minor}{flags}'.format( + major=major, + minor=minor, + flags=flags + ) def include_root(self, arch_name): return join(self.get_build_dir(arch_name), 'Include') @@ -393,9 +405,7 @@ def create_python_bundle(self, dirn, arch): # copy the python .so files into place python_build_dir = join(self.get_build_dir(arch.arch), 'android-build') - python_lib_name = 'libpython' + self.major_minor_version_string - if self.major_minor_version_string[0] == '3': - python_lib_name += 'm' + python_lib_name = 'libpython' + self.link_version shprint( sh.cp, join(python_build_dir, python_lib_name + '.so'), diff --git a/tests/recipes/test_python3.py b/tests/recipes/test_python3.py index 786a6e3e53..66698c9162 100644 --- a/tests/recipes/test_python3.py +++ b/tests/recipes/test_python3.py @@ -19,7 +19,7 @@ class TestPython3Recipe(RecipeCtx, unittest.TestCase): def test_property__libpython(self): self.assertEqual( self.recipe._libpython, - f'libpython{self.recipe.major_minor_version_string}m.so' + f'libpython{self.recipe.link_version}.so' ) @mock.patch('pythonforandroid.recipes.python3.Path.is_file')