Skip to content

🔥 Move to python3 super calls #2106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pythonforandroid/archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Arch(object):
]

def __init__(self, ctx):
super(Arch, self).__init__()
super().__init__()
self.ctx = ctx

# Allows injecting additional linker paths used by any recipe.
Expand Down Expand Up @@ -309,6 +309,6 @@ class ArchAarch_64(Arch):
# NDK r19 build system, because it seems that we don't need it anymore,
# do we need them?
# def get_env(self, with_flags_in_cc=True):
# env = super(ArchAarch_64, self).get_env(with_flags_in_cc)
# env = super().get_env(with_flags_in_cc)
# env['EXTRA_CFLAGS'] = self.arch_cflags[-1]
# return env
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run_distribute(self):

self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(SDL2GradleBootstrap, self).run_distribute()
super().run_distribute()


bootstrap = SDL2GradleBootstrap()
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/service_only/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_distribute(self):

self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(ServiceOnlyBootstrap, self).run_distribute()
super().run_distribute()


bootstrap = ServiceOnlyBootstrap()
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/webview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run_distribute(self):

self.strip_libraries(arch)
self.fry_eggs(site_packages_dir)
super(WebViewBootstrap, self).run_distribute()
super().run_distribute()


bootstrap = WebViewBootstrap()
2 changes: 1 addition & 1 deletion pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def prepare_build_environment(self,
'python-for-android cannot continue due to the missing executables above')

def __init__(self):
super(Context, self).__init__()
super().__init__()
self.include_dirs = []

self._build_env_prepared = False
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def format(self, record):
record.msg = '{}{}[DEBUG]{}{}: '.format(
Err_Style.BRIGHT, Err_Fore.LIGHTBLACK_EX, Err_Fore.RESET,
Err_Style.RESET_ALL) + record.msg
return super(LevelDifferentiatingFormatter, self).format(record)
return super().format(record)


logger = logging.getLogger('p4a')
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GuestPythonRecipe(TargetPythonRecipe):

def __init__(self, *args, **kwargs):
self._ctx = None
super(GuestPythonRecipe, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = environ.copy()
Expand Down Expand Up @@ -216,7 +216,7 @@ def should_build(self, arch):
return not isfile(join(self.link_root(arch.arch), self._libpython))

def prebuild_arch(self, arch):
super(TargetPythonRecipe, self).prebuild_arch(arch)
super().prebuild_arch(arch)
self.ctx.python_recipe = self

def build_arch(self, arch):
Expand Down
24 changes: 12 additions & 12 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __new__(cls, name, bases, dct):
if 'version' in dct:
dct['_version'] = dct.pop('version')

return super(RecipeMeta, cls).__new__(cls, name, bases, dct)
return super().__new__(cls, name, bases, dct)


class Recipe(with_metaclass(RecipeMeta)):
Expand Down Expand Up @@ -769,8 +769,7 @@ def get_jni_dir(self):
return join(self.ctx.bootstrap.build_dir, 'jni')

def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=False):
env = super(BootstrapNDKRecipe, self).get_recipe_env(
arch, with_flags_in_cc)
env = super().get_recipe_env(arch, with_flags_in_cc)
if not with_python:
return env

Expand Down Expand Up @@ -804,7 +803,7 @@ def get_jni_dir(self, arch):
return join(self.get_build_dir(arch.arch), 'jni')

def build_arch(self, arch, *extra_args):
super(NDKRecipe, self).build_arch(arch)
super().build_arch(arch)

