Skip to content

Commit ed4a23c

Browse files
misl6SomberNight
authored andcommitted
Use shutil.which instead of sh.which (kivy#2637)
1 parent 0121ca8 commit ed4a23c

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

pythonforandroid/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def prepare_build_environment(self,
392392
check_ndk_api(ndk_api, self.android_api)
393393

394394
# path to some tools
395-
self.ccache = sh.which("ccache")
395+
self.ccache = shutil.which("ccache")
396396
if not self.ccache:
397397
info('ccache is missing, the build will not be optimized in the '
398398
'future.')
@@ -463,7 +463,7 @@ def prepare_build_environment(self,
463463

464464
for executable in ("pkg-config", "autoconf", "automake", "libtoolize",
465465
"tar", "bzip2", "unzip", "make", "gcc", "g++"):
466-
if not sh.which(executable):
466+
if not shutil.which(executable):
467467
warning(f"Missing executable: {executable} is not installed")
468468

469469
if not ok:
@@ -1012,7 +1012,7 @@ def copylibs_function(soname, objs_paths, extra_link_dirs=None, env=None):
10121012
elif 'READELF' in os.environ:
10131013
readelf = os.environ['READELF']
10141014
else:
1015-
readelf = sh.which('readelf').strip()
1015+
readelf = shutil.which('readelf').strip()
10161016
readelf = sh.Command(readelf).bake('-d')
10171017

10181018
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/numpy/__init__.py

Lines changed: 1 addition & 0 deletions
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):

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")),
@@ -209,7 +209,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
209209
)
210210

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

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

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

0 commit comments

Comments
 (0)