From b3d3d45702071fb2fb7d8e44fb5103987d20c4cf Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Tue, 22 May 2018 23:33:10 +0200 Subject: [PATCH] Fixes linter E203 E231 E261 E302 E303 E305 W291 W293 W391 Spacing related issues: - E203 whitespace before ',' - E231 missing whitespace after ',' - E261 at least two spaces before inline comment - E302 expected 2 blank lines - E303 too many blank lines - E305 expected 2 blank lines after class or function definition - W291 trailing whitespace - W293 blank line contains whitespace - W391 blank line at end of file --- pythonforandroid/bdistapk.py | 6 ++--- pythonforandroid/bootstraps/empty/__init__.py | 1 + .../bootstraps/pygame/__init__.py | 4 +-- .../bootstraps/pygame/build/build.py | 1 + .../pygame/build/buildlib/argparse.py | 6 ++++- .../bootstraps/sdl2/build/build.py | 6 ++--- .../bootstraps/service_only/__init__.py | 1 - .../bootstraps/service_only/build/build.py | 6 ++--- .../bootstraps/webview/__init__.py | 5 ++-- .../bootstraps/webview/build/build.py | 8 +++--- pythonforandroid/build.py | 2 +- pythonforandroid/distribution.py | 2 +- pythonforandroid/logger.py | 2 ++ pythonforandroid/patching.py | 2 +- pythonforandroid/recipe.py | 9 +++---- .../recipes/android/src/android/activity.py | 3 ++- .../recipes/android/src/android/billing.py | 1 - .../recipes/android/src/android/broadcast.py | 3 +-- .../recipes/android/src/android/mixer.py | 25 ++++++++++++++----- .../recipes/android/src/android/runnable.py | 1 + pythonforandroid/recipes/apsw/__init__.py | 4 +-- pythonforandroid/recipes/atom/__init__.py | 6 +++-- .../recipes/audiostream/__init__.py | 1 - pythonforandroid/recipes/boost/__init__.py | 4 ++- .../recipes/brokenrecipe/__init__.py | 1 + pythonforandroid/recipes/cherrypy/__init__.py | 2 ++ .../recipes/cryptography/__init__.py | 2 ++ .../recipes/decorator/__init__.py | 2 ++ pythonforandroid/recipes/enaml/__init__.py | 6 +++-- pythonforandroid/recipes/enum34/__init__.py | 2 ++ .../recipes/feedparser/__init__.py | 2 ++ pythonforandroid/recipes/ffmpeg/__init__.py | 13 +++++----- .../recipes/ffpyplayer/__init__.py | 1 + .../recipes/ffpyplayer_codecs/__init__.py | 1 + pythonforandroid/recipes/freetype/__init__.py | 1 + .../recipes/gevent-websocket/__init__.py | 1 + pythonforandroid/recipes/greenlet/__init__.py | 1 + pythonforandroid/recipes/harfbuzz/__init__.py | 1 + .../recipes/hostpython2/__init__.py | 2 +- pythonforandroid/recipes/ifaddrs/__init__.py | 1 + .../recipes/kivent_core/__init__.py | 4 +-- pythonforandroid/recipes/kivy/__init__.py | 1 + .../recipes/kiwisolver/__init__.py | 4 ++- pythonforandroid/recipes/leveldb/__init__.py | 2 ++ pythonforandroid/recipes/libcurl/__init__.py | 1 + pythonforandroid/recipes/libexpat/__init__.py | 2 +- pythonforandroid/recipes/libgeos/__init__.py | 17 +++++++------ pythonforandroid/recipes/libglob/__init__.py | 5 ++-- .../recipes/libmysqlclient/__init__.py | 8 +++--- pythonforandroid/recipes/libnacl/__init__.py | 2 ++ pythonforandroid/recipes/libpq/__init__.py | 1 + pythonforandroid/recipes/libshine/__init__.py | 1 + .../recipes/libsodium/__init__.py | 2 ++ .../recipes/libtorrent/__init__.py | 6 +++-- .../recipes/libtribler/__init__.py | 4 ++- pythonforandroid/recipes/libx264/__init__.py | 1 + pythonforandroid/recipes/libzmq/__init__.py | 2 +- pythonforandroid/recipes/m2crypto/__init__.py | 4 +-- .../recipes/msgpack-python/__init__.py | 1 + pythonforandroid/recipes/numpy/__init__.py | 6 ++--- pythonforandroid/recipes/opencv/__init__.py | 19 +++++++------- pythonforandroid/recipes/openssl/__init__.py | 1 + pythonforandroid/recipes/png/__init__.py | 1 - pythonforandroid/recipes/preppy/__init__.py | 3 +++ .../recipes/protobuf_cpp/__init__.py | 5 +--- pythonforandroid/recipes/psycopg2/__init__.py | 1 + pythonforandroid/recipes/pyaml/__init__.py | 1 + pythonforandroid/recipes/pyasn1/__init__.py | 1 + pythonforandroid/recipes/pycrypto/__init__.py | 1 + pythonforandroid/recipes/pygame/__init__.py | 6 ++--- .../pygame_bootstrap_components/__init__.py | 2 +- .../recipes/pyleveldb/__init__.py | 3 ++- pythonforandroid/recipes/pymunk/__init__.py | 1 + pythonforandroid/recipes/pyproj/__init__.py | 2 +- pythonforandroid/recipes/pyrxp/__init__.py | 1 + pythonforandroid/recipes/pysdl2/__init__.py | 1 + pythonforandroid/recipes/python2/__init__.py | 10 ++------ .../recipes/python2/patches/_scproxy.py | 2 ++ .../recipes/python3crystax/__init__.py | 4 ++- pythonforandroid/recipes/pyusb/__init__.py | 2 +- pythonforandroid/recipes/pyyaml/__init__.py | 1 + pythonforandroid/recipes/pyzmq/__init__.py | 1 + .../recipes/reportlab/__init__.py | 21 ++++++++-------- pythonforandroid/recipes/requests/__init__.py | 2 ++ pythonforandroid/recipes/sdl/__init__.py | 4 +-- pythonforandroid/recipes/sdl2/__init__.py | 1 - .../recipes/sdl2_image/__init__.py | 1 + .../recipes/sdl2_mixer/__init__.py | 1 + pythonforandroid/recipes/sdl2_ttf/__init__.py | 1 + pythonforandroid/recipes/shapely/__init__.py | 18 ++++++------- .../recipes/simple-crypt/__init__.py | 1 + pythonforandroid/recipes/six/__init__.py | 1 + pythonforandroid/recipes/snappy/__init__.py | 2 ++ .../recipes/sqlalchemy/__init__.py | 4 +-- pythonforandroid/recipes/sqlite3/__init__.py | 1 + pythonforandroid/recipes/twisted/__init__.py | 1 + pythonforandroid/recipes/ujson/__init__.py | 3 ++- pythonforandroid/recipes/vlc/__init__.py | 4 ++- .../recipes/websocket-client/__init__.py | 1 + pythonforandroid/recipes/wsaccel/__init__.py | 1 + pythonforandroid/recipes/zope/__init__.py | 4 ++- pythonforandroid/toolchain.py | 6 +++-- pythonforandroid/util.py | 1 + tox.ini | 6 ++--- 104 files changed, 232 insertions(+), 144 deletions(-) diff --git a/pythonforandroid/bdistapk.py b/pythonforandroid/bdistapk.py index 74c0e618e8..04e09d5391 100644 --- a/pythonforandroid/bdistapk.py +++ b/pythonforandroid/bdistapk.py @@ -33,7 +33,6 @@ def initialize_options(self): for (option, (source, value)) in option_dict.items(): setattr(self, option, str(value)) - def finalize_options(self): setup_options = self.distribution.get_option_dict('apk') @@ -133,7 +132,7 @@ def prepare_build_dir(self): def _set_user_options(): # This seems like a silly way to do things, but not sure if there's a # better way to pass arbitrary options onwards to p4a - user_options = [('requirements=', None, None),] + user_options = [('requirements=', None, None), ] for i, arg in enumerate(sys.argv): if arg.startswith('--'): if ('=' in arg or @@ -144,4 +143,5 @@ def _set_user_options(): BdistAPK.user_options = user_options -_set_user_options() \ No newline at end of file + +_set_user_options() diff --git a/pythonforandroid/bootstraps/empty/__init__.py b/pythonforandroid/bootstraps/empty/__init__.py index 3b568200e4..576f512af6 100644 --- a/pythonforandroid/bootstraps/empty/__init__.py +++ b/pythonforandroid/bootstraps/empty/__init__.py @@ -12,4 +12,5 @@ def run_distribute(self): print('empty bootstrap has no distribute') exit(1) + bootstrap = EmptyBootstrap() diff --git a/pythonforandroid/bootstraps/pygame/__init__.py b/pythonforandroid/bootstraps/pygame/__init__.py index e5d5f4a8c9..74197bd949 100644 --- a/pythonforandroid/bootstraps/pygame/__init__.py +++ b/pythonforandroid/bootstraps/pygame/__init__.py @@ -64,7 +64,7 @@ def run_distribute(self): shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7')) shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/') - shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/')) + shprint(sh.cp, join('python-install', 'include', 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/')) info('Removing some unwanted files') shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so')) @@ -91,8 +91,8 @@ def run_distribute(self): shprint(sh.rm, '-rf', 'lib-dynload/_ctypes_test.so') shprint(sh.rm, '-rf', 'lib-dynload/_testcapi.so') - self.strip_libraries(arch) super(PygameBootstrap, self).run_distribute() + bootstrap = PygameBootstrap() diff --git a/pythonforandroid/bootstraps/pygame/build/build.py b/pythonforandroid/bootstraps/pygame/build/build.py index d9f2dfddfc..6991adebfe 100755 --- a/pythonforandroid/bootstraps/pygame/build/build.py +++ b/pythonforandroid/bootstraps/pygame/build/build.py @@ -370,6 +370,7 @@ def make_package(args): print('Did you install ant on your system ?') sys.exit(-1) + def parse_args(args=None): import argparse diff --git a/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py b/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py index 33d10dd297..ef6296c384 100644 --- a/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py +++ b/pythonforandroid/bootstraps/pygame/build/buildlib/argparse.py @@ -95,9 +95,11 @@ import sys as _sys import textwrap as _textwrap + def _(s): return s + try: _set = set except NameError: @@ -123,6 +125,7 @@ def _sorted(iterable, reverse=False): def _callable(obj): return hasattr(obj, '__call__') or hasattr(obj, '__bases__') + # silence Python 2.6 buggy warnings about Exception.message if _sys.version_info[:2] == (2, 6): import warnings @@ -145,6 +148,7 @@ def _callable(obj): # Utility functions and classes # ============================= + class _AttributeHolder(object): """Abstract base class that provides __repr__. @@ -1165,6 +1169,7 @@ def __repr__(self): # Optional and Positional Parsing # =========================== + class Namespace(_AttributeHolder): """Simple object for storing attributes. @@ -1265,7 +1270,6 @@ def get_default(self, dest): return action.default return self._defaults.get(dest, None) - # ======================= # Adding argument actions # ======================= diff --git a/pythonforandroid/bootstraps/sdl2/build/build.py b/pythonforandroid/bootstraps/sdl2/build/build.py index e78a753450..69d9eac1ff 100755 --- a/pythonforandroid/bootstraps/sdl2/build/build.py +++ b/pythonforandroid/bootstraps/sdl2/build/build.py @@ -296,7 +296,7 @@ def make_package(args): if args.intent_filters: with open(args.intent_filters) as fd: args.intent_filters = fd.read() - + args.add_activity = args.add_activity or [] args.activity_launch_mode = args.activity_launch_mode or '' @@ -355,7 +355,6 @@ def make_package(args): key=LooseVersion) build_tools_version = build_tools_versions[-1] - render( 'AndroidManifest.tmpl.xml', 'src/main/AndroidManifest.xml', @@ -371,7 +370,6 @@ def make_package(args): remove('AndroidManifest.xml') shutil.copy(join('src', 'main', 'AndroidManifest.xml'), 'AndroidManifest.xml') - render( 'strings.tmpl.xml', @@ -402,13 +400,13 @@ def make_package(args): 'custom_rules.xml', args=args) - if args.sign: render('build.properties', 'build.properties') else: if exists('build.properties'): os.remove('build.properties') + def parse_args(args=None): global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON default_android_api = 12 diff --git a/pythonforandroid/bootstraps/service_only/__init__.py b/pythonforandroid/bootstraps/service_only/__init__.py index b9d0aa0ecc..088928c6c4 100644 --- a/pythonforandroid/bootstraps/service_only/__init__.py +++ b/pythonforandroid/bootstraps/service_only/__init__.py @@ -114,7 +114,6 @@ def run_distribute(self): site_packages_dir = join(abspath(curdir), site_packages_dir) - self.strip_libraries(arch) self.fry_eggs(site_packages_dir) super(ServiceOnlyBootstrap, self).run_distribute() diff --git a/pythonforandroid/bootstraps/service_only/build/build.py b/pythonforandroid/bootstraps/service_only/build/build.py index ac7c4611e3..eef8ca47dd 100755 --- a/pythonforandroid/bootstraps/service_only/build/build.py +++ b/pythonforandroid/bootstraps/service_only/build/build.py @@ -53,6 +53,7 @@ environment = jinja2.Environment(loader=jinja2.FileSystemLoader( join(curdir, 'templates'))) + def render(template, dest, **kwargs): '''Using jinja2, render `template` to the filename `dest`, supplying the @@ -104,6 +105,7 @@ def listfiles(d): for fn in listfiles(subdir): yield fn + def make_python_zip(): ''' Search for all the python related files, and construct the pythonXX.zip @@ -120,7 +122,6 @@ def make_python_zip(): global python_files d = realpath(join('private', 'lib', 'python2.7')) - def select(fn): if is_blacklist(fn): return False @@ -147,6 +148,7 @@ def select(fn): zf.write(fn, afn) zf.close() + def make_tar(tfn, source_dirs, ignore_path=[]): ''' Make a zip file `fn` from the contents of source_dis. @@ -242,7 +244,6 @@ def make_package(args): # if args.dir: # make_tar('assets/public.mp3', [args.dir], args.ignore_path) - # # Build. # try: # for arg in args.command: @@ -252,7 +253,6 @@ def make_package(args): # print 'Did you install ant on your system ?' # sys.exit(-1) - # Prepare some variables for templating process # default_icon = 'templates/kivy-icon.png' diff --git a/pythonforandroid/bootstraps/webview/__init__.py b/pythonforandroid/bootstraps/webview/__init__.py index ba797d812f..041fe43c3e 100644 --- a/pythonforandroid/bootstraps/webview/__init__.py +++ b/pythonforandroid/bootstraps/webview/__init__.py @@ -4,6 +4,7 @@ import glob import sh + class WebViewBootstrap(Bootstrap): name = 'webview' @@ -59,7 +60,7 @@ def run_distribute(self): if exists(join('libs', arch.arch, 'libpymodules.so')): shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/') - shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/')) + shprint(sh.cp, join('python-install', 'include', 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/')) info('Removing some unwanted files') shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so')) @@ -110,9 +111,9 @@ def run_distribute(self): site_packages_dir = join(abspath(curdir), site_packages_dir) - self.strip_libraries(arch) self.fry_eggs(site_packages_dir) super(WebViewBootstrap, self).run_distribute() + bootstrap = WebViewBootstrap() diff --git a/pythonforandroid/bootstraps/webview/build/build.py b/pythonforandroid/bootstraps/webview/build/build.py index fa6f92b017..28851aa8e5 100755 --- a/pythonforandroid/bootstraps/webview/build/build.py +++ b/pythonforandroid/bootstraps/webview/build/build.py @@ -38,7 +38,7 @@ # pyc/py '*.pyc', - # '*.py', + # '*.py', # temp files '~', @@ -54,6 +54,7 @@ environment = jinja2.Environment(loader=jinja2.FileSystemLoader( join(curdir, 'templates'))) + def render(template, dest, **kwargs): '''Using jinja2, render `template` to the filename `dest`, supplying the @@ -105,6 +106,7 @@ def listfiles(d): for fn in listfiles(subdir): yield fn + def make_python_zip(): ''' Search for all the python related files, and construct the pythonXX.zip @@ -121,7 +123,6 @@ def make_python_zip(): global python_files d = realpath(join('private', 'lib', 'python2.7')) - def select(fn): if is_blacklist(fn): return False @@ -148,6 +149,7 @@ def select(fn): zf.write(fn, afn) zf.close() + def make_tar(tfn, source_dirs, ignore_path=[]): ''' Make a zip file `fn` from the contents of source_dis. @@ -244,7 +246,6 @@ def make_package(args): # if args.dir: # make_tar('assets/public.mp3', [args.dir], args.ignore_path) - # # Build. # try: # for arg in args.command: @@ -254,7 +255,6 @@ def make_package(args): # print 'Did you install ant on your system ?' # sys.exit(-1) - # Prepare some variables for templating process default_icon = 'templates/kivy-icon.png' diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py index d04ddb0443..8cba4553d4 100644 --- a/pythonforandroid/build.py +++ b/pythonforandroid/build.py @@ -44,7 +44,7 @@ class Context(object): recipe_build_order = None # Will hold the list of all built recipes - symlink_java_src = False # If True, will symlink instead of copying during build + symlink_java_src = False # If True, will symlink instead of copying during build java_build_tool = 'auto' diff --git a/pythonforandroid/distribution.py b/pythonforandroid/distribution.py index 371e35e042..735b64a79f 100644 --- a/pythonforandroid/distribution.py +++ b/pythonforandroid/distribution.py @@ -41,7 +41,7 @@ def __repr__(self): return str(self) @classmethod - def get_distribution(cls, ctx, name=None, recipes=[], + def get_distribution(cls, ctx, name=None, recipes=[], force_build=False, extra_dist_dirs=[], require_perfect_match=False): diff --git a/pythonforandroid/logger.py b/pythonforandroid/logger.py index b05d137f57..38afba0e5f 100644 --- a/pythonforandroid/logger.py +++ b/pythonforandroid/logger.py @@ -42,6 +42,7 @@ def format(self, record): Err_Style.RESET_ALL) + record.msg return super(LevelDifferentiatingFormatter, self).format(record) + logger = logging.getLogger('p4a') if not hasattr(logger, 'touched'): # Necessary as importlib reloads # this, which would add a second @@ -71,6 +72,7 @@ def __getattr__(self, key): def enable(self, enable): self._enabled = enable + Out_Style = colorama_shim(Colo_Style) Out_Fore = colorama_shim(Colo_Fore) Err_Style = colorama_shim(Colo_Style) diff --git a/pythonforandroid/patching.py b/pythonforandroid/patching.py index 70d7e9c9cf..2a4773327d 100644 --- a/pythonforandroid/patching.py +++ b/pythonforandroid/patching.py @@ -18,6 +18,7 @@ def is_x(**kwargs): return uname()[0] == platform return is_x + is_linux = is_platform('Linux') is_darwin = is_platform('Darwin') @@ -68,4 +69,3 @@ def is_ndk(ndk): def is_x(recipe, **kwargs): return recipe.ctx.ndk == ndk return is_x - diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py index 26ea48756d..f1708e02ba 100644 --- a/pythonforandroid/recipe.py +++ b/pythonforandroid/recipe.py @@ -798,7 +798,6 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True): with current_directory(self.get_build_dir(arch.arch)): hostpython = sh.Command(self.hostpython_location) - if self.ctx.python_recipe.from_crystax: hpenv = env.copy() shprint(hostpython, 'setup.py', 'install', '-O2', @@ -880,6 +879,7 @@ def rebuild_compiled_components(self, arch, env): shprint(hostpython, 'setup.py', self.build_cmd, '-v', _env=env, *self.setup_extra_args) + class CppCompiledComponentsPythonRecipe(CompiledComponentsPythonRecipe): """ Extensions that require the cxx-stl """ call_hostpython_via_targetpython = False @@ -902,22 +902,19 @@ def get_recipe_env(self, arch): " -lpython2.7" \ " -lgnustl_shared".format(**keys) - return env - def build_compiled_components(self,arch): + def build_compiled_components(self, arch): super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch) # Copy libgnustl_shared.so with current_directory(self.get_build_dir(arch.arch)): sh.cp( - "{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx,arch=arch), + "{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx, arch=arch), self.ctx.get_libs_dir(arch.arch) ) - - class CythonRecipe(PythonRecipe): pre_build_ext = False cythonize = True diff --git a/pythonforandroid/recipes/android/src/android/activity.py b/pythonforandroid/recipes/android/src/android/activity.py index d1daa3c1c7..0bbaa804dd 100644 --- a/pythonforandroid/recipes/android/src/android/activity.py +++ b/pythonforandroid/recipes/android/src/android/activity.py @@ -7,6 +7,7 @@ 'on_new_intent': [], 'on_activity_result': [] } + class NewIntentListener(PythonJavaClass): __javainterfaces__ = [JNI_NAMESPACE + '/PythonActivity$NewIntentListener'] __javacontext__ = 'app' @@ -46,6 +47,7 @@ def bind(**kwargs): _activity.registerActivityResultListener(listener) _callbacks[event].append(listener) + def unbind(**kwargs): for event, callback in kwargs.items(): if event not in _callbacks: @@ -58,4 +60,3 @@ def unbind(**kwargs): _activity.unregisterNewIntentListener(listener) elif event == 'on_activity_result': _activity.unregisterActivityResultListener(listener) - diff --git a/pythonforandroid/recipes/android/src/android/billing.py b/pythonforandroid/recipes/android/src/android/billing.py index 58e04bcaf6..0ea10083c6 100644 --- a/pythonforandroid/recipes/android/src/android/billing.py +++ b/pythonforandroid/recipes/android/src/android/billing.py @@ -3,4 +3,3 @@ =================== ''' - diff --git a/pythonforandroid/recipes/android/src/android/broadcast.py b/pythonforandroid/recipes/android/src/android/broadcast.py index ba3dfc9765..85b8728ed7 100644 --- a/pythonforandroid/recipes/android/src/android/broadcast.py +++ b/pythonforandroid/recipes/android/src/android/broadcast.py @@ -28,7 +28,7 @@ def __init__(self, callback, actions=None, categories=None): def _expand_partial_name(partial_name): if '.' in partial_name: - return partial_name # Its actually a full dotted name + return partial_name # Its actually a full dotted name else: name = 'ACTION_{}'.format(partial_name.upper()) if not hasattr(Intent, name): @@ -76,4 +76,3 @@ def context(self): return PythonService.mService PythonActivity = autoclass(JAVA_NAMESPACE + '.PythonActivity') return PythonActivity.mActivity - diff --git a/pythonforandroid/recipes/android/src/android/mixer.py b/pythonforandroid/recipes/android/src/android/mixer.py index 3f85c6352e..af3a5aeb46 100644 --- a/pythonforandroid/recipes/android/src/android/mixer.py +++ b/pythonforandroid/recipes/android/src/android/mixer.py @@ -8,36 +8,45 @@ condition = threading.Condition() + def periodic(): for i in range(0, num_channels): if i in channels: channels[i].periodic() + num_channels = 8 reserved_channels = 0 + def init(frequency=22050, size=-16, channels=2, buffer=4096): return None + def pre_init(frequency=22050, size=-16, channels=2, buffersize=4096): return None + def quit(): stop() return None + def stop(): for i in range(0, num_channels): sound.stop(i) + def pause(): for i in range(0, num_channels): sound.pause(i) + def unpause(): for i in range(0, num_channels): sound.unpause(i) + def get_busy(): for i in range(0, num_channels): if sound.busy(i): @@ -45,6 +54,7 @@ def get_busy(): return False + def fadeout(time): # Fadeout doesn't work - it just immediately stops playback. stop() @@ -53,17 +63,21 @@ def fadeout(time): # A map from channel number to Channel object. channels = { } + def set_num_channels(count): global num_channels num_channels = count + def get_num_channels(count): return num_channels + def set_reserved(count): global reserved_channels reserved_channels = count + def find_channel(force=False): busy = [ ] @@ -79,10 +93,11 @@ def find_channel(force=False): if not force: return None - busy.sort(key=lambda x : x.play_time) + busy.sort(key=lambda x: x.play_time) return busy[0] + class ChannelImpl(object): def __init__(self, id): @@ -101,7 +116,6 @@ def periodic(self): if self.loop is not None and sound.queue_depth(self.id) < 2: self.queue(self.loop, loops=1) - def play(self, s, loops=0, maxtime=0, fade_ms=0): if loops: self.loop = s @@ -183,6 +197,7 @@ def Channel(n): sound_serial = 0 sounds = { } + class Sound(object): def __init__(self, what): @@ -214,7 +229,6 @@ def play(self, loops=0, maxtime=0, fade_ms=0): channel.play(self, loops=loops) return channel - def stop(self): for i in range(0, num_channels): if Channel(i).get_sound() is self: @@ -244,9 +258,11 @@ def get_num_channels(self): def get_length(self): return 1.0 + music_channel = Channel(256) music_sound = None + class music(object): @staticmethod @@ -306,6 +322,3 @@ def get_pos(): @staticmethod def queue(filename): return music_channel.queue(Sound(filename)) - - - diff --git a/pythonforandroid/recipes/android/src/android/runnable.py b/pythonforandroid/recipes/android/src/android/runnable.py index 564d83b036..12c86a1ba6 100644 --- a/pythonforandroid/recipes/android/src/android/runnable.py +++ b/pythonforandroid/recipes/android/src/android/runnable.py @@ -39,6 +39,7 @@ def run(self): Runnable.__runnables__.remove(self) + def run_on_ui_thread(f): '''Decorator to create automatically a :class:`Runnable` object with the function. The function will be delayed and call into the Activity thread. diff --git a/pythonforandroid/recipes/apsw/__init__.py b/pythonforandroid/recipes/apsw/__init__.py index d1c60534c7..68e745961e 100644 --- a/pythonforandroid/recipes/apsw/__init__.py +++ b/pythonforandroid/recipes/apsw/__init__.py @@ -18,8 +18,7 @@ def build_arch(self, arch): shprint(hostpython, 'setup.py', 'build_ext', - '--enable=fts4' - , _env=env) + '--enable=fts4', _env=env) # Install python bindings super(ApswRecipe, self).build_arch(arch) @@ -35,4 +34,5 @@ def get_recipe_env(self, arch): ' -lsqlite3' return env + recipe = ApswRecipe() diff --git a/pythonforandroid/recipes/atom/__init__.py b/pythonforandroid/recipes/atom/__init__.py index 57d363bec8..854911372e 100644 --- a/pythonforandroid/recipes/atom/__init__.py +++ b/pythonforandroid/recipes/atom/__init__.py @@ -1,9 +1,11 @@ from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe + class AtomRecipe(CppCompiledComponentsPythonRecipe): site_packages_name = 'atom' version = '0.3.10' url = 'https://github.com/nucleic/atom/archive/master.zip' - depends = ['python2','setuptools'] - + depends = ['python2', 'setuptools'] + + recipe = AtomRecipe() diff --git a/pythonforandroid/recipes/audiostream/__init__.py b/pythonforandroid/recipes/audiostream/__init__.py index 7dd04ee55a..161d8505df 100644 --- a/pythonforandroid/recipes/audiostream/__init__.py +++ b/pythonforandroid/recipes/audiostream/__init__.py @@ -25,7 +25,6 @@ def get_recipe_env(self, arch): sdl_include = sdl_include, sdl_mixer_include = sdl_mixer_include) return env - recipe = AudiostreamRecipe() diff --git a/pythonforandroid/recipes/boost/__init__.py b/pythonforandroid/recipes/boost/__init__.py index 26afc2a070..89109c3f7d 100644 --- a/pythonforandroid/recipes/boost/__init__.py +++ b/pythonforandroid/recipes/boost/__init__.py @@ -6,6 +6,8 @@ This recipe creates a custom toolchain and bootstraps Boost from source to build Boost.Build including python bindings """ + + class BoostRecipe(Recipe): version = '1.60.0' # Don't forget to change the URL when changing the version @@ -64,4 +66,4 @@ def get_recipe_env(self, arch): return env -recipe = BoostRecipe() \ No newline at end of file +recipe = BoostRecipe() diff --git a/pythonforandroid/recipes/brokenrecipe/__init__.py b/pythonforandroid/recipes/brokenrecipe/__init__.py index b617074b3e..48e266b3a0 100644 --- a/pythonforandroid/recipes/brokenrecipe/__init__.py +++ b/pythonforandroid/recipes/brokenrecipe/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.toolchain import Recipe + class BrokenRecipe(Recipe): def __init__(self): print('This is a broken recipe, not a real one!') diff --git a/pythonforandroid/recipes/cherrypy/__init__.py b/pythonforandroid/recipes/cherrypy/__init__.py index 6740ebf8cf..f4567b2e1c 100644 --- a/pythonforandroid/recipes/cherrypy/__init__.py +++ b/pythonforandroid/recipes/cherrypy/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + class CherryPyRecipe(PythonRecipe): version = '5.1.0' url = 'https://bitbucket.org/cherrypy/cherrypy/get/{version}.tar.gz' @@ -7,4 +8,5 @@ class CherryPyRecipe(PythonRecipe): site_packages_name = 'cherrypy' call_hostpython_via_targetpython = False + recipe = CherryPyRecipe() diff --git a/pythonforandroid/recipes/cryptography/__init__.py b/pythonforandroid/recipes/cryptography/__init__.py index 5ef75156d5..3c4deef401 100644 --- a/pythonforandroid/recipes/cryptography/__init__.py +++ b/pythonforandroid/recipes/cryptography/__init__.py @@ -1,6 +1,7 @@ from pythonforandroid.recipe import CompiledComponentsPythonRecipe from os.path import join + class CryptographyRecipe(CompiledComponentsPythonRecipe): name = 'cryptography' version = '1.3' @@ -24,4 +25,5 @@ def get_recipe_env(self, arch): ' -lcrypto' + r.version return env + recipe = CryptographyRecipe() diff --git a/pythonforandroid/recipes/decorator/__init__.py b/pythonforandroid/recipes/decorator/__init__.py index 68a69ed536..56b0074e08 100644 --- a/pythonforandroid/recipes/decorator/__init__.py +++ b/pythonforandroid/recipes/decorator/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + class DecoratorPyRecipe(PythonRecipe): version = '4.0.9' url = 'https://pypi.python.org/packages/source/d/decorator/decorator-{version}.tar.gz' @@ -7,4 +8,5 @@ class DecoratorPyRecipe(PythonRecipe): site_packages_name = 'decorator' call_hostpython_via_targetpython = False + recipe = DecoratorPyRecipe() diff --git a/pythonforandroid/recipes/enaml/__init__.py b/pythonforandroid/recipes/enaml/__init__.py index 89c070081e..81738e73aa 100644 --- a/pythonforandroid/recipes/enaml/__init__.py +++ b/pythonforandroid/recipes/enaml/__init__.py @@ -1,10 +1,12 @@ from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe + class EnamlRecipe(CppCompiledComponentsPythonRecipe): site_packages_name = 'enaml' version = '0.9.8' url = 'https://github.com/nucleic/enaml/archive/master.zip' - patches = ['0001-Update-setup.py.patch'] # Remove PyQt dependency - depends = ['python2','setuptools','atom','kiwisolver'] + patches = ['0001-Update-setup.py.patch'] # Remove PyQt dependency + depends = ['python2', 'setuptools', 'atom', 'kiwisolver'] + recipe = EnamlRecipe() diff --git a/pythonforandroid/recipes/enum34/__init__.py b/pythonforandroid/recipes/enum34/__init__.py index 342d3716fb..3e10070174 100644 --- a/pythonforandroid/recipes/enum34/__init__.py +++ b/pythonforandroid/recipes/enum34/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + class Enum34Recipe(PythonRecipe): version = '1.1.3' url = 'https://pypi.python.org/packages/source/e/enum34/enum34-{version}.tar.gz' @@ -7,4 +8,5 @@ class Enum34Recipe(PythonRecipe): site_packages_name = 'enum' call_hostpython_via_targetpython = False + recipe = Enum34Recipe() diff --git a/pythonforandroid/recipes/feedparser/__init__.py b/pythonforandroid/recipes/feedparser/__init__.py index f1d5601e4a..d46b36544e 100644 --- a/pythonforandroid/recipes/feedparser/__init__.py +++ b/pythonforandroid/recipes/feedparser/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + class FeedparserPyRecipe(PythonRecipe): version = '5.2.1' url = 'https://github.com/kurtmckee/feedparser/archive/{version}.tar.gz' @@ -7,4 +8,5 @@ class FeedparserPyRecipe(PythonRecipe): site_packages_name = 'feedparser' call_hostpython_via_targetpython = False + recipe = FeedparserPyRecipe() diff --git a/pythonforandroid/recipes/ffmpeg/__init__.py b/pythonforandroid/recipes/ffmpeg/__init__.py index 65d2d4b227..4d229a0a8a 100644 --- a/pythonforandroid/recipes/ffmpeg/__init__.py +++ b/pythonforandroid/recipes/ffmpeg/__init__.py @@ -32,7 +32,7 @@ def build_arch(self, arch): if 'openssl' in self.ctx.recipe_build_order: flags += [ - '--enable-openssl', + '--enable-openssl', '--enable-nonfree', '--enable-protocol=https,tls_openssl', ] @@ -40,7 +40,7 @@ def build_arch(self, arch): cflags += ['-I' + build_dir + '/include/'] ldflags += ['-L' + build_dir] - if 'ffpyplayer_codecs' in self.ctx.recipe_build_order: + if 'ffpyplayer_codecs' in self.ctx.recipe_build_order: # libx264 flags += ['--enable-libx264'] build_dir = Recipe.get_recipe('libx264', self.ctx).get_build_dir(arch.arch) @@ -99,16 +99,16 @@ def build_arch(self, arch): # android: flags += [ - '--target-os=android', - '--cross-prefix=arm-linux-androideabi-', + '--target-os=android', + '--cross-prefix=arm-linux-androideabi-', '--arch=arm', '--sysroot=' + self.ctx.ndk_platform, '--enable-neon', '--prefix={}'.format(realpath('.')), ] cflags += [ - '-mfpu=vfpv3-d16', - '-mfloat-abi=softfp', + '-mfpu=vfpv3-d16', + '-mfloat-abi=softfp', '-fPIC', ] @@ -122,4 +122,5 @@ def build_arch(self, arch): # copy libs: sh.cp('-a', sh.glob('./lib/lib*.so'), self.ctx.get_libs_dir(arch.arch)) + recipe = FFMpegRecipe() diff --git a/pythonforandroid/recipes/ffpyplayer/__init__.py b/pythonforandroid/recipes/ffpyplayer/__init__.py index 480d88c975..f8a1137072 100644 --- a/pythonforandroid/recipes/ffpyplayer/__init__.py +++ b/pythonforandroid/recipes/ffpyplayer/__init__.py @@ -24,4 +24,5 @@ def get_recipe_env(self, arch, with_flags_in_cc=True): return env + recipe = FFPyPlayerRecipe() diff --git a/pythonforandroid/recipes/ffpyplayer_codecs/__init__.py b/pythonforandroid/recipes/ffpyplayer_codecs/__init__.py index ee70a43f69..b32419470d 100644 --- a/pythonforandroid/recipes/ffpyplayer_codecs/__init__.py +++ b/pythonforandroid/recipes/ffpyplayer_codecs/__init__.py @@ -7,4 +7,5 @@ class FFPyPlayerCodecsRecipe(Recipe): def build_arch(self, arch): pass + recipe = FFPyPlayerCodecsRecipe() diff --git a/pythonforandroid/recipes/freetype/__init__.py b/pythonforandroid/recipes/freetype/__init__.py index 15cd9a9a6f..2c10c1a630 100644 --- a/pythonforandroid/recipes/freetype/__init__.py +++ b/pythonforandroid/recipes/freetype/__init__.py @@ -3,6 +3,7 @@ from os.path import exists, join, realpath import sh + class FreetypeRecipe(Recipe): version = '2.5.5' diff --git a/pythonforandroid/recipes/gevent-websocket/__init__.py b/pythonforandroid/recipes/gevent-websocket/__init__.py index a4908aaa4b..8820a10b3b 100644 --- a/pythonforandroid/recipes/gevent-websocket/__init__.py +++ b/pythonforandroid/recipes/gevent-websocket/__init__.py @@ -8,4 +8,5 @@ class GeventWebsocketRecipe(PythonRecipe): site_packages_name = 'geventwebsocket' call_hostpython_via_targetpython = False + recipe = GeventWebsocketRecipe() diff --git a/pythonforandroid/recipes/greenlet/__init__.py b/pythonforandroid/recipes/greenlet/__init__.py index 2cec56324f..80564cd284 100644 --- a/pythonforandroid/recipes/greenlet/__init__.py +++ b/pythonforandroid/recipes/greenlet/__init__.py @@ -6,4 +6,5 @@ class GreenletRecipe(PythonRecipe): url = 'https://pypi.python.org/packages/source/g/greenlet/greenlet-{version}.tar.gz' depends = [('python2', 'python3crystax')] + recipe = GreenletRecipe() diff --git a/pythonforandroid/recipes/harfbuzz/__init__.py b/pythonforandroid/recipes/harfbuzz/__init__.py index 540b721079..7b4e35611d 100644 --- a/pythonforandroid/recipes/harfbuzz/__init__.py +++ b/pythonforandroid/recipes/harfbuzz/__init__.py @@ -28,4 +28,5 @@ def build_arch(self, arch): shprint(sh.cp, '-L', join('src', '.libs', 'libharfbuzz.so'), self.ctx.libs_dir) + recipe = HarfbuzzRecipe() diff --git a/pythonforandroid/recipes/hostpython2/__init__.py b/pythonforandroid/recipes/hostpython2/__init__.py index 3cda47c61c..cd617a6b10 100644 --- a/pythonforandroid/recipes/hostpython2/__init__.py +++ b/pythonforandroid/recipes/hostpython2/__init__.py @@ -35,7 +35,7 @@ def build_arch(self, arch): self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen') return - + if 'LIBS' in os.environ: os.environ.pop('LIBS') configure = sh.Command('./configure') diff --git a/pythonforandroid/recipes/ifaddrs/__init__.py b/pythonforandroid/recipes/ifaddrs/__init__.py index 161153d2d7..481935b5f7 100644 --- a/pythonforandroid/recipes/ifaddrs/__init__.py +++ b/pythonforandroid/recipes/ifaddrs/__init__.py @@ -65,4 +65,5 @@ def build_arch(self, arch): include_path = join(self.ctx.python_recipe.get_build_dir(arch.arch), 'Include') shprint(sh.cp, "ifaddrs.h", include_path) + recipe = IFAddrRecipe() diff --git a/pythonforandroid/recipes/kivent_core/__init__.py b/pythonforandroid/recipes/kivent_core/__init__.py index 7e70f68b20..f04152a6db 100644 --- a/pythonforandroid/recipes/kivent_core/__init__.py +++ b/pythonforandroid/recipes/kivent_core/__init__.py @@ -8,7 +8,7 @@ class KiventCoreRecipe(CythonRecipe): name = 'kivent_core' depends = ['kivy'] - + subbuilddir = False def get_recipe_env(self, arch, with_flags_in_cc=True): @@ -24,7 +24,7 @@ def get_build_dir(self, arch, sub=False): return join(builddir, 'modules', 'core') else: return builddir - + def build_arch(self, arch): self.subbuilddir = True super(KiventCoreRecipe, self).build_arch(arch) diff --git a/pythonforandroid/recipes/kivy/__init__.py b/pythonforandroid/recipes/kivy/__init__.py index 0b5e212e0f..731d61cae5 100644 --- a/pythonforandroid/recipes/kivy/__init__.py +++ b/pythonforandroid/recipes/kivy/__init__.py @@ -52,4 +52,5 @@ def get_recipe_env(self, arch): return env + recipe = KivyRecipe() diff --git a/pythonforandroid/recipes/kiwisolver/__init__.py b/pythonforandroid/recipes/kiwisolver/__init__.py index d7b5e2753f..052f88e1bb 100644 --- a/pythonforandroid/recipes/kiwisolver/__init__.py +++ b/pythonforandroid/recipes/kiwisolver/__init__.py @@ -1,9 +1,11 @@ from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe + class KiwiSolverRecipe(CppCompiledComponentsPythonRecipe): site_packages_name = 'kiwisolver' version = '0.1.3' url = 'https://github.com/nucleic/kiwi/archive/master.zip' depends = ['python2', 'setuptools'] - + + recipe = KiwiSolverRecipe() diff --git a/pythonforandroid/recipes/leveldb/__init__.py b/pythonforandroid/recipes/leveldb/__init__.py index a5b69f74b9..e7ebe71606 100644 --- a/pythonforandroid/recipes/leveldb/__init__.py +++ b/pythonforandroid/recipes/leveldb/__init__.py @@ -2,6 +2,7 @@ from os.path import join import sh + class LevelDBRecipe(Recipe): version = '1.18' url = 'https://github.com/google/leveldb/archive/v{version}.tar.gz' @@ -42,4 +43,5 @@ def get_recipe_env(self, arch): ' -lgnustl_shared' return env + recipe = LevelDBRecipe() diff --git a/pythonforandroid/recipes/libcurl/__init__.py b/pythonforandroid/recipes/libcurl/__init__.py index 3fa389350c..e8cc86042d 100644 --- a/pythonforandroid/recipes/libcurl/__init__.py +++ b/pythonforandroid/recipes/libcurl/__init__.py @@ -36,4 +36,5 @@ def build_arch(self, arch): self.ctx.get_libs_dir(arch.arch), 'libcurl.so')) + recipe = LibcurlRecipe() diff --git a/pythonforandroid/recipes/libexpat/__init__.py b/pythonforandroid/recipes/libexpat/__init__.py index f0e03acb71..ecf5265db3 100644 --- a/pythonforandroid/recipes/libexpat/__init__.py +++ b/pythonforandroid/recipes/libexpat/__init__.py @@ -1,4 +1,4 @@ - + import sh from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory from os.path import exists, join diff --git a/pythonforandroid/recipes/libgeos/__init__.py b/pythonforandroid/recipes/libgeos/__init__.py index 42de1d8af0..7706a1f0c5 100644 --- a/pythonforandroid/recipes/libgeos/__init__.py +++ b/pythonforandroid/recipes/libgeos/__init__.py @@ -3,6 +3,7 @@ import sh from multiprocessing import cpu_count + class LibgeosRecipe(Recipe): version = '3.5' #url = 'http://download.osgeo.org/geos/geos-{version}.tar.bz2' @@ -16,17 +17,17 @@ def should_build(self, arch): def build_arch(self, arch): super(LibgeosRecipe, self).build_arch(arch) env = self.get_recipe_env(arch) - + with current_directory(self.get_build_dir(arch.arch)): - dst_dir = join(self.get_build_dir(arch.arch),'dist') + dst_dir = join(self.get_build_dir(arch.arch), 'dist') bash = sh.Command('bash') print("If this fails make sure you have autoconf and libtool installed") - shprint(bash,'autogen.sh') # Requires autoconf and libtool - shprint(bash, 'configure', '--host=arm-linux-androideabi', '--enable-shared','--prefix={}'.format(dst_dir), _env=env) - shprint(sh.make,'-j',str(cpu_count()),_env=env) - shprint(sh.make,'install',_env=env) + shprint(bash, 'autogen.sh') # Requires autoconf and libtool + shprint(bash, 'configure', '--host=arm-linux-androideabi', '--enable-shared', '--prefix={}'.format(dst_dir), _env=env) + shprint(sh.make, '-j', str(cpu_count()), _env=env) + shprint(sh.make, 'install', _env=env) shutil.copyfile('{}/lib/libgeos_c.so'.format(dst_dir), join(self.ctx.get_libs_dir(arch.arch), 'libgeos_c.so')) - + def get_recipe_env(self, arch): env = super(LibgeosRecipe, self).get_recipe_env(arch) env['CXXFLAGS'] += ' -I{}/sources/cxx-stl/gnu-libstdc++/4.8/include'.format(self.ctx.ndk_dir) @@ -39,5 +40,5 @@ def get_recipe_env(self, arch): self.ctx.ndk_dir, arch) return env -recipe = LibgeosRecipe() +recipe = LibgeosRecipe() diff --git a/pythonforandroid/recipes/libglob/__init__.py b/pythonforandroid/recipes/libglob/__init__.py index 893ae454aa..7ef7f42049 100644 --- a/pythonforandroid/recipes/libglob/__init__.py +++ b/pythonforandroid/recipes/libglob/__init__.py @@ -13,7 +13,7 @@ class LibGlobRecipe(CompiledComponentsPythonRecipe): """Make a glob.h and glob.so for the python_install_dir()""" version = '0.0.1' url = None - # + # # glob.h and glob.c extracted from # https://github.com/white-gecko/TokyoCabinet, e.g.: # https://raw.githubusercontent.com/white-gecko/TokyoCabinet/master/glob.h @@ -50,7 +50,7 @@ def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): cflags = env['CFLAGS'].split() - cflags.extend(['-I.', '-c', '-l.', 'glob.c', '-I.']) # , '-o', 'glob.o']) + cflags.extend(['-I.', '-c', '-l.', 'glob.c', '-I.']) # , '-o', 'glob.o']) shprint(cc, *cflags, _env=env) cflags = env['CFLAGS'].split() @@ -72,4 +72,5 @@ def build_arch(self, arch): include_path = join(self.ctx.python_recipe.get_build_dir(arch.arch), 'Include') shprint(sh.cp, "glob.h", include_path) + recipe = LibGlobRecipe() diff --git a/pythonforandroid/recipes/libmysqlclient/__init__.py b/pythonforandroid/recipes/libmysqlclient/__init__.py index 1b1ce12ab9..9235ad4325 100644 --- a/pythonforandroid/recipes/libmysqlclient/__init__.py +++ b/pythonforandroid/recipes/libmysqlclient/__init__.py @@ -11,9 +11,9 @@ class LibmysqlclientRecipe(Recipe): url = 'https://github.com/0x-ff/libmysql-android/archive/{version}.zip' # version = '5.5.47' # url = 'http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-{version}.tar.gz' - # + # # depends = ['ncurses'] - # + # # patches = ['add-custom-platform.patch'] @@ -47,7 +47,7 @@ def build_arch(self, arch): # env['CURSES_INCLUDE_PATH'] = join(ncurses.get_build_dir(arch.arch), # 'include') # return env - # + # # def build_arch(self, arch): # env = self.get_recipe_env(arch) # with current_directory(self.get_build_dir(arch.arch)): @@ -60,7 +60,7 @@ def build_arch(self, arch): # shprint(sh.cmake, '.', '-DCURSES_LIBRARY=' + env['CURSES_LIBRARY'], # '-DCURSES_INCLUDE_PATH=' + env['CURSES_INCLUDE_PATH'], _env=env) # shprint(sh.make, _env=env) - # + # # self.install_libs(arch, 'libmysqlclient.so') diff --git a/pythonforandroid/recipes/libnacl/__init__.py b/pythonforandroid/recipes/libnacl/__init__.py index 526e00bcee..823a39b650 100644 --- a/pythonforandroid/recipes/libnacl/__init__.py +++ b/pythonforandroid/recipes/libnacl/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + class LibNaClRecipe(PythonRecipe): version = '1.4.4' url = 'https://github.com/saltstack/libnacl/archive/v{version}.tar.gz' @@ -7,4 +8,5 @@ class LibNaClRecipe(PythonRecipe): site_packages_name = 'libnacl' call_hostpython_via_targetpython = False + recipe = LibNaClRecipe() diff --git a/pythonforandroid/recipes/libpq/__init__.py b/pythonforandroid/recipes/libpq/__init__.py index ee018c9eba..dcfb541870 100644 --- a/pythonforandroid/recipes/libpq/__init__.py +++ b/pythonforandroid/recipes/libpq/__init__.py @@ -22,4 +22,5 @@ def build_arch(self, arch): shprint(sh.cp, '-a', 'src/interfaces/libpq/libpq.a', self.ctx.get_libs_dir(arch.arch)) + recipe = LibpqRecipe() diff --git a/pythonforandroid/recipes/libshine/__init__.py b/pythonforandroid/recipes/libshine/__init__.py index a138c32d53..fe9b5b589c 100644 --- a/pythonforandroid/recipes/libshine/__init__.py +++ b/pythonforandroid/recipes/libshine/__init__.py @@ -26,4 +26,5 @@ def build_arch(self, arch): shprint(sh.make, '-j4', _env=env) shprint(sh.make, 'install', _env=env) + recipe = LibShineRecipe() diff --git a/pythonforandroid/recipes/libsodium/__init__.py b/pythonforandroid/recipes/libsodium/__init__.py index 95b2d2191b..a9981e29de 100644 --- a/pythonforandroid/recipes/libsodium/__init__.py +++ b/pythonforandroid/recipes/libsodium/__init__.py @@ -2,6 +2,7 @@ from os.path import exists, join import sh + class LibsodiumRecipe(Recipe): version = '1.0.8' url = 'https://github.com/jedisct1/libsodium/releases/download/{version}/libsodium-{version}.tar.gz' @@ -25,4 +26,5 @@ def get_recipe_env(self, arch): env['CFLAGS'] += ' -Os' return env + recipe = LibsodiumRecipe() diff --git a/pythonforandroid/recipes/libtorrent/__init__.py b/pythonforandroid/recipes/libtorrent/__init__.py index bbd1bebaab..556d75f54d 100644 --- a/pythonforandroid/recipes/libtorrent/__init__.py +++ b/pythonforandroid/recipes/libtorrent/__init__.py @@ -5,6 +5,8 @@ # This recipe builds libtorrent with Python bindings # It depends on Boost.Build and the source of several Boost libraries present in BOOST_ROOT, # which is all provided by the boost recipe + + class LibtorrentRecipe(Recipe): version = '1.0.9' # Don't forget to change the URL when changing the version @@ -40,8 +42,7 @@ def build_arch(self, arch): 'boost=source', 'encryption=openssl' if 'openssl' in recipe.ctx.recipe_build_order else '', '--prefix=' + env['CROSSHOME'], - 'release' - , _env=env) + 'release', _env=env) # Common build directories build_subdirs = 'gcc-arm/release/boost-link-shared/boost-source' if 'openssl' in recipe.ctx.recipe_build_order: @@ -70,4 +71,5 @@ def get_recipe_env(self, arch): env['OPENSSL_VERSION'] = r.version return env + recipe = LibtorrentRecipe() diff --git a/pythonforandroid/recipes/libtribler/__init__.py b/pythonforandroid/recipes/libtribler/__init__.py index b22d8f860c..6c64ecd145 100644 --- a/pythonforandroid/recipes/libtribler/__init__.py +++ b/pythonforandroid/recipes/libtribler/__init__.py @@ -5,6 +5,8 @@ http://www.tribler.org """ + + class LibTriblerRecipe(PythonRecipe): version = 'devel' @@ -22,4 +24,4 @@ class LibTriblerRecipe(PythonRecipe): site_packages_name = 'Tribler' -recipe = LibTriblerRecipe() \ No newline at end of file +recipe = LibTriblerRecipe() diff --git a/pythonforandroid/recipes/libx264/__init__.py b/pythonforandroid/recipes/libx264/__init__.py index 8e09f10c3b..c139b4ce74 100644 --- a/pythonforandroid/recipes/libx264/__init__.py +++ b/pythonforandroid/recipes/libx264/__init__.py @@ -28,4 +28,5 @@ def build_arch(self, arch): shprint(sh.make, '-j4', _env=env) shprint(sh.make, 'install', _env=env) + recipe = LibX264Recipe() diff --git a/pythonforandroid/recipes/libzmq/__init__.py b/pythonforandroid/recipes/libzmq/__init__.py index 1ebebf7b63..0dea2052ed 100644 --- a/pythonforandroid/recipes/libzmq/__init__.py +++ b/pythonforandroid/recipes/libzmq/__init__.py @@ -51,7 +51,7 @@ def build_arch(self, arch): # Copy libgnustl_shared.so with current_directory(self.get_build_dir(arch.arch)): sh.cp( - "{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx,arch=arch), + "{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx, arch=arch), self.ctx.get_libs_dir(arch.arch) ) diff --git a/pythonforandroid/recipes/m2crypto/__init__.py b/pythonforandroid/recipes/m2crypto/__init__.py index 0e3f671261..1532820ce8 100644 --- a/pythonforandroid/recipes/m2crypto/__init__.py +++ b/pythonforandroid/recipes/m2crypto/__init__.py @@ -24,8 +24,7 @@ def build_arch(self, arch): 'build_ext', '-p' + arch.arch, '-c' + 'unix', - '--openssl=' + openssl_dir - , _env=env) + '--openssl=' + openssl_dir, _env=env) # Install M2Crypto super(M2CryptoRecipe, self).build_arch(arch) @@ -45,4 +44,5 @@ def get_recipe_env(self, arch): ' -lcrypto' + r.version return env + recipe = M2CryptoRecipe() diff --git a/pythonforandroid/recipes/msgpack-python/__init__.py b/pythonforandroid/recipes/msgpack-python/__init__.py index 1a27227dbd..f005c338c3 100644 --- a/pythonforandroid/recipes/msgpack-python/__init__.py +++ b/pythonforandroid/recipes/msgpack-python/__init__.py @@ -7,4 +7,5 @@ class MsgPackRecipe(CythonRecipe): depends = [('python2', 'python3crystax'), "setuptools"] call_hostpython_via_targetpython = False + recipe = MsgPackRecipe() diff --git a/pythonforandroid/recipes/numpy/__init__.py b/pythonforandroid/recipes/numpy/__init__.py index bea4ffe354..fdff7e28f6 100644 --- a/pythonforandroid/recipes/numpy/__init__.py +++ b/pythonforandroid/recipes/numpy/__init__.py @@ -3,7 +3,7 @@ class NumpyRecipe(CompiledComponentsPythonRecipe): - + version = '1.9.2' url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.tar.gz' site_packages_name= 'numpy' @@ -16,7 +16,7 @@ class NumpyRecipe(CompiledComponentsPythonRecipe): 'patches/lib.patch'] def get_recipe_env(self, arch): - """ looks like numpy has no proper -L flags. Code copied and adapted from + """ looks like numpy has no proper -L flags. Code copied and adapted from https://github.com/frmdstryr/p4a-numpy/ """ @@ -28,7 +28,7 @@ def get_recipe_env(self, arch): py_ver = '2.7' py_so = '2.7' if py_ver == '2.7' else '3.5m' - + api_ver = self.ctx.android_api platform = 'arm' if 'arm' in arch.arch else arch.arch diff --git a/pythonforandroid/recipes/opencv/__init__.py b/pythonforandroid/recipes/opencv/__init__.py index ee6b388012..6e183b3330 100644 --- a/pythonforandroid/recipes/opencv/__init__.py +++ b/pythonforandroid/recipes/opencv/__init__.py @@ -15,11 +15,11 @@ class OpenCVRecipe(NDKRecipe): depends = ['numpy'] patches = ['patches/p4a_build-2.4.10.1.patch'] generated_libraries = ['cv2.so'] - + def prebuild_arch(self, arch): self.apply_patches(arch) - - def get_recipe_env(self,arch): + + def get_recipe_env(self, arch): env = super(OpenCVRecipe, self).get_recipe_env(arch) env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() env['ANDROID_NDK'] = self.ctx.ndk_dir @@ -32,20 +32,21 @@ def build_arch(self, arch): env = self.get_recipe_env(arch) cvsrc = self.get_build_dir(arch.arch) lib_dir = os.path.join(self.ctx.get_python_install_dir(), "lib") - + shprint(sh.cmake, - '-DP4A=ON','-DANDROID_ABI={}'.format(arch.arch), + '-DP4A=ON', '-DANDROID_ABI={}'.format(arch.arch), '-DCMAKE_TOOLCHAIN_FILE={}/platforms/android/android.toolchain.cmake'.format(cvsrc), '-DPYTHON_INCLUDE_PATH={}/include/python2.7'.format(env['PYTHON_ROOT']), '-DPYTHON_LIBRARY={}/lib/libpython2.7.so'.format(env['PYTHON_ROOT']), '-DPYTHON_NUMPY_INCLUDE_DIR={}/numpy/core/include'.format(env['SITEPACKAGES_PATH']), - '-DANDROID_EXECUTABLE={}/tools/android'.format(env['ANDROID_SDK']), + '-DANDROID_EXECUTABLE={}/tools/android'.format(env['ANDROID_SDK']), '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_EXAMPLES=OFF', '-DBUILD_ANDROID_EXAMPLES=OFF', '-DPYTHON_PACKAGES_PATH={}'.format(env['SITEPACKAGES_PATH']), cvsrc, _env=env) - shprint(sh.make,'-j',str(cpu_count()),'opencv_python') - shprint(sh.cmake,'-DCOMPONENT=python','-P','./cmake_install.cmake') - sh.cp('-a',sh.glob('./lib/{}/lib*.so'.format(arch.arch)),lib_dir) + shprint(sh.make, '-j', str(cpu_count()), 'opencv_python') + shprint(sh.cmake, '-DCOMPONENT=python', '-P', './cmake_install.cmake') + sh.cp('-a', sh.glob('./lib/{}/lib*.so'.format(arch.arch)), lib_dir) + recipe = OpenCVRecipe() diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py index 195fd3a2bc..b8256e8662 100644 --- a/pythonforandroid/recipes/openssl/__init__.py +++ b/pythonforandroid/recipes/openssl/__init__.py @@ -63,4 +63,5 @@ def build_arch(self, arch): self.install_libs(arch, 'libssl' + self.version + '.so', 'libcrypto' + self.version + '.so') + recipe = OpenSSLRecipe() diff --git a/pythonforandroid/recipes/png/__init__.py b/pythonforandroid/recipes/png/__init__.py index de42f6f809..b604dd5469 100644 --- a/pythonforandroid/recipes/png/__init__.py +++ b/pythonforandroid/recipes/png/__init__.py @@ -10,4 +10,3 @@ class PngRecipe(NDKRecipe): recipe = PngRecipe() - diff --git a/pythonforandroid/recipes/preppy/__init__.py b/pythonforandroid/recipes/preppy/__init__.py index ea7e34762f..40afd681ba 100644 --- a/pythonforandroid/recipes/preppy/__init__.py +++ b/pythonforandroid/recipes/preppy/__init__.py @@ -1,4 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + + class PreppyRecipe(PythonRecipe): version = '27b7085' url = 'https://bitbucket.org/rptlab/preppy/get/{version}.tar.gz' @@ -6,4 +8,5 @@ class PreppyRecipe(PythonRecipe): patches = ['fix-setup.patch'] call_hostpython_via_targetpython = False + recipe = PreppyRecipe() diff --git a/pythonforandroid/recipes/protobuf_cpp/__init__.py b/pythonforandroid/recipes/protobuf_cpp/__init__.py index 2a059aea2d..9fa5fbef11 100644 --- a/pythonforandroid/recipes/protobuf_cpp/__init__.py +++ b/pythonforandroid/recipes/protobuf_cpp/__init__.py @@ -47,13 +47,11 @@ def build_arch(self, arch): shprint(hostpython, 'setup.py', 'build_ext', - '--cpp_implementation' - , _env=env) + '--cpp_implementation', _env=env) # Install python bindings self.install_python_package(arch) - def install_python_package(self, arch): env = self.get_recipe_env(arch) @@ -84,7 +82,6 @@ def install_python_package(self, arch): '--cpp_implementation', _env=hpenv, *self.setup_extra_args) - def get_recipe_env(self, arch): env = super(ProtobufCppRecipe, self).get_recipe_env(arch) env['PROTOC'] = '/home/fipo/soft/protobuf-3.1.0/src/protoc' diff --git a/pythonforandroid/recipes/psycopg2/__init__.py b/pythonforandroid/recipes/psycopg2/__init__.py index ec4e6ea328..f26f79109d 100644 --- a/pythonforandroid/recipes/psycopg2/__init__.py +++ b/pythonforandroid/recipes/psycopg2/__init__.py @@ -39,4 +39,5 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True): '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=lib/python2.7/site-packages', _env=env) + recipe = Psycopg2Recipe() diff --git a/pythonforandroid/recipes/pyaml/__init__.py b/pythonforandroid/recipes/pyaml/__init__.py index c2acab4993..ee24eb8f9c 100644 --- a/pythonforandroid/recipes/pyaml/__init__.py +++ b/pythonforandroid/recipes/pyaml/__init__.py @@ -8,4 +8,5 @@ class PyamlRecipe(PythonRecipe): site_packages_name = 'yaml' call_hostpython_via_targetpython = False + recipe = PyamlRecipe() diff --git a/pythonforandroid/recipes/pyasn1/__init__.py b/pythonforandroid/recipes/pyasn1/__init__.py index 9b18933d7d..08c821edee 100644 --- a/pythonforandroid/recipes/pyasn1/__init__.py +++ b/pythonforandroid/recipes/pyasn1/__init__.py @@ -7,4 +7,5 @@ class PyASN1Recipe(PythonRecipe): url = 'https://pypi.python.org/packages/source/p/pyasn1/pyasn1-{version}.tar.gz' depends = ['python2'] + recipe = PyASN1Recipe() diff --git a/pythonforandroid/recipes/pycrypto/__init__.py b/pythonforandroid/recipes/pycrypto/__init__.py index 08c3e4909b..c2f68724da 100644 --- a/pythonforandroid/recipes/pycrypto/__init__.py +++ b/pythonforandroid/recipes/pycrypto/__init__.py @@ -39,4 +39,5 @@ def build_compiled_components(self, arch): '--enable-shared', _env=env) super(PyCryptoRecipe, self).build_compiled_components(arch) + recipe = PyCryptoRecipe() diff --git a/pythonforandroid/recipes/pygame/__init__.py b/pythonforandroid/recipes/pygame/__init__.py index f0d7e24494..38ef57f816 100644 --- a/pythonforandroid/recipes/pygame/__init__.py +++ b/pythonforandroid/recipes/pygame/__init__.py @@ -6,6 +6,7 @@ import sh import glob + class PygameRecipe(Recipe): name = 'pygame' version = '1.9.1' @@ -37,10 +38,10 @@ def prebuild_arch(self, arch): return shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'), join(self.get_build_dir(arch.arch), 'Setup')) - + def build_arch(self, arch): env = self.get_recipe_env(arch) - + env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format( jni_path=join(self.ctx.bootstrap.build_dir, 'jni')) env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl/include -I{jni_path}/sdl_mixer'.format( @@ -49,7 +50,6 @@ def build_arch(self, arch): jni_path=join(self.ctx.bootstrap.build_dir, 'jni')) debug('pygame cflags', env['CFLAGS']) - env['LDFLAGS'] = env['LDFLAGS'] + ' -L{libs_path} -L{src_path}/obj/local/{arch} -lm -lz'.format( libs_path=self.ctx.libs_dir, src_path=self.ctx.bootstrap.build_dir, arch=env['ARCH']) diff --git a/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py b/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py index e39bf25403..681834ed61 100644 --- a/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py +++ b/pythonforandroid/recipes/pygame_bootstrap_components/__init__.py @@ -24,6 +24,6 @@ def prebuild_arch(self, arch): shprint(sh.mv, dirn, './') info('Unpacking was successful, deleting original container dir') shprint(sh.rm, '-rf', self.get_build_dir(arch)) - + recipe = PygameJNIComponentsRecipe() diff --git a/pythonforandroid/recipes/pyleveldb/__init__.py b/pythonforandroid/recipes/pyleveldb/__init__.py index f1f79e9019..f249a91cfc 100644 --- a/pythonforandroid/recipes/pyleveldb/__init__.py +++ b/pythonforandroid/recipes/pyleveldb/__init__.py @@ -8,7 +8,7 @@ class PyLevelDBRecipe(CompiledComponentsPythonRecipe): url = 'https://pypi.python.org/packages/source/l/leveldb/leveldb-{version}.tar.gz' depends = ['snappy', 'leveldb', 'hostpython2', 'python2', 'setuptools'] patches = ['bindings-only.patch'] - call_hostpython_via_targetpython = False # Due to setuptools + call_hostpython_via_targetpython = False # Due to setuptools site_packages_name = 'leveldb' def build_arch(self, arch): @@ -33,4 +33,5 @@ def get_recipe_env(self, arch): ' -lleveldb' return env + recipe = PyLevelDBRecipe() diff --git a/pythonforandroid/recipes/pymunk/__init__.py b/pythonforandroid/recipes/pymunk/__init__.py index 1d9e532169..3352b38f4c 100644 --- a/pythonforandroid/recipes/pymunk/__init__.py +++ b/pythonforandroid/recipes/pymunk/__init__.py @@ -18,4 +18,5 @@ def get_recipe_env(self, arch): ctx=self.ctx, arch_noeabi=arch_noeabi) return env + recipe = PymunkRecipe() diff --git a/pythonforandroid/recipes/pyproj/__init__.py b/pythonforandroid/recipes/pyproj/__init__.py index 3caec1dac9..e8d8800191 100644 --- a/pythonforandroid/recipes/pyproj/__init__.py +++ b/pythonforandroid/recipes/pyproj/__init__.py @@ -7,5 +7,5 @@ class PyProjRecipe(CythonRecipe): depends = ['python2', 'setuptools'] call_hostpython_via_targetpython = False - + recipe = PyProjRecipe() diff --git a/pythonforandroid/recipes/pyrxp/__init__.py b/pythonforandroid/recipes/pyrxp/__init__.py index 2bf463dc5f..5d44f353c4 100644 --- a/pythonforandroid/recipes/pyrxp/__init__.py +++ b/pythonforandroid/recipes/pyrxp/__init__.py @@ -7,4 +7,5 @@ class PyRXPURecipe(CompiledComponentsPythonRecipe): depends = ['python2'] patches = [] + recipe = PyRXPURecipe() diff --git a/pythonforandroid/recipes/pysdl2/__init__.py b/pythonforandroid/recipes/pysdl2/__init__.py index 59f6fc7029..e0df9dc55b 100644 --- a/pythonforandroid/recipes/pysdl2/__init__.py +++ b/pythonforandroid/recipes/pysdl2/__init__.py @@ -1,6 +1,7 @@ from pythonforandroid.recipe import PythonRecipe + class PySDL2Recipe(PythonRecipe): version = '0.9.3' url = 'https://bitbucket.org/marcusva/py-sdl2/downloads/PySDL2-{version}.tar.gz' diff --git a/pythonforandroid/recipes/python2/__init__.py b/pythonforandroid/recipes/python2/__init__.py index 8c111e27cb..4e355e28a2 100644 --- a/pythonforandroid/recipes/python2/__init__.py +++ b/pythonforandroid/recipes/python2/__init__.py @@ -13,8 +13,8 @@ class Python2Recipe(TargetPythonRecipe): depends = ['hostpython2'] conflicts = ['python3crystax', 'python3'] - opt_depends = ['openssl','sqlite3'] - + opt_depends = ['openssl', 'sqlite3'] + patches = ['patches/Python-{version}-xcompile.patch', 'patches/Python-{version}-ctypes-disable-wchar.patch', 'patches/disable-modules.patch', @@ -55,7 +55,6 @@ def build_arch(self, arch): if not exists(join(self.ctx.get_libs_dir(arch.arch), 'libpython2.7.so')): shprint(sh.cp, join(self.get_build_dir(arch.arch), 'libpython2.7.so'), self.ctx.get_libs_dir(arch.arch)) - # # if exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): # if exists(join(self.ctx.libs_dir, 'libpython2.7.so')): # info('libpython2.7.so already exists, skipping python build.') @@ -76,7 +75,6 @@ def do_python_build(self, arch): with current_directory(self.get_build_dir(arch.arch)): - hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') @@ -138,7 +136,6 @@ def do_python_build(self, arch): except sh.ErrorReturnCode_2: print('First python2 make failed. This is expected, trying again.') - print('Second install (expected to work)') shprint(sh.touch, 'python.exe', 'python') shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), @@ -162,7 +159,6 @@ def do_python_build(self, arch): shprint(sh.rm, '-rf', join('python-install', 'lib', 'python2.7', dir_name)) - # info('Copying python-install to dist-dependent location') # shprint(sh.cp, '-a', 'python-install', self.ctx.get_python_install_dir()) @@ -171,8 +167,6 @@ def do_python_build(self, arch): # join(self.ctx.get_python_install_dir(), 'bin', 'python.host')) # self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host') - - # print('python2 build done, exiting for debug') # exit(1) diff --git a/pythonforandroid/recipes/python2/patches/_scproxy.py b/pythonforandroid/recipes/python2/patches/_scproxy.py index 24239409e4..c481f6d498 100644 --- a/pythonforandroid/recipes/python2/patches/_scproxy.py +++ b/pythonforandroid/recipes/python2/patches/_scproxy.py @@ -3,8 +3,10 @@ No proxy is supported yet. ''' + def _get_proxy_settings(): return {'exclude_simple': 1} + def _get_proxies(): return {} diff --git a/pythonforandroid/recipes/python3crystax/__init__.py b/pythonforandroid/recipes/python3crystax/__init__.py index f796cb6228..4e96bea57e 100644 --- a/pythonforandroid/recipes/python3crystax/__init__.py +++ b/pythonforandroid/recipes/python3crystax/__init__.py @@ -10,12 +10,13 @@ '3.6': ('https://github.com/inclement/crystax_python_builds/' 'releases/download/0.1/crystax_python_3.6_armeabi_armeabi-v7a.tar.gz')} + class Python3Recipe(TargetPythonRecipe): version = '3.5' url = '' name = 'python3crystax' - depends = ['hostpython3crystax'] + depends = ['hostpython3crystax'] conflicts = ['python2', 'python3'] from_crystax = True @@ -72,4 +73,5 @@ def build_arch(self, arch): # available. Using e.g. pyenv makes this easy. self.ctx.hostpython = 'python{}'.format(self.version) + recipe = Python3Recipe() diff --git a/pythonforandroid/recipes/pyusb/__init__.py b/pythonforandroid/recipes/pyusb/__init__.py index eff882a6da..3ef7a88073 100644 --- a/pythonforandroid/recipes/pyusb/__init__.py +++ b/pythonforandroid/recipes/pyusb/__init__.py @@ -7,7 +7,7 @@ class PyusbRecipe(PythonRecipe): url = 'https://pypi.python.org/packages/source/p/pyusb/pyusb-{version}.tar.gz' depends = [('python2', 'python3crystax')] site_packages_name = 'usb' - + patches = ['fix-android.patch'] diff --git a/pythonforandroid/recipes/pyyaml/__init__.py b/pythonforandroid/recipes/pyyaml/__init__.py index eba40507bc..4dc872171a 100644 --- a/pythonforandroid/recipes/pyyaml/__init__.py +++ b/pythonforandroid/recipes/pyyaml/__init__.py @@ -8,4 +8,5 @@ class PyYamlRecipe(PythonRecipe): site_packages_name = 'pyyaml' call_hostpython_via_targetpython = False + recipe = PyYamlRecipe() diff --git a/pythonforandroid/recipes/pyzmq/__init__.py b/pythonforandroid/recipes/pyzmq/__init__.py index a078ecf5d7..c4a79ffa82 100644 --- a/pythonforandroid/recipes/pyzmq/__init__.py +++ b/pythonforandroid/recipes/pyzmq/__init__.py @@ -55,4 +55,5 @@ def build_cython_components(self, arch): shprint(sh.find, build_dir, '-name', '"*.o"', '-exec', env['STRIP'], '{}', ';', _env=env) + recipe = PyZMQRecipe() diff --git a/pythonforandroid/recipes/reportlab/__init__.py b/pythonforandroid/recipes/reportlab/__init__.py index 501bd36745..9b9bb49ad7 100644 --- a/pythonforandroid/recipes/reportlab/__init__.py +++ b/pythonforandroid/recipes/reportlab/__init__.py @@ -7,19 +7,19 @@ class ReportLabRecipe(CompiledComponentsPythonRecipe): version = 'c088826211ca' url = 'https://bitbucket.org/rptlab/reportlab/get/{version}.tar.gz' - depends = ['python2','freetype'] + depends = ['python2', 'freetype'] def prebuild_arch(self, arch): if not self.is_patched(arch): super(ReportLabRecipe, self).prebuild_arch(arch) - self.apply_patch('patches/fix-setup.patch',arch.arch) + self.apply_patch('patches/fix-setup.patch', arch.arch) recipe_dir = self.get_build_dir(arch.arch) shprint(sh.touch, os.path.join(recipe_dir, '.patched')) - ft = self.get_recipe('freetype',self.ctx) + ft = self.get_recipe('freetype', self.ctx) ft_dir = ft.get_build_dir(arch.arch) - ft_lib_dir = os.environ.get('_FT_LIB_',os.path.join(ft_dir,'objs','.libs')) - ft_inc_dir = os.environ.get('_FT_INC_',os.path.join(ft_dir,'include')) - tmp_dir = os.path.normpath(os.path.join(recipe_dir,"..","..","tmp")) + ft_lib_dir = os.environ.get('_FT_LIB_', os.path.join(ft_dir, 'objs', '.libs')) + ft_inc_dir = os.environ.get('_FT_INC_', os.path.join(ft_dir, 'include')) + tmp_dir = os.path.normpath(os.path.join(recipe_dir, "..", "..", "tmp")) info('reportlab recipe: recipe_dir={}'.format(recipe_dir)) info('reportlab recipe: tmp_dir={}'.format(tmp_dir)) info('reportlab recipe: ft_dir={}'.format(ft_dir)) @@ -28,14 +28,15 @@ def prebuild_arch(self, arch): with current_directory(recipe_dir): sh.ls('-lathr') ensure_dir(tmp_dir) - pfbfile = os.path.join(tmp_dir,"pfbfer-20070710.zip") + pfbfile = os.path.join(tmp_dir, "pfbfer-20070710.zip") if not os.path.isfile(pfbfile): sh.wget("http://www.reportlab.com/ftp/pfbfer-20070710.zip", "-O", pfbfile) sh.unzip("-u", "-d", os.path.join(recipe_dir, "src", "reportlab", "fonts"), pfbfile) if os.path.isfile("setup.py"): - with open('setup.py','rb') as f: - text = f.read().replace('_FT_LIB_',ft_lib_dir).replace('_FT_INC_',ft_inc_dir) - with open('setup.py','wb') as f: + with open('setup.py', 'rb') as f: + text = f.read().replace('_FT_LIB_', ft_lib_dir).replace('_FT_INC_', ft_inc_dir) + with open('setup.py', 'wb') as f: f.write(text) + recipe = ReportLabRecipe() diff --git a/pythonforandroid/recipes/requests/__init__.py b/pythonforandroid/recipes/requests/__init__.py index c693cbeb6d..b81ea12de5 100644 --- a/pythonforandroid/recipes/requests/__init__.py +++ b/pythonforandroid/recipes/requests/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.recipe import PythonRecipe + class RequestsRecipe(PythonRecipe): version = '2.13.0' url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz' @@ -7,4 +8,5 @@ class RequestsRecipe(PythonRecipe): site_packages_name = 'requests' call_hostpython_via_targetpython = False + recipe = RequestsRecipe() diff --git a/pythonforandroid/recipes/sdl/__init__.py b/pythonforandroid/recipes/sdl/__init__.py index dd598269a9..a0e07b2675 100644 --- a/pythonforandroid/recipes/sdl/__init__.py +++ b/pythonforandroid/recipes/sdl/__init__.py @@ -6,7 +6,7 @@ class LibSDLRecipe(BootstrapNDKRecipe): version = "1.2.14" - url = None + url = None name = 'sdl' depends = ['python2', 'pygame_bootstrap_components'] conflicts = ['sdl2'] @@ -16,7 +16,7 @@ def build_arch(self, arch): if exists(join(self.ctx.libs_dir, 'libsdl.so')): info('libsdl.so already exists, skipping sdl build.') return - + env = self.get_recipe_env(arch) with current_directory(self.get_jni_dir()): diff --git a/pythonforandroid/recipes/sdl2/__init__.py b/pythonforandroid/recipes/sdl2/__init__.py index acf03c3261..79bf64c3c7 100644 --- a/pythonforandroid/recipes/sdl2/__init__.py +++ b/pythonforandroid/recipes/sdl2/__init__.py @@ -33,4 +33,3 @@ def build_arch(self, arch): recipe = LibSDL2Recipe() - diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 0a3c6b1617..d611899b42 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -12,4 +12,5 @@ class LibSDL2Image(BootstrapNDKRecipe): 'extra_cflags.patch', 'fix_with_ndk_15_plus.patch'] + recipe = LibSDL2Image() diff --git a/pythonforandroid/recipes/sdl2_mixer/__init__.py b/pythonforandroid/recipes/sdl2_mixer/__init__.py index d522ac3ccb..1a8e0a9cda 100644 --- a/pythonforandroid/recipes/sdl2_mixer/__init__.py +++ b/pythonforandroid/recipes/sdl2_mixer/__init__.py @@ -8,4 +8,5 @@ class LibSDL2Mixer(BootstrapNDKRecipe): patches = ['toggle_modplug_mikmod_smpeg_ogg.patch'] + recipe = LibSDL2Mixer() diff --git a/pythonforandroid/recipes/sdl2_ttf/__init__.py b/pythonforandroid/recipes/sdl2_ttf/__init__.py index eb444df29a..2d0a629ccb 100644 --- a/pythonforandroid/recipes/sdl2_ttf/__init__.py +++ b/pythonforandroid/recipes/sdl2_ttf/__init__.py @@ -6,4 +6,5 @@ class LibSDL2TTF(BootstrapNDKRecipe): url = 'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-{version}.tar.gz' dir_name = 'SDL2_ttf' + recipe = LibSDL2TTF() diff --git a/pythonforandroid/recipes/shapely/__init__.py b/pythonforandroid/recipes/shapely/__init__.py index 02b234dc54..05e260846e 100644 --- a/pythonforandroid/recipes/shapely/__init__.py +++ b/pythonforandroid/recipes/shapely/__init__.py @@ -1,4 +1,4 @@ -from pythonforandroid.recipe import Recipe,CythonRecipe +from pythonforandroid.recipe import Recipe, CythonRecipe class ShapelyRecipe(CythonRecipe): @@ -6,19 +6,17 @@ class ShapelyRecipe(CythonRecipe): url = 'https://github.com/Toblerity/Shapely/archive/master.zip' depends = ['python2', 'setuptools', 'libgeos'] call_hostpython_via_targetpython = False - - patches = ['setup.patch'] # Patch to force setup to fail when C extention fails to build - + + patches = ['setup.patch'] # Patch to force setup to fail when C extention fails to build + # setup_extra_args = ['sdist'] # DontForce Cython - + def get_recipe_env(self, arch, with_flags_in_cc=True): """ Add libgeos headers to path """ - env = super(ShapelyRecipe, self).get_recipe_env(arch,with_flags_in_cc) + env = super(ShapelyRecipe, self).get_recipe_env(arch, with_flags_in_cc) libgeos_dir = Recipe.get_recipe('libgeos', self.ctx).get_build_dir(arch.arch) env['CFLAGS'] += " -I{}/dist/include".format(libgeos_dir) return env - - - + + recipe = ShapelyRecipe() - \ No newline at end of file diff --git a/pythonforandroid/recipes/simple-crypt/__init__.py b/pythonforandroid/recipes/simple-crypt/__init__.py index d6b66ce3b1..0c2781ee4d 100644 --- a/pythonforandroid/recipes/simple-crypt/__init__.py +++ b/pythonforandroid/recipes/simple-crypt/__init__.py @@ -7,4 +7,5 @@ class SimpleCryptRecipe(PythonRecipe): depends = [('python2', 'python3crystax'), 'pycrypto'] site_packages_name = 'simplecrypt' + recipe = SimpleCryptRecipe() diff --git a/pythonforandroid/recipes/six/__init__.py b/pythonforandroid/recipes/six/__init__.py index 0166450471..e1e13b9ea6 100644 --- a/pythonforandroid/recipes/six/__init__.py +++ b/pythonforandroid/recipes/six/__init__.py @@ -7,4 +7,5 @@ class SixRecipe(PythonRecipe): url = 'https://pypi.python.org/packages/source/s/six/six-{version}.tar.gz' depends = [('python2', 'python3crystax')] + recipe = SixRecipe() diff --git a/pythonforandroid/recipes/snappy/__init__.py b/pythonforandroid/recipes/snappy/__init__.py index ca429b20b0..4ca61a219a 100644 --- a/pythonforandroid/recipes/snappy/__init__.py +++ b/pythonforandroid/recipes/snappy/__init__.py @@ -1,5 +1,6 @@ from pythonforandroid.toolchain import Recipe + class SnappyRecipe(Recipe): version = '1.1.3' url = 'https://github.com/google/snappy/releases/download/{version}/snappy-{version}.tar.gz' @@ -8,4 +9,5 @@ def should_build(self, arch): # Only download to use in leveldb recipe return False + recipe = SnappyRecipe() diff --git a/pythonforandroid/recipes/sqlalchemy/__init__.py b/pythonforandroid/recipes/sqlalchemy/__init__.py index 813f602565..809d45a3dc 100644 --- a/pythonforandroid/recipes/sqlalchemy/__init__.py +++ b/pythonforandroid/recipes/sqlalchemy/__init__.py @@ -5,9 +5,9 @@ class SQLAlchemyRecipe(CompiledComponentsPythonRecipe): name = 'sqlalchemy' version = '1.0.9' url = 'https://pypi.python.org/packages/source/S/SQLAlchemy/SQLAlchemy-{version}.tar.gz' - + depends = [('python2', 'python3crystax'), 'setuptools'] - + patches = ['zipsafe.patch'] diff --git a/pythonforandroid/recipes/sqlite3/__init__.py b/pythonforandroid/recipes/sqlite3/__init__.py index b94ff8c40d..cfdcb0f6ab 100644 --- a/pythonforandroid/recipes/sqlite3/__init__.py +++ b/pythonforandroid/recipes/sqlite3/__init__.py @@ -31,4 +31,5 @@ def get_recipe_env(self, arch): env['NDK_PROJECT_PATH'] = self.get_build_dir(arch.arch) return env + recipe = Sqlite3Recipe() diff --git a/pythonforandroid/recipes/twisted/__init__.py b/pythonforandroid/recipes/twisted/__init__.py index 5fb7031ea4..eefc2563c9 100644 --- a/pythonforandroid/recipes/twisted/__init__.py +++ b/pythonforandroid/recipes/twisted/__init__.py @@ -24,4 +24,5 @@ def get_recipe_env(self, arch): ]) return env + recipe = TwistedRecipe() diff --git a/pythonforandroid/recipes/ujson/__init__.py b/pythonforandroid/recipes/ujson/__init__.py index ec0cec8216..57bc69f711 100644 --- a/pythonforandroid/recipes/ujson/__init__.py +++ b/pythonforandroid/recipes/ujson/__init__.py @@ -5,5 +5,6 @@ class UJsonRecipe(CompiledComponentsPythonRecipe): version = '1.35' url = 'https://pypi.python.org/packages/source/u/ujson/ujson-{version}.tar.gz' depends = [('python2', 'python3crystax')] - + + recipe = UJsonRecipe() diff --git a/pythonforandroid/recipes/vlc/__init__.py b/pythonforandroid/recipes/vlc/__init__.py index 6d4d24f987..513275587c 100644 --- a/pythonforandroid/recipes/vlc/__init__.py +++ b/pythonforandroid/recipes/vlc/__init__.py @@ -4,6 +4,7 @@ from os import environ import sh + class VlcRecipe(Recipe): version = '3.0.0' url = None @@ -14,7 +15,7 @@ class VlcRecipe(Recipe): port_git = 'http://git.videolan.org/git/vlc-ports/android.git' # vlc_git = 'http://git.videolan.org/git/vlc.git' ENV_LIBVLC_AAR = 'LIBVLC_AAR' - aars = {} # for future use of multiple arch + aars = {} # for future use of multiple arch def prebuild_arch(self, arch): super(VlcRecipe, self).prebuild_arch(arch) @@ -70,4 +71,5 @@ def build_arch(self, arch): _tail=50, _critical=True) shprint(sh.cp, '-a', aar, self.ctx.aars_dir) + recipe = VlcRecipe() diff --git a/pythonforandroid/recipes/websocket-client/__init__.py b/pythonforandroid/recipes/websocket-client/__init__.py index b0de3d0055..9fecee3101 100644 --- a/pythonforandroid/recipes/websocket-client/__init__.py +++ b/pythonforandroid/recipes/websocket-client/__init__.py @@ -25,4 +25,5 @@ class WebSocketClient(Recipe): depends = ['kivy', 'python2', 'android', 'pyjnius', 'cryptography', 'pyasn1', 'pyopenssl'] + recipe = WebSocketClient() diff --git a/pythonforandroid/recipes/wsaccel/__init__.py b/pythonforandroid/recipes/wsaccel/__init__.py index 4a4ad6cf19..dd27caace8 100644 --- a/pythonforandroid/recipes/wsaccel/__init__.py +++ b/pythonforandroid/recipes/wsaccel/__init__.py @@ -7,4 +7,5 @@ class WSAccellRecipe(CythonRecipe): depends = [('python2', 'python3crystax')] call_hostpython_via_targetpython = False + recipe = WSAccellRecipe() diff --git a/pythonforandroid/recipes/zope/__init__.py b/pythonforandroid/recipes/zope/__init__.py index 036fbb1de5..45180a16f1 100644 --- a/pythonforandroid/recipes/zope/__init__.py +++ b/pythonforandroid/recipes/zope/__init__.py @@ -2,13 +2,14 @@ from pythonforandroid.recipe import PythonRecipe from os.path import join + class ZopeRecipe(PythonRecipe): name = 'zope' version = '4.1.3' url = 'http://pypi.python.org/packages/source/z/zope.interface/zope.interface-{version}.tar.gz' depends = ['python2'] - + def get_recipe_env(self, arch): env = super(ZopeRecipe, self).get_recipe_env(arch) @@ -22,4 +23,5 @@ def postbuild_arch(self, arch): # Should do some deleting here + recipe = ZopeRecipe() diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index dc72596fd5..ff8ab85a99 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -9,6 +9,7 @@ from __future__ import print_function from pythonforandroid import __version__ + def check_python_dependencies(): # Check if the Python requirements are installed. This appears # before the imports because otherwise they're imported elsewhere. @@ -201,6 +202,7 @@ def split_argument_list(l): return [] return re.split(r'[ ,]+', l) + class NoAbbrevParser(argparse.ArgumentParser): '''We want to disable argument abbreviation so as not to interfere with passing through arguments to build.py, but in python2 argparse @@ -212,6 +214,7 @@ class NoAbbrevParser(argparse.ArgumentParser): def _get_option_tuples(self, option_string): return [] + class ToolchainCL(object): def __init__(self): @@ -598,7 +601,6 @@ def clean(self, args): 'recognised'.format(component))) component_clean_methods[component](args) - def clean_all(self, args): '''Delete all build components; the package cache, package builds, bootstrap builds and distributions.''' @@ -939,7 +941,6 @@ def _adb(self, commands): sys.stdout.write(line) sys.stdout.flush() - def build_status(self, args): print('{Style.BRIGHT}Bootstraps whose core components are probably ' 'already built:{Style.RESET_ALL}'.format(Style=Out_Style)) @@ -971,5 +972,6 @@ def build_status(self, args): def main(): ToolchainCL() + if __name__ == "__main__": main() diff --git a/pythonforandroid/util.py b/pythonforandroid/util.py index 75e56bde63..bf5ba83901 100644 --- a/pythonforandroid/util.py +++ b/pythonforandroid/util.py @@ -19,6 +19,7 @@ class WgetDownloader(FancyURLopener): version = ('Wget/1.17.1') + urlretrieve = WgetDownloader().retrieve diff --git a/tox.ini b/tox.ini index ea0c63985f..63107c50ec 100644 --- a/tox.ini +++ b/tox.ini @@ -10,6 +10,6 @@ commands = flake8 pythonforandroid/ [flake8] ignore = E111, E114, E115, E116, E202, E121, E123, E124, E225, E126, E127, E128, - E129, E201, E203, E221, E226, E231, E241, E251, E261, E265, E266, E271, - E302, E303, E305, E401, E402, E501, E502, E703, E722, E741, F403, - F812, F841, F811, W291, W292, W293, W391, W503 + E129, E201, E221, E226, E241, E251, E265, E266, E271, + E401, E402, E501, E502, E703, E722, E741, F403, + F812, F841, F811, W292, W503