Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpython3.8m.so should not have m suffix #2278

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected static ArrayList<String> 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;
}
Expand Down
9 changes: 2 additions & 7 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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'))
Expand Down
6 changes: 1 addition & 5 deletions pythonforandroid/recipes/boost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions pythonforandroid/recipes/cffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 1 addition & 3 deletions pythonforandroid/recipes/opencv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 17 additions & 7 deletions pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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'),
Expand Down
2 changes: 1 addition & 1 deletion tests/recipes/test_python3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down