diff --git a/pythonforandroid/recipes/beautifulsoup4/__init__.py b/pythonforandroid/recipes/beautifulsoup4/__init__.py new file mode 100644 index 0000000000..a09565679a --- /dev/null +++ b/pythonforandroid/recipes/beautifulsoup4/__init__.py @@ -0,0 +1,25 @@ + +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(CythonRecipe): + 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 new file mode 100644 index 0000000000..4b90e1dc7e --- /dev/null +++ b/pythonforandroid/recipes/libxml2/__init__.py @@ -0,0 +1,27 @@ +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(Recipe): + version = '2.9.3' + 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) + return env + + 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/pythonforandroid/recipes/libxslt/__init__.py b/pythonforandroid/recipes/libxslt/__init__.py new file mode 100644 index 0000000000..d87b4a621e --- /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_dir(arch.arch),".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 c2a349af16..4b82afa05e 100644 --- a/pythonforandroid/recipes/requests/__init__.py +++ b/pythonforandroid/recipes/requests/__init__.py @@ -1,7 +1,10 @@ from pythonforandroid.toolchain import PythonRecipe class RequestsRecipe(PythonRecipe): + + version = '2.13.0' + url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz' depends = ['hostpython2', 'setuptools'] site_packages_name = 'requests' diff --git a/testapps/BeautifulSoup4/main.py b/testapps/BeautifulSoup4/main.py new file mode 100644 index 0000000000..b80a3d9c3f --- /dev/null +++ b/testapps/BeautifulSoup4/main.py @@ -0,0 +1,59 @@ +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 requests +from bs4 import BeautifulSoup + +Builder.load_string(''' +: + 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] +''') + + +class PopupScreen(BoxLayout): + + def detail(self): + + f_url = 'https://httpbin.org/html' + title = self.ids.title + story = self.ids.story + + var = requests.get(f_url) + + soup = BeautifulSoup(var.content) + + title_find = soup.find("h1") + story_find = soup.find("p") + + for x in title_find: + title.text = x + for x in story_find: + story.text = x + + +class MovieApp(App): + def build(self): + return PopupScreen() + +MovieApp().run() \ No newline at end of file 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