env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
Expand Down Expand Up @@ -856,7 +855,8 @@ class PythonRecipe(Recipe):
'''

def __init__(self, *args, **kwargs):
super(PythonRecipe, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

if 'python3' not in self.depends:
# We ensure here that the recipe depends on python even it overrode
# `depends`. We only do this if it doesn't already depend on any
Expand All @@ -868,7 +868,7 @@ def __init__(self, *args, **kwargs):
self.depends = depends

def clean_build(self, arch=None):
super(PythonRecipe, self).clean_build(arch=arch)
super().clean_build(arch=arch)
name = self.folder_name
python_install_dirs = glob.glob(join(self.ctx.python_installs_dir, '*'))
for python_install in python_install_dirs:
Expand Down Expand Up @@ -905,7 +905,7 @@ def folder_name(self):
return name

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(PythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env = super().get_recipe_env(arch, with_flags_in_cc)

env['PYTHONNOUSERSITE'] = '1'

Expand Down Expand Up @@ -950,7 +950,7 @@ def should_build(self, arch):
def build_arch(self, arch):
'''Install the Python module by calling setup.py install with
the target Python dir.'''
super(PythonRecipe, self).build_arch(arch)
super().build_arch(arch)
self.install_python_package(arch)

def install_python_package(self, arch, name=None, env=None, is_dir=True):
Expand Down Expand Up @@ -1020,7 +1020,7 @@ def build_compiled_components(self, arch):
def install_hostpython_package(self, arch):
env = self.get_hostrecipe_env(arch)
self.rebuild_compiled_components(arch, env)
super(CompiledComponentsPythonRecipe, self).install_hostpython_package(arch)
super().install_hostpython_package(arch)

def rebuild_compiled_components(self, arch, env):
info('Rebuilding compiled components in {}'.format(self.name))
Expand Down Expand Up @@ -1122,7 +1122,7 @@ def cythonize_build(self, env, build_dir="."):
self.cythonize_file(env, build_dir, join(root, filename))

def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super(CythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env = super().get_recipe_env(arch, with_flags_in_cc)
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
self.ctx.get_libs_dir(arch.arch) +
' -L{} '.format(self.ctx.libs_dir) +
Expand Down Expand Up @@ -1152,10 +1152,10 @@ class TargetPythonRecipe(Recipe):

def __init__(self, *args, **kwargs):
self._ctx = None
super(TargetPythonRecipe, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def prebuild_arch(self, arch):
super(TargetPythonRecipe, self).prebuild_arch(arch)
super().prebuild_arch(arch)
self.ctx.python_recipe = self

def include_root(self, arch):
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/Pillow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PillowRecipe(CompiledComponentsPythonRecipe):
call_hostpython_via_targetpython = False

def get_recipe_env(self, arch=None, with_flags_in_cc=True):
env = super(PillowRecipe, self).get_recipe_env(arch, with_flags_in_cc)
env = super().get_recipe_env(arch, with_flags_in_cc)

env['ANDROID_ROOT'] = join(self.ctx.ndk_platform, 'usr')
ndk_lib_dir = join(self.ctx.ndk_platform, 'usr', 'lib')
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/android/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe):
config_env = {}

def get_recipe_env(self, arch):
env = super(AndroidRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
env.update(self.config_env)
return env

def prebuild_arch(self, arch):
super(AndroidRecipe, self).prebuild_arch(arch)
super().prebuild_arch(arch)
ctx_bootstrap = self.ctx.bootstrap.name

# define macros for Cython, C, Python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BillingService(object):
BILLING_TYPE_SUBSCRIPTION = 'subs'

def __init__(self, callback):
super(BillingService, self).__init__()
super().__init__()
self.callback = callback
self.purchased_items = None
android_billing_service_start()
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/android/src/android/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class NewIntentListener(PythonJavaClass):
__javacontext__ = 'app'

def __init__(self, callback, **kwargs):
super(NewIntentListener, self).__init__(**kwargs)
super().__init__(**kwargs)
self.callback = callback

@java_method('(Landroid/content/Intent;)V')
Expand All @@ -27,7 +27,7 @@ class ActivityResultListener(PythonJavaClass):
__javacontext__ = 'app'

def __init__(self, callback):
super(ActivityResultListener, self).__init__()
super().__init__()
self.callback = callback

@java_method('(IILandroid/content/Intent;)V')
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/android/src/android/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def onReceive(self, context, intent):
self.callback(context, intent)

def __init__(self, callback, actions=None, categories=None):
super(BroadcastReceiver, self).__init__()
super().__init__()
self.callback = callback

if not actions and not categories:
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/android/src/android/runnable.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Runnable(PythonJavaClass):
__runnables__ = []

def __init__(self, func):
super(Runnable, self).__init__()
super().__init__()
self.func = func

def __call__(self, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/apsw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def build_arch(self, arch):
'build_ext',
'--enable=fts4', _env=env)
# Install python bindings
super(ApswRecipe, self).build_arch(arch)
super().build_arch(arch)

def get_recipe_env(self, arch):
env = super(ApswRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
sqlite_recipe = self.get_recipe('sqlite3', self.ctx)
env['CFLAGS'] += ' -I' + sqlite_recipe.get_build_dir(arch.arch)
env['LDFLAGS'] += ' -L' + sqlite_recipe.get_lib_dir(arch)
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/audiostream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AudiostreamRecipe(CythonRecipe):
depends = ['python3', 'sdl2', 'pyjnius']

def get_recipe_env(self, arch):
env = super(AudiostreamRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
sdl_include = 'SDL2'
sdl_mixer_include = 'SDL2_mixer'
env['USE_SDL2'] = 'True'
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/bcrypt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class BCryptRecipe(CompiledComponentsPythonRecipe):
call_hostpython_via_targetpython = False

def get_recipe_env(self, arch):
env = super(BCryptRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)

openssl_recipe = Recipe.get_recipe('openssl', self.ctx)
env['CFLAGS'] += openssl_recipe.include_flags(arch)
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/boost/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def should_build(self, arch):
return not exists(join(self.get_build_dir(arch.arch), 'b2'))

def prebuild_arch(self, arch):
super(BoostRecipe, self).prebuild_arch(arch)
super().prebuild_arch(arch)
env = self.get_recipe_env(arch)
with current_directory(self.get_build_dir(arch.arch)):
# Set custom configuration
Expand All @@ -70,7 +70,7 @@ def prebuild_arch(self, arch):
)

def build_arch(self, arch):
super(BoostRecipe, self).build_arch(arch)
super().build_arch(arch)
env = self.get_recipe_env(arch)
env['PYTHON_HOST'] = self.ctx.hostpython
with current_directory(self.get_build_dir(arch.arch)):
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/cdecimal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CdecimalRecipe(CompiledComponentsPythonRecipe):
'cross-compile.patch']

def prebuild_arch(self, arch):
super(CdecimalRecipe, self).prebuild_arch(arch)
super().prebuild_arch(arch)
if not is_darwin():
if '64' in arch.arch:
machine = 'ansi64'
Expand Down
4 changes: 2 additions & 2 deletions pythonforandroid/recipes/cffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class CffiRecipe(CompiledComponentsPythonRecipe):

def get_hostrecipe_env(self, arch=None):
# fixes missing ffi.h on some host systems (e.g. gentoo)
env = super(CffiRecipe, self).get_hostrecipe_env(arch)
env = super().get_hostrecipe_env(arch)
libffi = self.get_recipe('libffi', self.ctx)
includes = libffi.get_include_dirs(arch)
env['FFI_INC'] = ",".join(includes)
return env

def get_recipe_env(self, arch=None):
env = super(CffiRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
libffi = self.get_recipe('libffi', self.ctx)
includes = libffi.get_include_dirs(arch)
env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes)
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/cryptography/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CryptographyRecipe(CompiledComponentsPythonRecipe):
call_hostpython_via_targetpython = False

def get_recipe_env(self, arch):
env = super(CryptographyRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)

openssl_recipe = Recipe.get_recipe('openssl', self.ctx)
env['CFLAGS'] += openssl_recipe.include_flags(arch)
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/enum34/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def should_build(self, arch):
# attribute `depends` because otherwise we will not be able to
# build the cryptography recipe.
return False
return super(Enum34Recipe, self).should_build(arch)
return super().should_build(arch)


recipe = Enum34Recipe()
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/evdev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EvdevRecipe(CompiledComponentsPythonRecipe):
'evdev-permissions.patch']

def get_recipe_env(self, arch=None):
env = super(EvdevRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
env['NDKPLATFORM'] = self.ctx.ndk_platform
return env

Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/ffmpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def prebuild_arch(self, arch):
self.apply_patches(arch)

def get_recipe_env(self, arch):
env = super(FFMpegRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
env['NDK'] = self.ctx.ndk_dir
return env

Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/ffpyplayer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class FFPyPlayerRecipe(CythonRecipe):
opt_depends = ['openssl', 'ffpyplayer_codecs']

def get_recipe_env(self, arch, with_flags_in_cc=True):
env = super(FFPyPlayerRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)

build_dir = Recipe.get_recipe('ffmpeg', self.ctx).get_build_dir(arch.arch)
env["FFMPEG_INCLUDE_DIR"] = join(build_dir, "include")
Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/freetype/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FreetypeRecipe(Recipe):
built_libraries = {'libfreetype.so': 'objs/.libs'}

def get_recipe_env(self, arch=None, with_harfbuzz=False):
env = super(FreetypeRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
if with_harfbuzz:
harfbuzz_build = self.get_recipe(
'harfbuzz', self.ctx
Expand Down
6 changes: 4 additions & 2 deletions pythonforandroid/recipes/genericndkbuild/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ def should_build(self, arch):
return True

def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True):
env = super(GenericNDKBuildRecipe, self).get_recipe_env(
arch=arch, with_flags_in_cc=with_flags_in_cc, with_python=with_python)
env = super().get_recipe_env(
arch=arch, with_flags_in_cc=with_flags_in_cc,
with_python=with_python,
)
env['APP_ALLOW_MISSING_DEPS'] = 'true'
return env

Expand Down
2 changes: 1 addition & 1 deletion pythonforandroid/recipes/harfbuzz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HarfbuzzRecipe(Recipe):
built_libraries = {'libharfbuzz.so': 'src/.libs'}

def get_recipe_env(self, arch=None):
env = super(HarfbuzzRecipe, self).get_recipe_env(arch)
env = super().get_recipe_env(arch)
if 'freetype' in self.ctx.recipe_build_order:
freetype = self.get_recipe('freetype', self.ctx)
freetype_install = join(
Expand Down
Loading