From e1680f5e2d531eb0be2e59c5dab90b89e89bd2b2 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Tue, 13 Feb 2018 21:51:26 +0000 Subject: [PATCH 1/2] Added sympy recipe --- pythonforandroid/recipes/sympy/__init__.py | 16 ++ .../recipes/sympy/fix_android_detection.patch | 47 ++++ .../recipes/sympy/fix_pretty_print.patch | 223 ++++++++++++++++++ .../recipes/sympy/fix_timeutils.patch | 13 + 4 files changed, 299 insertions(+) create mode 100644 pythonforandroid/recipes/sympy/__init__.py create mode 100644 pythonforandroid/recipes/sympy/fix_android_detection.patch create mode 100644 pythonforandroid/recipes/sympy/fix_pretty_print.patch create mode 100644 pythonforandroid/recipes/sympy/fix_timeutils.patch diff --git a/pythonforandroid/recipes/sympy/__init__.py b/pythonforandroid/recipes/sympy/__init__.py new file mode 100644 index 0000000000..d1b9f9b14e --- /dev/null +++ b/pythonforandroid/recipes/sympy/__init__.py @@ -0,0 +1,16 @@ + +from pythonforandroid.toolchain import PythonRecipe + + +class SympyRecipe(PythonRecipe): + version = '1.1.1' + url = 'https://github.com/sympy/sympy/releases/download/sympy-{version}/sympy-{version}.tar.gz' + + # depends = [('python2', 'python3crystax'), 'setuptools'] + depends = [('python2', 'python3crystax'), 'mpmath'] + + call_hostpython_via_targetpython = True + + patches = ['fix_timeutils.patch', 'fix_pretty_print.patch'] + +recipe = SympyRecipe() diff --git a/pythonforandroid/recipes/sympy/fix_android_detection.patch b/pythonforandroid/recipes/sympy/fix_android_detection.patch new file mode 100644 index 0000000000..964c3db66f --- /dev/null +++ b/pythonforandroid/recipes/sympy/fix_android_detection.patch @@ -0,0 +1,47 @@ +diff --git a/pip/download.py b/pip/download.py +index 54d3131..1aab70f 100644 +--- a/pip/download.py ++++ b/pip/download.py +@@ -89,23 +89,25 @@ def user_agent(): + # Complete Guess + data["implementation"]["version"] = platform.python_version() + +- if sys.platform.startswith("linux"): +- from pip._vendor import distro +- distro_infos = dict(filter( +- lambda x: x[1], +- zip(["name", "version", "id"], distro.linux_distribution()), +- )) +- libc = dict(filter( +- lambda x: x[1], +- zip(["lib", "version"], libc_ver()), +- )) +- if libc: +- distro_infos["libc"] = libc +- if distro_infos: +- data["distro"] = distro_infos +- +- if sys.platform.startswith("darwin") and platform.mac_ver()[0]: +- data["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]} ++ # if sys.platform.startswith("linux"): ++ # from pip._vendor import distro ++ # distro_infos = dict(filter( ++ # lambda x: x[1], ++ # zip(["name", "version", "id"], distro.linux_distribution()), ++ # )) ++ # libc = dict(filter( ++ # lambda x: x[1], ++ # zip(["lib", "version"], libc_ver()), ++ # )) ++ # if libc: ++ # distro_infos["libc"] = libc ++ # if distro_infos: ++ # data["distro"] = distro_infos ++ ++ # if sys.platform.startswith("darwin") and platform.mac_ver()[0]: ++ # data["distro"] = {"name": "macOS", "version": platform.mac_ver()[0]} ++ ++ data['distro'] = {'name': 'Android'} + + if platform.system(): + data.setdefault("system", {})["name"] = platform.system() diff --git a/pythonforandroid/recipes/sympy/fix_pretty_print.patch b/pythonforandroid/recipes/sympy/fix_pretty_print.patch new file mode 100644 index 0000000000..f94cb2245c --- /dev/null +++ b/pythonforandroid/recipes/sympy/fix_pretty_print.patch @@ -0,0 +1,223 @@ +diff --git a/sympy/printing/pretty/pretty.py b/sympy/printing/pretty/pretty.py +index 604e97c..ddd3eb2 100644 +--- a/sympy/printing/pretty/pretty.py ++++ b/sympy/printing/pretty/pretty.py +@@ -166,14 +166,14 @@ class PrettyPrinter(Printer): + arg = e.args[0] + pform = self._print(arg) + if isinstance(arg, Equivalent): +- return self._print_Equivalent(arg, altchar=u"\N{NOT IDENTICAL TO}") ++ return self._print_Equivalent(arg, altchar=u"NOT IDENTICAL TO") + if isinstance(arg, Implies): +- return self._print_Implies(arg, altchar=u"\N{RIGHTWARDS ARROW WITH STROKE}") ++ return self._print_Implies(arg, altchar=u"RIGHTWARDS ARROW WITH STROKE") + + if arg.is_Boolean and not arg.is_Not: + pform = prettyForm(*pform.parens()) + +- return prettyForm(*pform.left(u"\N{NOT SIGN}")) ++ return prettyForm(*pform.left(u"NOT SIGN")) + else: + return self._print_Function(e) + +@@ -200,43 +200,43 @@ class PrettyPrinter(Printer): + + def _print_And(self, e): + if self._use_unicode: +- return self.__print_Boolean(e, u"\N{LOGICAL AND}") ++ return self.__print_Boolean(e, u"LOGICAL AND") + else: + return self._print_Function(e, sort=True) + + def _print_Or(self, e): + if self._use_unicode: +- return self.__print_Boolean(e, u"\N{LOGICAL OR}") ++ return self.__print_Boolean(e, u"LOGICAL OR") + else: + return self._print_Function(e, sort=True) + + def _print_Xor(self, e): + if self._use_unicode: +- return self.__print_Boolean(e, u"\N{XOR}") ++ return self.__print_Boolean(e, u"XOR") + else: + return self._print_Function(e, sort=True) + + def _print_Nand(self, e): + if self._use_unicode: +- return self.__print_Boolean(e, u"\N{NAND}") ++ return self.__print_Boolean(e, u"NAND") + else: + return self._print_Function(e, sort=True) + + def _print_Nor(self, e): + if self._use_unicode: +- return self.__print_Boolean(e, u"\N{NOR}") ++ return self.__print_Boolean(e, u"NOR") + else: + return self._print_Function(e, sort=True) + + def _print_Implies(self, e, altchar=None): + if self._use_unicode: +- return self.__print_Boolean(e, altchar or u"\N{RIGHTWARDS ARROW}", sort=False) ++ return self.__print_Boolean(e, altchar or u"RIGHTWARDS ARROW", sort=False) + else: + return self._print_Function(e) + + def _print_Equivalent(self, e, altchar=None): + if self._use_unicode: +- return self.__print_Boolean(e, altchar or u"\N{IDENTICAL TO}") ++ return self.__print_Boolean(e, altchar or u"IDENTICAL TO") + else: + return self._print_Function(e, sort=True) + +@@ -425,7 +425,7 @@ class PrettyPrinter(Printer): + if self._use_unicode: + # use unicode corners + horizontal_chr = xobj('-', 1) +- corner_chr = u'\N{BOX DRAWINGS LIGHT DOWN AND HORIZONTAL}' ++ corner_chr = u'BOX DRAWINGS LIGHT DOWN AND HORIZONTAL' + + func_height = pretty_func.height() + +@@ -580,7 +580,7 @@ class PrettyPrinter(Printer): + + LimArg = self._print(z) + if self._use_unicode: +- LimArg = prettyForm(*LimArg.right(u'\N{BOX DRAWINGS LIGHT HORIZONTAL}\N{RIGHTWARDS ARROW}')) ++ LimArg = prettyForm(*LimArg.right(u'BOX DRAWINGS LIGHT HORIZONTALRIGHTWARDS ARROW')) + else: + LimArg = prettyForm(*LimArg.right('->')) + LimArg = prettyForm(*LimArg.right(self._print(z0))) +@@ -589,7 +589,7 @@ class PrettyPrinter(Printer): + dir = "" + else: + if self._use_unicode: +- dir = u'\N{SUPERSCRIPT PLUS SIGN}' if str(dir) == "+" else u'\N{SUPERSCRIPT MINUS}' ++ dir = u'SUPERSCRIPT PLUS SIGN' if str(dir) == "+" else u'SUPERSCRIPT MINUS' + + LimArg = prettyForm(*LimArg.right(self._print(dir))) + +@@ -740,7 +740,7 @@ class PrettyPrinter(Printer): + def _print_Adjoint(self, expr): + pform = self._print(expr.arg) + if self._use_unicode: +- dag = prettyForm(u'\N{DAGGER}') ++ dag = prettyForm(u'DAGGER') + else: + dag = prettyForm('+') + from sympy.matrices import MatrixSymbol +@@ -850,8 +850,8 @@ class PrettyPrinter(Printer): + if '\n' in partstr: + tempstr = partstr + tempstr = tempstr.replace(vectstrs[i], '') +- tempstr = tempstr.replace(u'\N{RIGHT PARENTHESIS UPPER HOOK}', +- u'\N{RIGHT PARENTHESIS UPPER HOOK}' ++ tempstr = tempstr.replace(u'RIGHT PARENTHESIS UPPER HOOK', ++ u'RIGHT PARENTHESIS UPPER HOOK' + + ' ' + vectstrs[i]) + o1[i] = tempstr + o1 = [x.split('\n') for x in o1] +@@ -1153,7 +1153,7 @@ class PrettyPrinter(Printer): + def _print_Lambda(self, e): + vars, expr = e.args + if self._use_unicode: +- arrow = u" \N{RIGHTWARDS ARROW FROM BAR} " ++ arrow = u" RIGHTWARDS ARROW FROM BAR " + else: + arrow = " -> " + if len(vars) == 1: +@@ -1173,7 +1173,7 @@ class PrettyPrinter(Printer): + elif len(expr.variables): + pform = prettyForm(*pform.right(self._print(expr.variables[0]))) + if self._use_unicode: +- pform = prettyForm(*pform.right(u" \N{RIGHTWARDS ARROW} ")) ++ pform = prettyForm(*pform.right(u" RIGHTWARDS ARROW ")) + else: + pform = prettyForm(*pform.right(" -> ")) + if len(expr.point) > 1: +@@ -1462,7 +1462,7 @@ class PrettyPrinter(Printer): + and expt is S.Half and bpretty.height() == 1 + and (bpretty.width() == 1 + or (base.is_Integer and base.is_nonnegative))): +- return prettyForm(*bpretty.left(u'\N{SQUARE ROOT}')) ++ return prettyForm(*bpretty.left(u'SQUARE ROOT')) + + # Construct root sign, start with the \/ shape + _zZ = xobj('/', 1) +@@ -1558,7 +1558,7 @@ class PrettyPrinter(Printer): + from sympy import Pow + return self._print(Pow(p.sets[0], len(p.sets), evaluate=False)) + else: +- prod_char = u"\N{MULTIPLICATION SIGN}" if self._use_unicode else 'x' ++ prod_char = u"MULTIPLICATION SIGN" if self._use_unicode else 'x' + return self._print_seq(p.sets, None, None, ' %s ' % prod_char, + parenthesize=lambda set: set.is_Union or + set.is_Intersection or set.is_ProductSet) +@@ -1570,7 +1570,7 @@ class PrettyPrinter(Printer): + def _print_Range(self, s): + + if self._use_unicode: +- dots = u"\N{HORIZONTAL ELLIPSIS}" ++ dots = u"HORIZONTAL ELLIPSIS" + else: + dots = '...' + +@@ -1641,7 +1641,7 @@ class PrettyPrinter(Printer): + + def _print_ImageSet(self, ts): + if self._use_unicode: +- inn = u"\N{SMALL ELEMENT OF}" ++ inn = u"SMALL ELEMENT OF" + else: + inn = 'in' + variables = self._print_seq(ts.lamda.variables) +@@ -1653,10 +1653,10 @@ class PrettyPrinter(Printer): + + def _print_ConditionSet(self, ts): + if self._use_unicode: +- inn = u"\N{SMALL ELEMENT OF}" ++ inn = u"SMALL ELEMENT OF" + # using _and because and is a keyword and it is bad practice to + # overwrite them +- _and = u"\N{LOGICAL AND}" ++ _and = u"LOGICAL AND" + else: + inn = 'in' + _and = 'and' +@@ -1677,7 +1677,7 @@ class PrettyPrinter(Printer): + + def _print_ComplexRegion(self, ts): + if self._use_unicode: +- inn = u"\N{SMALL ELEMENT OF}" ++ inn = u"SMALL ELEMENT OF" + else: + inn = 'in' + variables = self._print_seq(ts.variables) +@@ -1690,7 +1690,7 @@ class PrettyPrinter(Printer): + def _print_Contains(self, e): + var, set = e.args + if self._use_unicode: +- el = u" \N{ELEMENT OF} " ++ el = u" ELEMENT OF " + return prettyForm(*stringPict.next(self._print(var), + el, self._print(set)), binding=8) + else: +@@ -1698,7 +1698,7 @@ class PrettyPrinter(Printer): + + def _print_FourierSeries(self, s): + if self._use_unicode: +- dots = u"\N{HORIZONTAL ELLIPSIS}" ++ dots = u"HORIZONTAL ELLIPSIS" + else: + dots = '...' + return self._print_Add(s.truncate()) + self._print(dots) +@@ -1708,7 +1708,7 @@ class PrettyPrinter(Printer): + + def _print_SeqFormula(self, s): + if self._use_unicode: +- dots = u"\N{HORIZONTAL ELLIPSIS}" ++ dots = u"HORIZONTAL ELLIPSIS" + else: + dots = '...' + diff --git a/pythonforandroid/recipes/sympy/fix_timeutils.patch b/pythonforandroid/recipes/sympy/fix_timeutils.patch new file mode 100644 index 0000000000..c8424eaa2c --- /dev/null +++ b/pythonforandroid/recipes/sympy/fix_timeutils.patch @@ -0,0 +1,13 @@ +diff --git a/sympy/utilities/timeutils.py b/sympy/utilities/timeutils.py +index 3770d85..c53594e 100644 +--- a/sympy/utilities/timeutils.py ++++ b/sympy/utilities/timeutils.py +@@ -8,7 +8,7 @@ import math + from sympy.core.compatibility import range + + _scales = [1e0, 1e3, 1e6, 1e9] +-_units = [u's', u'ms', u'\N{GREEK SMALL LETTER MU}s', u'ns'] ++_units = [u's', u'ms', u'mus', u'ns'] + + + def timed(func, setup="pass", limit=None): From 5f665273d0a040e6f5d8efba1a2e5f12feb49b0e Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Sun, 11 Nov 2018 18:02:28 +0100 Subject: [PATCH 2/2] Fixes import, linter and comments Also adds sympy to ignore list: ``` Please install the mpmath package with a version >= 0.19 ``` --- ci/constants.py | 4 ++++ pythonforandroid/recipes/sympy/__init__.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/constants.py b/ci/constants.py index 0e1bccda8a..a6a8f99702 100644 --- a/ci/constants.py +++ b/ci/constants.py @@ -57,6 +57,8 @@ class TargetPython(Enum): 'pyzmq', 'secp256k1', 'shapely', + # mpmath package with a version >= 0.19 required + 'sympy', 'twisted', 'vlc', 'websocket-client', @@ -93,6 +95,8 @@ class TargetPython(Enum): 'pyjnius', 'pyopenal', # SyntaxError: invalid syntax (Python2) 'storm', + # mpmath package with a version >= 0.19 required + 'sympy', 'vlc', ]) # to be created via https://github.com/kivy/python-for-android/issues/1514 diff --git a/pythonforandroid/recipes/sympy/__init__.py b/pythonforandroid/recipes/sympy/__init__.py index d1b9f9b14e..473c4332da 100644 --- a/pythonforandroid/recipes/sympy/__init__.py +++ b/pythonforandroid/recipes/sympy/__init__.py @@ -1,16 +1,16 @@ -from pythonforandroid.toolchain import PythonRecipe +from pythonforandroid.recipe import PythonRecipe class SympyRecipe(PythonRecipe): version = '1.1.1' url = 'https://github.com/sympy/sympy/releases/download/sympy-{version}/sympy-{version}.tar.gz' - # depends = [('python2', 'python3crystax'), 'setuptools'] depends = [('python2', 'python3crystax'), 'mpmath'] call_hostpython_via_targetpython = True patches = ['fix_timeutils.patch', 'fix_pretty_print.patch'] + recipe = SympyRecipe()