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 11, 2024
1 parent f526e6b commit 9d0df0f
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def strip_libraries(self, arch):
libs_dir = join(self.dist_dir, f'_python_bundle__{arch.arch}',
'_python_bundle', 'modules')
filens = shprint(sh.find, libs_dir, join(self.dist_dir, 'libs'),
'-iname', '*.so', _env=env).stdout.decode('utf-8')
'-iname', '*.so', _env=env)

logger.info('Stripping libraries in private dir')
for filen in filens.split('\n'):
Expand Down
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
1 change: 1 addition & 0 deletions pythonforandroid/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ def shprint(command, *args, **kwargs):
output = command(*args, **kwargs)
for line in output:
if isinstance(line, bytes):
# TODO: adjust?
line = line.decode('utf-8', errors='replace')
if logger.level > logging.DEBUG:
if full_debug:
Expand Down
11 changes: 6 additions & 5 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ def download(self):
ensure_dir(join(self.ctx.packages_path, self.name))

with current_directory(join(self.ctx.packages_path, self.name)):
filename = shprint(sh.basename, url).stdout[:-1].decode('utf-8')
# TODO: make sure we're passing here, maybe an assert False to be sure
filename = shprint(sh.basename, url)[:-1]

do_download = True
marker_filename = '.mark-{}'.format(filename)
Expand Down Expand Up @@ -440,8 +441,9 @@ def unpack(self, arch):
info('Skipping {} unpack as no URL is set'.format(self.name))
return

# TODO: make sure we're passing here, maybe an assert False to be sure
filename = shprint(
sh.basename, self.versioned_url).stdout[:-1].decode('utf-8')
sh.basename, self.versioned_url)[:-1]
ma = match(u'^(.+)#[a-z0-9_]{3,}=([0-9a-f]{32,})$', filename)
if ma: # fragmented URL?
filename = ma.group(1)
Expand Down Expand Up @@ -469,8 +471,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 @@ -1453,7 +1454,7 @@ def reduce_object_file_names(self, dirn):
coming from the local system.
"""
py_so_files = shprint(sh.find, dirn, '-iname', '*.so')
filens = py_so_files.stdout.decode('utf-8').split('\n')[:-1]
filens = py_so_files.split('\n')[:-1]
for filen in filens:
file_dirname, file_basename = split(filen)
parts = file_basename.split('.')
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/libxml2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def build_arch(self, arch):
shprint(sh.Command('./autogen.sh'), _env=env)
shprint(sh.Command('autoreconf'), '-vif', _env=env)
build_arch = shprint(
sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0]
sh.gcc, '-dumpmachine').split('\n')[0]
shprint(sh.Command('./configure'),
'--build=' + build_arch,
'--host=' + arch.command_prefix,
Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/recipes/protobuf_cpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def build_arch(self, arch):
with current_directory(self.get_build_dir(arch.arch)):
build_arch = (
shprint(sh.gcc, '-dumpmachine')
.stdout.decode('utf-8')
.split('\n')[0]
)

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
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 9d0df0f

Please sign in to comment.