Skip to content

recipe for libxml2 #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pythonforandroid/recipes/beautifulsoup4/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
27 changes: 27 additions & 0 deletions pythonforandroid/recipes/libxml2/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
23 changes: 23 additions & 0 deletions pythonforandroid/recipes/libxslt/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
11 changes: 11 additions & 0 deletions pythonforandroid/recipes/libxslt/fix-dlopen.patch
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions pythonforandroid/recipes/lxml/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 3 additions & 0 deletions pythonforandroid/recipes/requests/__init__.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
59 changes: 59 additions & 0 deletions testapps/BeautifulSoup4/main.py
Original file line number Diff line number Diff line change
@@ -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('''
<PopupScreen>:
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()
73 changes: 73 additions & 0 deletions testapps/libxml2/main.py
Original file line number Diff line number Diff line change
@@ -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('''
<PopupScreen>:
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 = """<?xml version="1.0" encoding="UTF-8"?>

<verse>

<attribution>Christopher Okibgo</attribution>

<line>For he was a shrub among the poplars,</line>

<line>Needing more roots</line>

<line>More sap to grow to sunlight,</line>

<line>Thirsting for sunlight</line>

</verse>

"""

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()