Skip to content

Commit 25504c9

Browse files
committed
⬆️ Bump to sh 2
1 parent f526e6b commit 25504c9

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

pythonforandroid/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
def get_targets(sdk_dir):
3030
if exists(join(sdk_dir, 'cmdline-tools', 'latest', 'bin', 'avdmanager')):
3131
avdmanager = sh.Command(join(sdk_dir, 'cmdline-tools', 'latest', 'bin', 'avdmanager'))
32-
targets = avdmanager('list', 'target').stdout.decode('utf-8').split('\n')
32+
targets = avdmanager('list', 'target').split('\n')
3333

3434
elif exists(join(sdk_dir, 'tools', 'bin', 'avdmanager')):
3535
avdmanager = sh.Command(join(sdk_dir, 'tools', 'bin', 'avdmanager'))
36-
targets = avdmanager('list', 'target').stdout.decode('utf-8').split('\n')
36+
targets = avdmanager('list', 'target').split('\n')
3737
elif exists(join(sdk_dir, 'tools', 'android')):
3838
android = sh.Command(join(sdk_dir, 'tools', 'android'))
39-
targets = android('list').stdout.decode('utf-8').split('\n')
39+
targets = android('list').split('\n')
4040
else:
4141
raise BuildInterruptingException(
4242
'Could not find `android` or `sdkmanager` binaries in Android SDK',

pythonforandroid/recipe.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
from urllib.request import urlretrieve
1313
from os import listdir, unlink, environ, curdir, walk
1414
from sys import stdout
15-
from wheel.wheelfile import WheelFile
16-
from wheel.cli.tags import tags as wheel_tags
15+
from unittest import mock
1716
import time
1817
try:
1918
from urlparse import urlparse
@@ -26,7 +25,7 @@
2625
logger, info, warning, debug, shprint, info_main, error)
2726
from pythonforandroid.util import (
2827
current_directory, ensure_dir, BuildInterruptingException, rmdir, move,
29-
touch)
28+
touch, patch_wheel_setuptools_logging)
3029
from pythonforandroid.util import load_source as import_recipe
3130

3231

@@ -469,8 +468,7 @@ def unpack(self, arch):
469468
elif extraction_filename.endswith(
470469
('.tar.gz', '.tgz', '.tar.bz2', '.tbz2', '.tar.xz', '.txz')):
471470
sh.tar('xf', extraction_filename)
472-
root_directory = sh.tar('tf', extraction_filename).stdout.decode(
473-
'utf-8').split('\n')[0].split('/')[0]
471+
root_directory = sh.tar('tf', extraction_filename).split('\n')[0].split('/')[0]
474472
if root_directory != basename(directory_name):
475473
move(root_directory, directory_name)
476474
else:
@@ -1205,6 +1203,9 @@ def get_wheel_platform_tag(self, arch):
12051203
}[arch.arch]
12061204

12071205
def install_wheel(self, arch, built_wheels):
1206+
with patch_wheel_setuptools_logging():
1207+
from wheel.cli.tags import tags as wheel_tags
1208+
from wheel.wheelfile import WheelFile
12081209
_wheel = built_wheels[0]
12091210
built_wheel_dir = dirname(_wheel)
12101211
# Fix wheel platform tag

pythonforandroid/recipes/python3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def build_arch(self, arch):
320320

321321
android_build = sh.Command(
322322
join(recipe_build_dir,
323-
'config.guess'))().stdout.strip().decode('utf-8')
323+
'config.guess'))()
324324

325325
with current_directory(build_dir):
326326
if not exists('config.status'):

pythonforandroid/util.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import contextlib
2+
from unittest import mock
23
from fnmatch import fnmatch
34
import logging
45
from os.path import exists, join
@@ -163,3 +164,15 @@ def max_build_tool_version(
163164
"""
164165

165166
return max(build_tools_versions, key=build_tools_version_sort_key)
167+
168+
def patch_wheel_setuptools_logging():
169+
"""
170+
When setuptools is not present and the root logger has no handlers,
171+
Wheels would configure the root logger with DEBUG level, refs:
172+
- https://github.com/pypa/wheel/blob/0.44.0/src/wheel/util.py
173+
- https://github.com/pypa/wheel/blob/0.44.0/src/wheel/_setuptools_logging.py
174+
175+
Both of these conditions are met in our CI, leading to very verbose
176+
and unreadable `sh` logs. Patching it prevents that.
177+
"""
178+
return mock.patch("wheel._setuptools_logging.configure")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# https://github.com/kivy/buildozer/issues/722
2222
install_reqs = [
2323
'appdirs', 'colorama>=0.3.3', 'jinja2',
24-
'sh>=1.10, <2.0; sys_platform!="win32"',
24+
'sh>=2, <3.0; sys_platform!="win32"',
2525
'build', 'toml', 'packaging', 'setuptools', 'wheel~=0.43.0'
2626
]
2727
# (build and toml are used by pythonpackage.py)

0 commit comments

Comments
 (0)