From 99599aab24e9813dae9bb51bd017f3b7a9bf7fec Mon Sep 17 00:00:00 2001 From: yaki29 Date: Sat, 28 Jan 2017 01:54:48 +0530 Subject: [PATCH 1/6] recipe for libxml2 added --- pythonforandroid/recipes/libxml2/__init__.py | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pythonforandroid/recipes/libxml2/__init__.py diff --git a/pythonforandroid/recipes/libxml2/__init__.py b/pythonforandroid/recipes/libxml2/__init__.py new file mode 100644 index 0000000000..14db65a33a --- /dev/null +++ b/pythonforandroid/recipes/libxml2/__init__.py @@ -0,0 +1,31 @@ +from pythonforandroid.toolchain import (CythonRecipe, shprint, + current_directory, info, Recipe) +from pythonforandroid.patching import will_build, check_any +import sh +from os.path import join + + +class Libxml2Recipe(CythonRecipe): + version = '2.9.4' + url = 'ftp://xmlsoft.org/libxml2/libxml2-{version}.tar.gz' + name = 'libxml2' + depends = [('python2', 'python3crystax')] + + def get_recipe_env(self, arch): + env = super(Libxml2Recipe, self).get_recipe_env(arch) + + try: + sh.sed('runtest\$(EXEEXT) \\/ \\/', 'Makefile') + except: + pass + try: + sh.sed('testrecurse\$(EXEEXT)$//', 'Makefile') + except: + pass + try: + sh.make('-j', '$MAKE_JOBS') + except: + pass + + +recipe = Libxml2Recipe() From c4b8969e3104d39535380bc07cf8c1c8f6dcd75a Mon Sep 17 00:00:00 2001 From: yaki29 Date: Sun, 29 Jan 2017 04:27:50 +0530 Subject: [PATCH 2/6] lxml,libxslt,libxml2,beautifulsoup4 recipe added --- .../recipes/beautifulsoup4/__init__.py | 25 +++++++++++++++ pythonforandroid/recipes/libxml2/__init__.py | 19 +++-------- pythonforandroid/recipes/libxslt/__init__.py | 23 +++++++++++++ .../recipes/libxslt/fix-dlopen.patch | 11 +++++++ pythonforandroid/recipes/lxml/__init__.py | 32 +++++++++++++++++++ pythonforandroid/recipes/requests/__init__.py | 2 +- 6 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 pythonforandroid/recipes/beautifulsoup4/__init__.py create mode 100644 pythonforandroid/recipes/libxslt/__init__.py create mode 100644 pythonforandroid/recipes/libxslt/fix-dlopen.patch create mode 100644 pythonforandroid/recipes/lxml/__init__.py diff --git a/pythonforandroid/recipes/beautifulsoup4/__init__.py b/pythonforandroid/recipes/beautifulsoup4/__init__.py new file mode 100644 index 0000000000..65dc374fe1 --- /dev/null +++ b/pythonforandroid/recipes/beautifulsoup4/__init__.py @@ -0,0 +1,25 @@ + +from pythonforandroid.toolchain import (PythonRecipe, shprint, + current_directory, info, Recipe) +from pythonforandroid.patching import will_build, check_any +import sh +from os.path import join + +class BSoup4Recipe(PythonRecipe): + version = '4.1.0' + url = 'https://www.crummy.com/software/BeautifulSoup/bs4/download/4.0/beautifulsoup4-{version}.tar.gz' + depends = [('python2', 'python3crystax'), 'lxml'] + site_packages_name = 'beautifulsoup4' + call_hostpython_via_targetpython = True + def get_recipe_env(self, arch): + env = super(BSoup4Recipe, self).get_recipe_env(arch) + + + lxml_recipe = Recipe.get_recipe('lxml', self.ctx) + + env['CC'] = env['CC'] + ' -I{lxml_dir}/include -I{lxml_dir}'.format( + lxml_dir=lxml_recipe.get_build_dir(arch)) + + env['LDFLAGS'] = ('-Llxml_dir/lxml/.libs -Llxml_dir/lxml/.libs ').format(lxml_dir=lxml_recipe.get_build_dir(arch)) + +recipe = BSoup4Recipe() \ No newline at end of file diff --git a/pythonforandroid/recipes/libxml2/__init__.py b/pythonforandroid/recipes/libxml2/__init__.py index 14db65a33a..ecb68b7aac 100644 --- a/pythonforandroid/recipes/libxml2/__init__.py +++ b/pythonforandroid/recipes/libxml2/__init__.py @@ -5,8 +5,8 @@ from os.path import join -class Libxml2Recipe(CythonRecipe): - version = '2.9.4' +class Libxml2Recipe(Recipe): + version = '2.9.3' url = 'ftp://xmlsoft.org/libxml2/libxml2-{version}.tar.gz' name = 'libxml2' depends = [('python2', 'python3crystax')] @@ -14,18 +14,9 @@ class Libxml2Recipe(CythonRecipe): def get_recipe_env(self, arch): env = super(Libxml2Recipe, self).get_recipe_env(arch) - try: - sh.sed('runtest\$(EXEEXT) \\/ \\/', 'Makefile') - except: - pass - try: - sh.sed('testrecurse\$(EXEEXT)$//', 'Makefile') - except: - pass - try: - sh.make('-j', '$MAKE_JOBS') - except: - pass + sh.sed('runtest$(EXEEXT) \/ \/', 'Makefile') + sh.sed('testrecurse$(EXEEXT)$//', 'Makefile') + sh.make('-j', '5') recipe = Libxml2Recipe() diff --git a/pythonforandroid/recipes/libxslt/__init__.py b/pythonforandroid/recipes/libxslt/__init__.py new file mode 100644 index 0000000000..0b6957572d --- /dev/null +++ b/pythonforandroid/recipes/libxslt/__init__.py @@ -0,0 +1,23 @@ +from pythonforandroid.toolchain import (CythonRecipe, shprint, + current_directory, info, Recipe) +from pythonforandroid.patching import will_build, check_any +import sh +from os.path import exists,join + +class LibxsltRecipe(CythonRecipe): + version = '1.1.29' + url = 'ftp://xmlsoft.org/libxslt/libxslt-{version}.tar.gz' + name = 'libxslt' + depends = [('python2', 'python3crystax'), 'libxml2'] + patches = ['fix-dlopen.patch'] + + def should_build(self, arch): + return not exists(join(self.get_build_container_dir(arch.arch),"libxslt/.libs/libxslt.a")) + + + def get_recipe_env(self, arch): + env = super(LibxsltRecipe, self).get_recipe_env(arch) + sh.make('-j', '5') + + +recipe = LibxsltRecipe() diff --git a/pythonforandroid/recipes/libxslt/fix-dlopen.patch b/pythonforandroid/recipes/libxslt/fix-dlopen.patch new file mode 100644 index 0000000000..34d56b6e01 --- /dev/null +++ b/pythonforandroid/recipes/libxslt/fix-dlopen.patch @@ -0,0 +1,11 @@ +--- libxslt-1.1.27.orig/python/libxsl.py 2012-09-04 16:26:23.000000000 +0200 ++++ libxslt-1.1.27/python/libxsl.py 2013-07-29 15:11:04.182227378 +0200 +@@ -4,7 +4,7 @@ + # loader to work in that mode if feasible + # + import sys +-if not hasattr(sys,'getdlopenflags'): ++if True: + import libxml2mod + import libxsltmod + import libxml2 diff --git a/pythonforandroid/recipes/lxml/__init__.py b/pythonforandroid/recipes/lxml/__init__.py new file mode 100644 index 0000000000..6a1607c88c --- /dev/null +++ b/pythonforandroid/recipes/lxml/__init__.py @@ -0,0 +1,32 @@ + + +from pythonforandroid.toolchain import (CythonRecipe, shprint, + current_directory, info, Recipe) +from pythonforandroid.patching import will_build, check_any +import sh +from os.path import join + + +class LxmlRecipe(CythonRecipe): + version = '3.7.2' + url = 'https://github.com/lxml/lxml/archive/lxml-{version}.tar.gz' + name = 'lxml' + depends = [('python2', 'python3crystax'), 'libxslt'] + + def get_recipe_env(self, arch): + env = super(LxmlRecipe, self).get_recipe_env(arch) + + libxslt_recipe = Recipe.get_recipe('libxslt', self.ctx) + libxml2_recipe = Recipe.get_recipe('libxml2', self.ctx) + + env['CC'] = env['CC'] + ' -I{libxslt_dir}/include -I{libxslt_dir}'.format( + librslt_dir=libxslt_recipe.get_build_dir(arch)) + + env['LDFLAGS'] = ('-Llibxslt_dir/libxslt/.libs -Llibxslt_dir/libexslt/.libs ' + '-Llibxml2_dir/.libs -Llibxslt_dir/libxslt -Llibxslt_dir/libexslt ' + '-Llibxml2_dir/ ').format(libxslt_dir=libxslt_recipe.get_build_dir(arch), + libxml2_dir=libxml2_recipe.get_build_dir(arch)) + + # env['LDSHARED'] = env['LIBLINK'] # not sure this is necessary in new toolchain + +recipe = LxmlRecipe() diff --git a/pythonforandroid/recipes/requests/__init__.py b/pythonforandroid/recipes/requests/__init__.py index 753f918a85..6d0636eb20 100644 --- a/pythonforandroid/recipes/requests/__init__.py +++ b/pythonforandroid/recipes/requests/__init__.py @@ -1,7 +1,7 @@ from pythonforandroid.toolchain import PythonRecipe class RequestsRecipe(PythonRecipe): - version = '2.9.1' + version = '2.12.3' url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz' depends = ['hostpython2', 'setuptools'] site_packages_name = 'requests' From 9a0579b8558e3b39852c3ebbff5ed0a1afac8667 Mon Sep 17 00:00:00 2001 From: yaki29 Date: Wed, 1 Feb 2017 03:42:57 +0530 Subject: [PATCH 3/6] get_build_dir changed --- pythonforandroid/recipes/libxslt/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/libxslt/__init__.py b/pythonforandroid/recipes/libxslt/__init__.py index 0b6957572d..d87b4a621e 100644 --- a/pythonforandroid/recipes/libxslt/__init__.py +++ b/pythonforandroid/recipes/libxslt/__init__.py @@ -12,7 +12,7 @@ class LibxsltRecipe(CythonRecipe): patches = ['fix-dlopen.patch'] def should_build(self, arch): - return not exists(join(self.get_build_container_dir(arch.arch),"libxslt/.libs/libxslt.a")) + return not exists(join(self.get_build_dir(arch.arch),".libs/libxslt.a")) def get_recipe_env(self, arch): From a65834505658f6a6aebe430beecaa177a0a5c7db Mon Sep 17 00:00:00 2001 From: yaki29 Date: Thu, 2 Feb 2017 03:41:09 +0530 Subject: [PATCH 4/6] BeautifulSoup4 testapp added --- testapps/BeautifulSoup4/main.py | 128 ++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 testapps/BeautifulSoup4/main.py diff --git a/testapps/BeautifulSoup4/main.py b/testapps/BeautifulSoup4/main.py new file mode 100644 index 0000000000..dc458d1719 --- /dev/null +++ b/testapps/BeautifulSoup4/main.py @@ -0,0 +1,128 @@ +from kivy.app import App +from kivy.uix.button import Button +from kivy.uix.textinput import TextInput +from kivy.uix.label import Label +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.gridlayout import GridLayout +from kivy.lang import Builder +from kivy.uix.popup import Popup +from kivy.uix.image import AsyncImage + +import requests +from bs4 import BeautifulSoup + +Builder.load_string( +''' +: + orientation: 'vertical' + Label: + text: "Enter Your movie name buddy" + TextInput: + id: name + font_size: 40 + multiline: False + Button: + text: "show details" + on_press: root.detail(name.text) + +''') +global writer +writer = "Writers:" +global actor +actor = "Actors:" +global director +director = "Directors:" +class PopupScreen(BoxLayout): + def error(self): + popup = Popup(title="ERROR",content=Label(text="Bro, Check your movie name"),size_hint=(0.8,0.8)) + popup.open() + + def Pop(self,movie,imdb,actor,director,writer,url): + wid1 = GridLayout(cols=2,rows=1) + lb = AsyncImage(source=url) + wid1.add_widget(lb) + wid2 = GridLayout(rows=4) + lb = Label(text=imdb) + wid2.add_widget(lb) + + lb = Label(text=actor) + wid2.add_widget(lb) + lb = Label(text=director) + wid2.add_widget(lb) + lb = Label(text=writer) + wid2.add_widget(lb) + + wid1.add_widget(wid2) + popup = Popup(title=movie,content=wid1,size_hint=(0.8,0.8)) + popup.open() + + def detail(self, title): + + global writer + writer = "Writers:" + global actor + actor = "Actors:" + global director + director = "Directors:" + + s="+".join(title.split()) + + + f_url = 'http://www.imdb.com/find?q=' + url=f_url+s+'&s=all' + try: + var = requests.get(url) + soup = BeautifulSoup(var.content) + + x = soup.find("td", {"class": "result_text"}) + m = x.find("a")['href'] + + new_url = 'http://www.imdb.com' + m + content = requests.get(new_url) + soup = BeautifulSoup(content.content) + + img = soup.find("div", {"class":"poster"}) + url = img.findChildren()[1]['src'] + + x = soup.find("div", {"class": "title_wrapper"}) + + c = x.findChildren()[0] + + movie = c.text + + c = soup.find("div", {"class":"ratingValue"}) + + imdb = c.text + + + + for tag in soup.find_all("span", {"itemprop":"director"}): + + + director += tag.text + + + for tag in soup.find_all("span", {"itemprop":"creator"}): + + writer += tag.text + + + + for tag in soup.find_all("span", {"itemprop":"actors"}): + + actor += tag.text + + + + self.Pop(movie,imdb,actor,director,writer,url) + + except Exception: + + self.error() + + +class MovieApp(App): + def build(self): + return PopupScreen() + +MovieApp().run() \ No newline at end of file From dcf8721a9938b79a0a2dc91cbbaaead469e76d6b Mon Sep 17 00:00:00 2001 From: yaki29 Date: Sat, 4 Feb 2017 23:22:46 +0530 Subject: [PATCH 5/6] bs4 testapp modified --- testapps/BeautifulSoup4/main.py | 151 ++++++++++---------------------- 1 file changed, 45 insertions(+), 106 deletions(-) diff --git a/testapps/BeautifulSoup4/main.py b/testapps/BeautifulSoup4/main.py index dc458d1719..14af6aeec9 100644 --- a/testapps/BeautifulSoup4/main.py +++ b/testapps/BeautifulSoup4/main.py @@ -1,128 +1,67 @@ from kivy.app import App -from kivy.uix.button import Button -from kivy.uix.textinput import TextInput -from kivy.uix.label import Label +from kivy.uix.button import Button +from kivy.uix.label import Label from kivy.uix.boxlayout import BoxLayout -from kivy.uix.gridlayout import GridLayout from kivy.lang import Builder from kivy.uix.popup import Popup -from kivy.uix.image import AsyncImage import requests -from bs4 import BeautifulSoup +from bs4 import BeautifulSoup -Builder.load_string( -''' +Builder.load_string(''' : - orientation: 'vertical' - Label: - text: "Enter Your movie name buddy" - TextInput: - id: name - font_size: 40 - multiline: False - Button: - text: "show details" - on_press: root.detail(name.text) - + orientation: 'vertical' + Button: + text: "Show Story" + on_press: root.detail() + size_hint_y: None + height: '40dp' + Label: + id: title + font_size: 30 + size_hint_y: None + height: '50dp' + ScrollView: + Label: + id: story + font_size: 20 + text_size: self.width, None + size_hint_y: None + height: self.texture_size[1] ''') -global writer -writer = "Writers:" -global actor -actor = "Actors:" -global director -director = "Directors:" -class PopupScreen(BoxLayout): - def error(self): - popup = Popup(title="ERROR",content=Label(text="Bro, Check your movie name"),size_hint=(0.8,0.8)) - popup.open() - - def Pop(self,movie,imdb,actor,director,writer,url): - wid1 = GridLayout(cols=2,rows=1) - lb = AsyncImage(source=url) - wid1.add_widget(lb) - wid2 = GridLayout(rows=4) - lb = Label(text=imdb) - wid2.add_widget(lb) - - lb = Label(text=actor) - wid2.add_widget(lb) - lb = Label(text=director) - wid2.add_widget(lb) - lb = Label(text=writer) - wid2.add_widget(lb) - - wid1.add_widget(wid2) - popup = Popup(title=movie,content=wid1,size_hint=(0.8,0.8)) - popup.open() - - def detail(self, title): - - global writer - writer = "Writers:" - global actor - actor = "Actors:" - global director - director = "Directors:" - s="+".join(title.split()) +class PopupScreen(BoxLayout): + def error(self): + popup = Popup(title="ERROR", + content=Label(text="Check Your Network Connection"), + size_hint=(0.8, 0.8)) + popup.open() - f_url = 'http://www.imdb.com/find?q=' - url=f_url+s+'&s=all' - try: - var = requests.get(url) - soup = BeautifulSoup(var.content) - - x = soup.find("td", {"class": "result_text"}) - m = x.find("a")['href'] - - new_url = 'http://www.imdb.com' + m - content = requests.get(new_url) - soup = BeautifulSoup(content.content) - - img = soup.find("div", {"class":"poster"}) - url = img.findChildren()[1]['src'] - - x = soup.find("div", {"class": "title_wrapper"}) - - c = x.findChildren()[0] - - movie = c.text - - c = soup.find("div", {"class":"ratingValue"}) - - imdb = c.text - + def detail(self): - - for tag in soup.find_all("span", {"itemprop":"director"}): - - - director += tag.text + f_url = 'https://httpbin.org/html' + title = self.ids.title + story = self.ids.story + try: + var = requests.get(f_url) - - for tag in soup.find_all("span", {"itemprop":"creator"}): - - writer += tag.text + soup = BeautifulSoup(var.content) + title_find = soup.find("h1") + story_find = soup.find("p") - - for tag in soup.find_all("span", {"itemprop":"actors"}): - - actor += tag.text - - + for x in title_find: + title.text = x + for x in story_find: + story.text = x - self.Pop(movie,imdb,actor,director,writer,url) + except Exception: + self.error() - except Exception: - - self.error() - class MovieApp(App): - def build(self): - return PopupScreen() + def build(self): + return PopupScreen() MovieApp().run() \ No newline at end of file From 3a1728b314da4d3337a30d3c1b04285fcb12c5f7 Mon Sep 17 00:00:00 2001 From: yaki29 Date: Thu, 9 Feb 2017 22:49:02 +0530 Subject: [PATCH 6/6] testapp for libxml2, modified bs4 testapp, libxml2 recipe modified --- .../recipes/beautifulsoup4/__init__.py | 4 +- pythonforandroid/recipes/libxml2/__init__.py | 11 ++- testapps/BeautifulSoup4/main.py | 24 ++---- testapps/libxml2/main.py | 73 +++++++++++++++++++ 4 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 testapps/libxml2/main.py diff --git a/pythonforandroid/recipes/beautifulsoup4/__init__.py b/pythonforandroid/recipes/beautifulsoup4/__init__.py index 65dc374fe1..a09565679a 100644 --- a/pythonforandroid/recipes/beautifulsoup4/__init__.py +++ b/pythonforandroid/recipes/beautifulsoup4/__init__.py @@ -1,11 +1,11 @@ -from pythonforandroid.toolchain import (PythonRecipe, shprint, +from pythonforandroid.toolchain import (CythonRecipe, shprint, current_directory, info, Recipe) from pythonforandroid.patching import will_build, check_any import sh from os.path import join -class BSoup4Recipe(PythonRecipe): +class BSoup4Recipe(CythonRecipe): version = '4.1.0' url = 'https://www.crummy.com/software/BeautifulSoup/bs4/download/4.0/beautifulsoup4-{version}.tar.gz' depends = [('python2', 'python3crystax'), 'lxml'] diff --git a/pythonforandroid/recipes/libxml2/__init__.py b/pythonforandroid/recipes/libxml2/__init__.py index ecb68b7aac..4b90e1dc7e 100644 --- a/pythonforandroid/recipes/libxml2/__init__.py +++ b/pythonforandroid/recipes/libxml2/__init__.py @@ -13,10 +13,15 @@ class Libxml2Recipe(Recipe): def get_recipe_env(self, arch): env = super(Libxml2Recipe, self).get_recipe_env(arch) + return env - sh.sed('runtest$(EXEEXT) \/ \/', 'Makefile') - sh.sed('testrecurse$(EXEEXT)$//', 'Makefile') - sh.make('-j', '5') + def build_arch(self, arch): + env = self.get_recipe_env(arch) + + with current_directory(self.get_build_dir(arch.arch)): + sh.sed('runtest$(EXEEXT)', 'Makefile') + sh.sed('testrecurse$(EXEEXT)', 'Makefile') + sh.make('-j', '5') recipe = Libxml2Recipe() diff --git a/testapps/BeautifulSoup4/main.py b/testapps/BeautifulSoup4/main.py index 14af6aeec9..b80a3d9c3f 100644 --- a/testapps/BeautifulSoup4/main.py +++ b/testapps/BeautifulSoup4/main.py @@ -32,32 +32,24 @@ class PopupScreen(BoxLayout): - def error(self): - popup = Popup(title="ERROR", - content=Label(text="Check Your Network Connection"), - size_hint=(0.8, 0.8)) - popup.open() def detail(self): f_url = 'https://httpbin.org/html' title = self.ids.title story = self.ids.story - try: - var = requests.get(f_url) - soup = BeautifulSoup(var.content) + var = requests.get(f_url) - title_find = soup.find("h1") - story_find = soup.find("p") + soup = BeautifulSoup(var.content) - for x in title_find: - title.text = x - for x in story_find: - story.text = x + title_find = soup.find("h1") + story_find = soup.find("p") - except Exception: - self.error() + for x in title_find: + title.text = x + for x in story_find: + story.text = x class MovieApp(App): diff --git a/testapps/libxml2/main.py b/testapps/libxml2/main.py new file mode 100644 index 0000000000..d8bbf30c51 --- /dev/null +++ b/testapps/libxml2/main.py @@ -0,0 +1,73 @@ +from kivy.app import App +from kivy.uix.button import Button +from kivy.uix.label import Label +from kivy.uix.boxlayout import BoxLayout +from kivy.lang import Builder +from kivy.uix.popup import Popup + +import libxml2 + + +Builder.load_string(''' +: + orientation: 'vertical' + Button: + text: "Show Story" + on_press: root.detail() + size_hint_y: None + height: '40dp' + Label: + id: head + font_size: 30 + size_hint_y: None + height: '50dp' + ScrollView: + Label: + id: str_doc + font_size: 20 + text_size: self.width, None + size_hint_y: None + height: self.texture_size[1] +''') + + +class PopupScreen(BoxLayout): + + def detail(self): + DOC = """ + + + + Christopher Okibgo + + For he was a shrub among the poplars, + + Needing more roots + + More sap to grow to sunlight, + + Thirsting for sunlight + + + + """ + + doc = libxml2.parseDoc(DOC) + + root = doc.children + + # print root + lbl = self.ids.str_doc + head = self.ids.head + + head.text = "Here is the string version of the children of doc" + + lbl.text = str(root) + doc.freeDoc() + + +class MovieApp(App): + def build(self): + return PopupScreen() + +MovieApp().run() \ No newline at end of file