Skip to content

Commit cb760ae

Browse files
authored
Merge pull request #2278 from davidhewitt/patch-1
`libpython3.8m.so` should not have `m` suffix
2 parents 0db8184 + de8f339 commit cb760ae

File tree

7 files changed

+24
-27
lines changed

7 files changed

+24
-27
lines changed

pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected static ArrayList<String> getLibraries(File libsDir) {
4343
libsList.add("python3.5m");
4444
libsList.add("python3.6m");
4545
libsList.add("python3.7m");
46-
libsList.add("python3.8m");
46+
libsList.add("python3.8");
4747
libsList.add("main");
4848
return libsList;
4949
}

pythonforandroid/recipe.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -775,9 +775,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=False):
775775
env['PYTHON_INCLUDE_ROOT'] = self.ctx.python_recipe.include_root(arch.arch)
776776
env['PYTHON_LINK_ROOT'] = self.ctx.python_recipe.link_root(arch.arch)
777777
env['EXTRA_LDLIBS'] = ' -lpython{}'.format(
778-
self.ctx.python_recipe.major_minor_version_string)
779-
if 'python3' in self.ctx.python_recipe.name:
780-
env['EXTRA_LDLIBS'] += 'm'
778+
self.ctx.python_recipe.link_version)
781779
return env
782780

783781

@@ -914,16 +912,13 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
914912
env['LANG'] = "en_GB.UTF-8"
915913

916914
if not self.call_hostpython_via_targetpython:
917-
python_name = self.ctx.python_recipe.name
918915
env['CFLAGS'] += ' -I{}'.format(
919916
self.ctx.python_recipe.include_root(arch.arch)
920917
)
921918
env['LDFLAGS'] += ' -L{} -lpython{}'.format(
922919
self.ctx.python_recipe.link_root(arch.arch),
923-
self.ctx.python_recipe.major_minor_version_string,
920+
self.ctx.python_recipe.link_version,
924921
)
925-
if python_name == 'python3':
926-
env['LDFLAGS'] += 'm'
927922

928923
hppath = []
929924
hppath.append(join(dirname(self.hostpython_location), 'Lib'))

pythonforandroid/recipes/boost/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ def get_recipe_env(self, arch):
9292
env['PYTHON_ROOT'] = self.ctx.python_recipe.link_root(arch.arch)
9393
env['PYTHON_INCLUDE'] = self.ctx.python_recipe.include_root(arch.arch)
9494
env['PYTHON_MAJOR_MINOR'] = self.ctx.python_recipe.version[:3]
95-
env[
96-
'PYTHON_LINK_VERSION'
97-
] = self.ctx.python_recipe.major_minor_version_string
98-
if 'python3' in self.ctx.python_recipe.name:
99-
env['PYTHON_LINK_VERSION'] += 'm'
95+
env['PYTHON_LINK_VERSION'] = self.ctx.python_recipe.link_version
10096

10197
env['ARCH'] = arch.arch.replace('-', '')
10298
env['TARGET_TRIPLET'] = arch.target

pythonforandroid/recipes/cffi/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ def get_recipe_env(self, arch=None):
4343
env['BUILDLIB_PATH'],
4444
])
4545
env['LDFLAGS'] += ' -L{}'.format(self.ctx.python_recipe.link_root(arch.arch))
46-
env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.major_minor_version_string)
47-
if 'python3' in self.ctx.python_recipe.name:
48-
env['LDFLAGS'] += 'm'
46+
env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.link_version)
4947
return env
5048

5149

pythonforandroid/recipes/opencv/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ def build_arch(self, arch):
6363
python_include_root = self.ctx.python_recipe.include_root(arch.arch)
6464
python_site_packages = self.ctx.get_site_packages_dir()
6565
python_link_root = self.ctx.python_recipe.link_root(arch.arch)
66-
python_link_version = self.ctx.python_recipe.major_minor_version_string
67-
if 'python3' in self.ctx.python_recipe.name:
68-
python_link_version += 'm'
66+
python_link_version = self.ctx.python_recipe.link_version
6967
python_library = join(python_link_root,
7068
'libpython{}.so'.format(python_link_version))
7169
python_include_numpy = join(python_site_packages,

pythonforandroid/recipes/python3/__init__.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,22 @@ def __init__(self, *args, **kwargs):
155155
@property
156156
def _libpython(self):
157157
'''return the python's library name (with extension)'''
158-
py_version = self.major_minor_version_string
159-
if self.major_minor_version_string[0] == '3':
160-
py_version += 'm'
161-
return 'libpython{version}.so'.format(version=py_version)
158+
return 'libpython{link_version}.so'.format(
159+
link_version=self.link_version
160+
)
161+
162+
@property
163+
def link_version(self):
164+
'''return the python's library link version e.g. 3.7m, 3.8'''
165+
major, minor = self.major_minor_version_string.split('.')
166+
flags = ''
167+
if major == '3' and int(minor) < 8:
168+
flags += 'm'
169+
return '{major}.{minor}{flags}'.format(
170+
major=major,
171+
minor=minor,
172+
flags=flags
173+
)
162174

163175
def include_root(self, arch_name):
164176
return join(self.get_build_dir(arch_name), 'Include')
@@ -393,9 +405,7 @@ def create_python_bundle(self, dirn, arch):
393405
# copy the python .so files into place
394406
python_build_dir = join(self.get_build_dir(arch.arch),
395407
'android-build')
396-
python_lib_name = 'libpython' + self.major_minor_version_string
397-
if self.major_minor_version_string[0] == '3':
398-
python_lib_name += 'm'
408+
python_lib_name = 'libpython' + self.link_version
399409
shprint(
400410
sh.cp,
401411
join(python_build_dir, python_lib_name + '.so'),

tests/recipes/test_python3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestPython3Recipe(RecipeCtx, unittest.TestCase):
1919
def test_property__libpython(self):
2020
self.assertEqual(
2121
self.recipe._libpython,
22-
f'libpython{self.recipe.major_minor_version_string}m.so'
22+
f'libpython{self.recipe.link_version}.so'
2323
)
2424

2525
@mock.patch('pythonforandroid.recipes.python3.Path.is_file')

0 commit comments

Comments
 (0)