Skip to content

Commit

Permalink
⬆️ Bump to sh 2
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreMiras committed Aug 13, 2024
1 parent f526e6b commit 25504c9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
def get_targets(sdk_dir):
if exists(join(sdk_dir, 'cmdline-tools', 'latest', 'bin', 'avdmanager')):
avdmanager = sh.Command(join(sdk_dir, 'cmdline-tools', 'latest', 'bin', 'avdmanager'))
targets = avdmanager('list', 'target').stdout.decode('utf-8').split('\n')
targets = avdmanager('list', 'target').split('\n')

elif exists(join(sdk_dir, 'tools', 'bin', 'avdmanager')):
avdmanager = sh.Command(join(sdk_dir, 'tools', 'bin', 'avdmanager'))
targets = avdmanager('list', 'target').stdout.decode('utf-8').split('\n')
targets = avdmanager('list', 'target').split('\n')
elif exists(join(sdk_dir, 'tools', 'android')):
android = sh.Command(join(sdk_dir, 'tools', 'android'))
targets = android('list').stdout.decode('utf-8').split('\n')
targets = android('list').split('\n')
else:
raise BuildInterruptingException(
'Could not find `android` or `sdkmanager` binaries in Android SDK',
Expand Down
11 changes: 6 additions & 5 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
from urllib.request import urlretrieve
from os import listdir, unlink, environ, curdir, walk
from sys import stdout
from wheel.wheelfile import WheelFile
from wheel.cli.tags import tags as wheel_tags
from unittest import mock
import time
try:
from urlparse import urlparse
Expand All @@ -26,7 +25,7 @@
logger, info, warning, debug, shprint, info_main, error)
from pythonforandroid.util import (
current_directory, ensure_dir, BuildInterruptingException, rmdir, move,
touch)
touch, patch_wheel_setuptools_logging)
from pythonforandroid.util import load_source as import_recipe


Expand Down Expand Up @@ -469,8 +468,7 @@ def unpack(self, arch):
elif extraction_filename.endswith(
('.tar.gz', '.tgz', '.tar.bz2', '.tbz2', '.tar.xz', '.txz')):
sh.tar('xf', extraction_filename)
root_directory = sh.tar('tf', extraction_filename).stdout.decode(
'utf-8').split('\n')[0].split('/')[0]
root_directory = sh.tar('tf', extraction_filename).split('\n')[0].split('/')[0]
if root_directory != basename(directory_name):
move(root_directory, directory_name)
else:
Expand Down Expand Up @@ -1205,6 +1203,9 @@ def get_wheel_platform_tag(self, arch):
}[arch.arch]

def install_wheel(self, arch, built_wheels):
with patch_wheel_setuptools_logging():
from wheel.cli.tags import tags as wheel_tags
from wheel.wheelfile import WheelFile
_wheel = built_wheels[0]
built_wheel_dir = dirname(_wheel)
# Fix wheel platform tag
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def build_arch(self, arch):

android_build = sh.Command(
join(recipe_build_dir,
'config.guess'))().stdout.strip().decode('utf-8')
'config.guess'))()

with current_directory(build_dir):
if not exists('config.status'):
Expand Down
13 changes: 13 additions & 0 deletions pythonforandroid/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
from unittest import mock
from fnmatch import fnmatch
import logging
from os.path import exists, join
Expand Down Expand Up @@ -163,3 +164,15 @@ def max_build_tool_version(
"""

return max(build_tools_versions, key=build_tools_version_sort_key)

def patch_wheel_setuptools_logging():
"""
When setuptools is not present and the root logger has no handlers,
Wheels would configure the root logger with DEBUG level, refs:
- https://github.com/pypa/wheel/blob/0.44.0/src/wheel/util.py
- https://github.com/pypa/wheel/blob/0.44.0/src/wheel/_setuptools_logging.py
Both of these conditions are met in our CI, leading to very verbose
and unreadable `sh` logs. Patching it prevents that.
"""
return mock.patch("wheel._setuptools_logging.configure")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# https://github.com/kivy/buildozer/issues/722
install_reqs = [
'appdirs', 'colorama>=0.3.3', 'jinja2',
'sh>=1.10, <2.0; sys_platform!="win32"',
'sh>=2, <3.0; sys_platform!="win32"',
'build', 'toml', 'packaging', 'setuptools', 'wheel~=0.43.0'
]
# (build and toml are used by pythonpackage.py)
Expand Down

0 comments on commit 25504c9

Please sign in to comment.