From e4515df43b0a57d0a6f5cc99419104cd752699ff Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Wed, 26 Jun 2019 22:56:30 +0100 Subject: [PATCH 1/3] Updated numpy recipe to version 1.16.4 Undid unnecessary parts of 1.16.4 recipe change Fully replaced numpy 1.15.1 patches with 1.16.4 patches Removed git commit info from patches --- pythonforandroid/recipes/numpy/__init__.py | 16 ++++--- ...tch => add_libm_explicitly_to_build.patch} | 10 ++-- .../recipes/numpy/patches/ar.patch | 25 +++++----- ...eck.patch => do_not_use_system_libs.patch} | 4 +- .../patches/fix_environment_detection.patch | 48 +++++++++++++++++++ ...xes.patch => fix_setup_dependencies.patch} | 39 ++------------- ...numpy.patch => remove_unittest_call.patch} | 30 +++++------- testapps/setup_testapp_python3.py | 2 +- testapps/testapp/main.py | 9 ++-- 9 files changed, 99 insertions(+), 84 deletions(-) rename pythonforandroid/recipes/numpy/patches/{lib.patch => add_libm_explicitly_to_build.patch} (87%) rename pythonforandroid/recipes/numpy/patches/{prevent_libs_check.patch => do_not_use_system_libs.patch} (81%) create mode 100644 pythonforandroid/recipes/numpy/patches/fix_environment_detection.patch rename pythonforandroid/recipes/numpy/patches/{python-fixes.patch => fix_setup_dependencies.patch} (50%) rename pythonforandroid/recipes/numpy/patches/{fix-numpy.patch => remove_unittest_call.patch} (68%) diff --git a/pythonforandroid/recipes/numpy/__init__.py b/pythonforandroid/recipes/numpy/__init__.py index 6b6e6b3907..97df43524d 100644 --- a/pythonforandroid/recipes/numpy/__init__.py +++ b/pythonforandroid/recipes/numpy/__init__.py @@ -5,18 +5,21 @@ class NumpyRecipe(CompiledComponentsPythonRecipe): - version = '1.15.1' + version = '1.16.4' url = 'https://pypi.python.org/packages/source/n/numpy/numpy-{version}.zip' site_packages_name = 'numpy' depends = [('python2', 'python3', 'python3crystax')] patches = [ - join('patches', 'fix-numpy.patch'), - join('patches', 'prevent_libs_check.patch'), + join('patches', 'add_libm_explicitly_to_build.patch'), + join('patches', 'do_not_use_system_libs.patch'), + join('patches', 'remove_unittest_call.patch'), join('patches', 'ar.patch'), - join('patches', 'lib.patch'), - join('patches', 'python-fixes.patch') - ] + join('patches', 'fix_setup_dependencies.patch'), + join('patches', 'fix_environment_detection.patch'), + ] + + call_hostpython_via_targetpython = False def build_compiled_components(self, arch): self.setup_extra_args = ['-j', str(cpu_count())] @@ -52,6 +55,7 @@ def get_recipe_env(self, arch): env['CC'] += flags if flags not in env['LD']: env['LD'] += flags + ' -shared' + return env diff --git a/pythonforandroid/recipes/numpy/patches/lib.patch b/pythonforandroid/recipes/numpy/patches/add_libm_explicitly_to_build.patch similarity index 87% rename from pythonforandroid/recipes/numpy/patches/lib.patch rename to pythonforandroid/recipes/numpy/patches/add_libm_explicitly_to_build.patch index 194ce51b31..fc2be9bd6d 100644 --- a/pythonforandroid/recipes/numpy/patches/lib.patch +++ b/pythonforandroid/recipes/numpy/patches/add_libm_explicitly_to_build.patch @@ -1,5 +1,5 @@ diff --git a/numpy/fft/setup.py b/numpy/fft/setup.py -index cd99a82d7..e614ecd07 100644 +index cd99a82..cd7c1ef 100644 --- a/numpy/fft/setup.py +++ b/numpy/fft/setup.py @@ -9,7 +9,8 @@ def configuration(parent_package='',top_path=None): @@ -8,12 +8,12 @@ index cd99a82d7..e614ecd07 100644 config.add_extension('fftpack_lite', - sources=['fftpack_litemodule.c', 'fftpack.c'] + sources=['fftpack_litemodule.c', 'fftpack.c'], -+ libraries=['m'] ++ libraries=['m'], ) return config diff --git a/numpy/linalg/setup.py b/numpy/linalg/setup.py -index 66c07c9e1..d34bd930a 100644 +index 66c07c9..d34bd93 100644 --- a/numpy/linalg/setup.py +++ b/numpy/linalg/setup.py @@ -43,6 +43,7 @@ def configuration(parent_package='', top_path=None): @@ -34,10 +34,10 @@ index 66c07c9e1..d34bd930a 100644 return config diff --git a/numpy/random/setup.py b/numpy/random/setup.py -index 3f3b773a4..c1db9f783 100644 +index 394a70e..44af180 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py -@@ -40,7 +40,7 @@ def configuration(parent_package='',top_path=None): +@@ -39,7 +39,7 @@ def configuration(parent_package='',top_path=None): if needs_mingw_ftime_workaround(): defs.append(("NPY_NEEDS_MINGW_TIME_WORKAROUND", None)) diff --git a/pythonforandroid/recipes/numpy/patches/ar.patch b/pythonforandroid/recipes/numpy/patches/ar.patch index ddb096cc81..c806636dc1 100644 --- a/pythonforandroid/recipes/numpy/patches/ar.patch +++ b/pythonforandroid/recipes/numpy/patches/ar.patch @@ -1,8 +1,8 @@ diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py -index 632bcb4..c1e0dd5 100644 +index 0fac9b0..94be92a 100644 --- a/numpy/core/code_generators/generate_umath.py +++ b/numpy/core/code_generators/generate_umath.py -@@ -970,6 +970,7 @@ def make_arrays(funcdict): +@@ -982,6 +982,7 @@ def make_arrays(funcdict): funclist.append('%s_%s' % (tname, name)) if t.simd is not None: for vt in t.simd: @@ -11,10 +11,10 @@ index 632bcb4..c1e0dd5 100644 #ifdef HAVE_ATTRIBUTE_TARGET_{ISA} if (npy_cpu_supports("{isa}")) {{ diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py -index b03fb96..f9e6cd0 100644 +index 14451fa..dfd65da 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py -@@ -275,6 +275,7 @@ def CCompiler_compile(self, sources, output_dir=None, macros=None, +@@ -295,6 +295,7 @@ def CCompiler_compile(self, sources, output_dir=None, macros=None, self._setup_compile(output_dir, macros, include_dirs, sources, depends, extra_postargs) cc_args = self._get_cc_args(pp_opts, debug, extra_preargs) @@ -22,19 +22,16 @@ index b03fb96..f9e6cd0 100644 display = "compile options: '%s'" % (' '.join(cc_args)) if extra_postargs: display += "\nextra options: '%s'" % (' '.join(extra_postargs)) +@@ -795,4 +796,3 @@ for _cc in ['msvc9', 'msvc', '_msvc', 'bcpp', 'cygwinc', 'emxc', 'unixc']: + _m = sys.modules.get('distutils.' + _cc + 'compiler') + if _m is not None: + setattr(_m, 'gen_lib_options', gen_lib_options) +- diff --git a/numpy/distutils/unixccompiler.py b/numpy/distutils/unixccompiler.py -index 11b2cce..f6dde79 100644 +index 11b2cce..c3e9f10 100644 --- a/numpy/distutils/unixccompiler.py +++ b/numpy/distutils/unixccompiler.py -@@ -54,6 +54,7 @@ def UnixCCompiler__compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts - deps = [] - - try: -+ self.linker_so = [os.environ['LD']+" "+os.environ['LDFLAGS']] - self.spawn(self.compiler_so + cc_args + [src, '-o', obj] + deps + - extra_postargs, display = display) - except DistutilsExecError: -@@ -111,6 +112,7 @@ def UnixCCompiler_create_static_lib(self, objects, output_libname, +@@ -111,6 +111,7 @@ def UnixCCompiler_create_static_lib(self, objects, output_libname, while tmp_objects: objects = tmp_objects[:50] tmp_objects = tmp_objects[50:] diff --git a/pythonforandroid/recipes/numpy/patches/prevent_libs_check.patch b/pythonforandroid/recipes/numpy/patches/do_not_use_system_libs.patch similarity index 81% rename from pythonforandroid/recipes/numpy/patches/prevent_libs_check.patch rename to pythonforandroid/recipes/numpy/patches/do_not_use_system_libs.patch index 8ff3775c13..cdcc41086b 100644 --- a/pythonforandroid/recipes/numpy/patches/prevent_libs_check.patch +++ b/pythonforandroid/recipes/numpy/patches/do_not_use_system_libs.patch @@ -1,8 +1,8 @@ diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py -index bea120cf9..a448a83fc 100644 +index 806f4f7..0d51cfa 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py -@@ -719,6 +719,7 @@ class system_info(object): +@@ -734,6 +734,7 @@ class system_info(object): return self.get_paths(self.section, key) def get_libs(self, key, default): diff --git a/pythonforandroid/recipes/numpy/patches/fix_environment_detection.patch b/pythonforandroid/recipes/numpy/patches/fix_environment_detection.patch new file mode 100644 index 0000000000..3c7251eaa1 --- /dev/null +++ b/pythonforandroid/recipes/numpy/patches/fix_environment_detection.patch @@ -0,0 +1,48 @@ +commit 9a09edac303c534a38c5d829d8537176f8a8dfb9 +Author: Alexander Taylor +Date: Fri Jun 28 22:50:45 2019 +0100 + + fix_environment_detection.patch + +diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h +index 64aaaac..e6293f9 100644 +--- a/numpy/core/include/numpy/npy_common.h ++++ b/numpy/core/include/numpy/npy_common.h +@@ -164,12 +164,12 @@ extern long long __cdecl _ftelli64(FILE *); + #endif + #else + #ifdef HAVE_FSEEKO +- #define npy_fseek fseeko ++ #define npy_fseek fseek + #else + #define npy_fseek fseek + #endif + #ifdef HAVE_FTELLO +- #define npy_ftell ftello ++ #define npy_ftell ftell + #else + #define npy_ftell ftell + #endif +@@ -321,13 +321,15 @@ typedef unsigned char npy_bool; + #define NPY_TRUE 1 + + +-#if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE +- typedef double npy_longdouble; +- #define NPY_LONGDOUBLE_FMT "g" +-#else +- typedef long double npy_longdouble; +- #define NPY_LONGDOUBLE_FMT "Lg" +-#endif ++/* #if NPY_SIZEOF_LONGDOUBLE == NPY_SIZEOF_DOUBLE */ ++/* typedef double npy_longdouble; */ ++/* #define NPY_LONGDOUBLE_FMT "g" */ ++/* #else */ ++/* typedef long double npy_longdouble; */ ++/* #define NPY_LONGDOUBLE_FMT "Lg" */ ++/* #endif */ ++typedef long double npy_longdouble; ++#define NPY_LONGDOUBLE_FMT "Lg" + + #ifndef Py_USING_UNICODE + #error Must use Python with unicode enabled. diff --git a/pythonforandroid/recipes/numpy/patches/python-fixes.patch b/pythonforandroid/recipes/numpy/patches/fix_setup_dependencies.patch similarity index 50% rename from pythonforandroid/recipes/numpy/patches/python-fixes.patch rename to pythonforandroid/recipes/numpy/patches/fix_setup_dependencies.patch index 59d225df6f..1c38bc6068 100644 --- a/pythonforandroid/recipes/numpy/patches/python-fixes.patch +++ b/pythonforandroid/recipes/numpy/patches/fix_setup_dependencies.patch @@ -1,35 +1,5 @@ -diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c -index c70f852..695efd5 100644 ---- a/numpy/core/src/multiarray/common.c -+++ b/numpy/core/src/multiarray/common.c -@@ -852,3 +852,12 @@ _may_have_objects(PyArray_Descr *dtype) - return (PyDataType_HASFIELDS(base) || - PyDataType_FLAGCHK(base, NPY_ITEM_HASOBJECT) ); - } -+ -+/* -+ * Dummy to fix android NDK problem with missing reference. -+ */ -+void * -+__emutls_get_address(struct __emutls_object *obj) -+{ -+ return NULL; -+} -diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py -index 8118e2f..b586442 100644 ---- a/numpy/distutils/exec_command.py -+++ b/numpy/distutils/exec_command.py -@@ -260,7 +260,7 @@ def _exec_command(command, use_shell=None, use_tee = None, **env): - return 127, '' - - text, err = proc.communicate() -- text = text.decode(locale.getpreferredencoding(False), -+ text = text.decode('UTF-8', - errors='replace') - - text = text.replace('\r\n', '\n') diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py -index f2d677a..758b1ed 100644 +index 42374ac..67fcd98 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -9,7 +9,6 @@ import atexit @@ -40,7 +10,7 @@ index f2d677a..758b1ed 100644 import distutils from distutils.errors import DistutilsError -@@ -93,10 +92,7 @@ def get_num_build_jobs(): +@@ -94,11 +93,7 @@ def get_num_build_jobs(): """ from numpy.distutils.core import get_distribution @@ -48,15 +18,16 @@ index f2d677a..758b1ed 100644 - cpu_count = len(os.sched_getaffinity(0)) - except AttributeError: - cpu_count = multiprocessing.cpu_count() +- cpu_count = min(cpu_count, 8) + cpu_count = 1 envjobs = int(os.environ.get("NPY_NUM_BUILD_JOBS", cpu_count)) dist = get_distribution() # may be None during configuration diff --git a/setup.py b/setup.py -index fed178e..b0266eb 100755 +index 8b2ded1..431c1b8 100755 --- a/setup.py +++ b/setup.py -@@ -377,9 +377,8 @@ def setup_package(): +@@ -389,9 +389,8 @@ def setup_package(): # Raise errors for unsupported commands, improve help output, etc. run_build = parse_setuppy_commands() diff --git a/pythonforandroid/recipes/numpy/patches/fix-numpy.patch b/pythonforandroid/recipes/numpy/patches/remove_unittest_call.patch similarity index 68% rename from pythonforandroid/recipes/numpy/patches/fix-numpy.patch rename to pythonforandroid/recipes/numpy/patches/remove_unittest_call.patch index a5e00843a0..e19dc0f814 100644 --- a/pythonforandroid/recipes/numpy/patches/fix-numpy.patch +++ b/pythonforandroid/recipes/numpy/patches/remove_unittest_call.patch @@ -1,24 +1,13 @@ diff --git a/numpy/testing/__init__.py b/numpy/testing/__init__.py -index a7c8593..007ce26 100644 +index a8bd4fc..6b01fa6 100644 --- a/numpy/testing/__init__.py +++ b/numpy/testing/__init__.py -@@ -1,22 +1,8 @@ --"""Common test support for all numpy test scripts. -+# fake tester, android don't have unittest -+class Tester(object): -+ def test(self, *args, **kwargs): -+ pass -+ def bench(self, *args, **kwargs): -+ pass -+test = Tester().test +@@ -5,18 +5,11 @@ in a single location, so that test scripts can just import it and work right + away. --This single module should provide all the common functionality for numpy tests --in a single location, so that test scripts can just import it and work right --away. -- --""" + """ -from __future__ import division, absolute_import, print_function -- + -from unittest import TestCase - -from ._private.utils import * @@ -29,6 +18,13 @@ index a7c8593..007ce26 100644 - -__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite'] - --from ._private.pytesttester import PytestTester +-from numpy._pytesttester import PytestTester -test = PytestTester(__name__) -del PytestTester ++# fake tester, android don't have unittest ++class Tester(object): ++ def test(self, *args, **kwargs): ++ pass ++ def bench(self, *args, **kwargs): ++ pass ++test = Tester().test diff --git a/testapps/setup_testapp_python3.py b/testapps/setup_testapp_python3.py index bf83b06c33..57065941cf 100644 --- a/testapps/setup_testapp_python3.py +++ b/testapps/setup_testapp_python3.py @@ -19,7 +19,7 @@ print('packages are', packages) setup( - name='testapp_python3_googlendk', + name='python3_googlendk', version='1.1', description='p4a setup.py test', author='Alexander Taylor', diff --git a/testapps/testapp/main.py b/testapps/testapp/main.py index c235d6ed3d..5baa420f3c 100644 --- a/testapps/testapp/main.py +++ b/testapps/testapp/main.py @@ -27,7 +27,6 @@ from kivy.utils import platform print('platform is', platform) - kv = ''' #:import Metrics kivy.metrics.Metrics #:import sys sys @@ -90,7 +89,7 @@ on_touch_down: print('touched at', args[-1].pos) : - title: 'Error' + title: 'Error' size_hint: 0.75, 0.75 Label: text: root.error_text @@ -128,7 +127,7 @@ def test_pyjnius(self, *args): except ImportError: raise_error('Could not import pyjnius') return - + print('Attempting to vibrate with pyjnius') # PythonActivity = autoclass('org.renpy.android.PythonActivity') # activity = PythonActivity.mActivity @@ -142,13 +141,13 @@ def test_pyjnius(self, *args): def test_ctypes(self, *args): import ctypes - + def test_numpy(self, *args): import numpy print(numpy.zeros(5)) print(numpy.arange(5)) print(numpy.random.random((3, 3))) - + TestApp().run() From 456b6a8394522aef932b7a725696dae0d8259cac Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Fri, 28 Jun 2019 23:32:11 +0100 Subject: [PATCH 2/3] Updated numpy version targeted by matplotlib recipe --- .../recipes/matplotlib/mpl_android_fixes.patch | 18 +++++++++--------- testapps/setup_testapp_python3_matplotlib.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pythonforandroid/recipes/matplotlib/mpl_android_fixes.patch b/pythonforandroid/recipes/matplotlib/mpl_android_fixes.patch index 1ae826f22c..021b7b0260 100644 --- a/pythonforandroid/recipes/matplotlib/mpl_android_fixes.patch +++ b/pythonforandroid/recipes/matplotlib/mpl_android_fixes.patch @@ -4,26 +4,26 @@ index fc82d5d..2067db0 100644 +++ b/setupext.py @@ -1004,10 +1004,10 @@ class Numpy(SetupPackage): ext.define_macros.append(('__STDC_FORMAT_MACROS', 1)) - + def get_setup_requires(self): - return ['numpy>=1.10.0'] -+ return ['numpy==1.15.1'] # to match p4a's target version - ++ return ['numpy==1.16.4'] # to match p4a's target version + def get_install_requires(self): - return ['numpy>=1.10.0'] -+ return ['numpy==1.15.1'] # to match p4a's target version - - ++ return ['numpy==1.16.4'] # to match p4a's target version + + class LibAgg(SetupPackage): @@ -1443,9 +1443,10 @@ class BackendAgg(OptionalBackendPackage): - + class BackendTkAgg(OptionalBackendPackage): name = "tkagg" - force = True + force = False - + def check(self): + raise CheckFailed("Disabled by patching during Android build") # tk doesn't work on Android but causes build problems return "installing; run-time loading from Python Tcl / Tk" - + def get_extension(self): diff --git a/testapps/setup_testapp_python3_matplotlib.py b/testapps/setup_testapp_python3_matplotlib.py index 3320579466..014f4492b2 100644 --- a/testapps/setup_testapp_python3_matplotlib.py +++ b/testapps/setup_testapp_python3_matplotlib.py @@ -19,7 +19,7 @@ print('packages are', packages) setup( - name='testapp_matplotlib', + name='matplotlib_testapp', version='0.1', description='p4a setup.py test', author='Alexander Taylor', From d63adf26eeabbb09477163feb4e2bdec71817989 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 29 Jun 2019 13:07:53 +0100 Subject: [PATCH 3/3] Added matplotlib to broken recipes list https://github.com/kivy/python-for-android/issues/1900 logs failure --- ci/constants.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/constants.py b/ci/constants.py index 7e60e19d6f..27e9d31a1e 100644 --- a/ci/constants.py +++ b/ci/constants.py @@ -56,6 +56,7 @@ class TargetPython(Enum): 'websocket-client', 'zeroconf', 'zope', + 'matplotlib', # https://github.com/kivy/python-for-android/issues/1900 ]) BROKEN_RECIPES_PYTHON3 = set([ 'brokenrecipe', @@ -77,6 +78,7 @@ class TargetPython(Enum): # mpmath package with a version >= 0.19 required 'sympy', 'vlc', + 'matplotlib', # https://github.com/kivy/python-for-android/issues/1900 ]) BROKEN_RECIPES = {