Skip to content

Commit 28151d1

Browse files
authored
Use shutil.which instead of sh.which (#2637)
1 parent cae8a85 commit 28151d1

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

pythonforandroid/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def prepare_build_environment(self,
336336
self.ndk = AndroidNDK(self.ndk_dir)
337337

338338
# path to some tools
339-
self.ccache = sh.which("ccache")
339+
self.ccache = shutil.which("ccache")
340340
if not self.ccache:
341341
info('ccache is missing, the build will not be optimized in the '
342342
'future.')
@@ -905,7 +905,7 @@ def copylibs_function(soname, objs_paths, extra_link_dirs=None, env=None):
905905
elif 'READELF' in os.environ:
906906
readelf = os.environ['READELF']
907907
else:
908-
readelf = sh.which('readelf').strip()
908+
readelf = shutil.which('readelf').strip()
909909
readelf = sh.Command(readelf).bake('-d')
910910

911911
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
from os import environ
1314
from pythonforandroid.util import build_platform
1415

@@ -43,7 +44,7 @@ def get_recipe_env(self, arch):
4344
sysroot = f"{ndk_dir}/platforms/{env['NDK_API']}/arch-{sysroot_suffix}"
4445
FC = f"{ndk_dir}/toolchains/{arch_to_toolchain(arch)}-{GCC_VER}/prebuilt/{HOST}/bin/{arch.command_prefix}-gfortran"
4546
env['FC'] = f'{FC} --sysroot={sysroot}'
46-
if sh.which(FC) is None:
47+
if shutil.which(FC) is None:
4748
raise BuildInterruptingException(f"{FC} not found. See https://github.com/mzakharo/android-gfortran")
4849
return env
4950

pythonforandroid/recipes/numpy/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from os.path import join
66
import glob
77
import sh
8+
import shutil
89

910

1011
class NumpyRecipe(CompiledComponentsPythonRecipe):
@@ -67,7 +68,7 @@ def rebuild_compiled_components(self, arch, env):
6768

6869
def get_hostrecipe_env(self, arch):
6970
env = super().get_hostrecipe_env(arch)
70-
env['RANLIB'] = sh.which('ranlib')
71+
env['RANLIB'] = shutil.which('ranlib')
7172
return env
7273

7374

pythonforandroid/recipes/python3/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from os import environ, utime
77
from os.path import dirname, exists, join
88
from pathlib import Path
9-
from shutil import copy2
9+
import shutil
1010

1111
from pythonforandroid.logger import info, warning, shprint
1212
from pythonforandroid.patching import version_starts_with
@@ -73,7 +73,7 @@ class Python3Recipe(TargetPythonRecipe):
7373
('patches/py3.8.1.patch', version_starts_with("3.9"))
7474
]
7575

76-
if sh.which('lld') is not None:
76+
if shutil.which('lld') is not None:
7777
patches = patches + [
7878
("patches/py3.7.1_fix_cortex_a8.patch", version_starts_with("3.7")),
7979
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.8")),
@@ -208,7 +208,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
208208
)
209209

210210
env['LDFLAGS'] = env.get('LDFLAGS', '')
211-
if sh.which('lld') is not None:
211+
if shutil.which('lld') is not None:
212212
# Note: The -L. is to fix a bug in python 3.7.
213213
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234409
214214
env['LDFLAGS'] += ' -L. -fuse-ld=lld'
@@ -380,7 +380,7 @@ def create_python_bundle(self, dirn, arch):
380380
info("Copy {} files into the bundle".format(len(module_filens)))
381381
for filen in module_filens:
382382
info(" - copy {}".format(filen))
383-
copy2(filen, modules_dir)
383+
shutil.copy2(filen, modules_dir)
384384

385385
# zip up the standard library
386386
stdlib_zip = join(dirn, 'stdlib.zip')
@@ -408,7 +408,7 @@ def create_python_bundle(self, dirn, arch):
408408
for filen in filens:
409409
info(" - copy {}".format(filen))
410410
ensure_dir(join(dirn, 'site-packages', dirname(filen)))
411-
copy2(filen, join(dirn, 'site-packages', filen))
411+
shutil.copy2(filen, join(dirn, 'site-packages', filen))
412412

413413
# copy the python .so files into place
414414
python_build_dir = join(self.get_build_dir(arch.arch),

0 commit comments

Comments
 (0)