Skip to content

Commit 211fe88

Browse files
committed
Use shutil.which instead of sh.which
Handcrafted version of this patch upstream: kivy#2637 https://phabricator.endlessm.com/T33736
1 parent 7d2a759 commit 211fe88

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

pythonforandroid/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def select_and_check_toolchain_version(sdk_dir, ndk_dir, arch, ndk_sysroot_exist
102102
"gcc",
103103
"g++",
104104
):
105-
if not sh.which(executable):
105+
if not shutil.which(executable):
106106
warning(f"Missing executable: {executable} is not installed")
107107

108108
if not ok:
@@ -424,7 +424,7 @@ def prepare_build_environment(self,
424424
check_ndk_api(ndk_api, self.android_api)
425425

426426
# path to some tools
427-
self.ccache = sh.which("ccache")
427+
self.ccache = shutil.which("ccache")
428428
if not self.ccache:
429429
info('ccache is missing, the build will not be optimized in the '
430430
'future.')
@@ -1000,7 +1000,7 @@ def copylibs_function(soname, objs_paths, extra_link_dirs=None, env=None):
10001000
elif 'READELF' in os.environ:
10011001
readelf = os.environ['READELF']
10021002
else:
1003-
readelf = sh.which('readelf').strip()
1003+
readelf = shutil.which('readelf').strip()
10041004
readelf = sh.Command(readelf).bake('-d')
10051005

10061006
dest = dirname(soname)

pythonforandroid/recipes/lapack/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from multiprocessing import cpu_count
1010
from os.path import join
1111
import sh
12+
import shutil
1213

1314

1415
class LapackRecipe(Recipe):
@@ -25,7 +26,7 @@ def get_recipe_env(self, arch):
2526
sysroot = f"{self.ctx.ndk_dir}/platforms/{env['NDK_API']}/{arch.platform_dir}"
2627
FC = f"{env['TOOLCHAIN_PREFIX']}-gfortran"
2728
env['FC'] = f'{FC} --sysroot={sysroot}'
28-
if sh.which(FC) is None:
29+
if shutil.which(FC) is None:
2930
raise BuildInterruptingException(f"{FC} not found. See https://github.com/mzakharo/android-gfortran")
3031
return env
3132

pythonforandroid/recipes/python3/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import glob
22
import sh
3+
import shutil
34
import subprocess
45

56
from multiprocessing import cpu_count
@@ -73,7 +74,7 @@ class Python3Recipe(TargetPythonRecipe):
7374
('patches/py3.8.1.patch', version_starts_with("3.9"))
7475
]
7576

76-
if sh.which('lld') is not None:
77+
if shutil.which('lld') is not None:
7778
patches = patches + [
7879
("patches/py3.7.1_fix_cortex_a8.patch", version_starts_with("3.7")),
7980
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.8")),
@@ -209,7 +210,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
209210
)
210211

211212
env['LDFLAGS'] = env.get('LDFLAGS', '')
212-
if sh.which('lld') is not None:
213+
if shutil.which('lld') is not None:
213214
# Note: The -L. is to fix a bug in python 3.7.
214215
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234409
215216
env['LDFLAGS'] += ' -L. -fuse-ld=lld'

0 commit comments

Comments
 (0)