From 2d2b09716bb076adfa201941e30f2bd17a42e995 Mon Sep 17 00:00:00 2001 From: Robin Becker Date: Mon, 20 Nov 2017 10:25:13 +0000 Subject: [PATCH 1/3] add recipes for pyrxp & reportlab --- pythonforandroid/recipes/pyrxp/__init__.py | 8 ++ .../recipes/reportlab/__init__.py | 38 ++++++++ .../recipes/reportlab/patches/fix-setup.patch | 89 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 pythonforandroid/recipes/pyrxp/__init__.py create mode 100644 pythonforandroid/recipes/reportlab/__init__.py create mode 100644 pythonforandroid/recipes/reportlab/patches/fix-setup.patch diff --git a/pythonforandroid/recipes/pyrxp/__init__.py b/pythonforandroid/recipes/pyrxp/__init__.py new file mode 100644 index 0000000000..2361f1e5fc --- /dev/null +++ b/pythonforandroid/recipes/pyrxp/__init__.py @@ -0,0 +1,8 @@ +from pythonforandroid.toolchain import CompiledComponentsPythonRecipe, warning +class PyRXPURecipe(CompiledComponentsPythonRecipe): + version = '2a02cecc87b9' + url = 'https://bitbucket.org/rptlab/pyrxp/get/{version}.tar.gz' + depends = ['python2'] + patches = [] + +recipe = PyRXPURecipe() diff --git a/pythonforandroid/recipes/reportlab/__init__.py b/pythonforandroid/recipes/reportlab/__init__.py new file mode 100644 index 0000000000..1553c96b63 --- /dev/null +++ b/pythonforandroid/recipes/reportlab/__init__.py @@ -0,0 +1,38 @@ +import os, sh +from pythonforandroid.toolchain import CompiledComponentsPythonRecipe, warning +from pythonforandroid.util import (urlretrieve, current_directory, ensure_dir) +from pythonforandroid.logger import (logger, info, warning, error, debug, shprint, info_main) +class ReportLabRecipe(CompiledComponentsPythonRecipe): + version = 'c088826211ca' + url = 'https://bitbucket.org/rptlab/reportlab/get/{version}.tar.gz' + depends = ['python2','freetype'] + + def prebuild_arch(self, arch): + if not self.is_patched(arch): + super(ReportLabRecipe, self).prebuild_arch(arch) + self.apply_patch('patches/fix-setup.patch',arch.arch) + recipe_dir = self.get_build_dir(arch.arch) + ft = self.get_recipe('freetype',self.ctx) + ft_dir = ft.get_build_dir(arch.arch) + ft_lib_dir = os.environ.get('_FT_LIB_',os.path.join(ft_dir,'objs','.libs')) + ft_inc_dir = os.environ.get('_FT_INC_',os.path.join(ft_dir,'include')) + tmp_dir = os.path.normpath(os.path.join(recipe_dir,"..","..","tmp")) + info('reportlab recipe: recipe_dir={}'.format(recipe_dir)) + info('reportlab recipe: tmp_dir={}'.format(tmp_dir)) + info('reportlab recipe: ft_dir={}'.format(ft_dir)) + info('reportlab recipe: ft_lib_dir={}'.format(ft_lib_dir)) + info('reportlab recipe: ft_inc_dir={}'.format(ft_inc_dir)) + with current_directory(recipe_dir): + sh.ls('-lathr') + ensure_dir(tmp_dir) + pfbfile = os.path.join(tmp_dir,"pfbfer-20070710.zip") + if not os.path.isfile(pfbfile): + sh.wget("http://www.reportlab.com/ftp/pfbfer-20070710.zip", "-O", pfbfile) + sh.unzip("-u", "-d", os.path.join(recipe_dir, "src", "reportlab", "fonts"), pfbfile) + if os.path.isfile("setup.py"): + with open('setup.py','rb') as f: + text = f.read().replace('_FT_LIB_',ft_lib_dir).replace('_FT_INC_',ft_inc_dir) + with open('setup.py','wb') as f: + f.write(text) + +recipe = ReportLabRecipe() diff --git a/pythonforandroid/recipes/reportlab/patches/fix-setup.patch b/pythonforandroid/recipes/reportlab/patches/fix-setup.patch new file mode 100644 index 0000000000..eae3c1ed73 --- /dev/null +++ b/pythonforandroid/recipes/reportlab/patches/fix-setup.patch @@ -0,0 +1,89 @@ +diff -r 9ecdf084933c setup.py +--- a/setup.py Wed May 13 14:09:03 2015 +0100 ++++ b/setup.py Fri May 22 10:14:29 2015 +0100 +@@ -14,8 +14,8 @@ + #no-download-t1-files=yes + #ignore-system-libart=yes + # if used on command line the config values are not used +-dlt1 = not specialOption('--no-download-t1-files') +-isla = specialOption('--ignore-system-libart') ++dlt1 = False ++isla = True + + try: + import configparser +@@ -121,39 +121,6 @@ + else: + P.insert(x, d) + +-class inc_lib_dirs: +- L = None +- I = None +- def __call__(self): +- if self.L is None: +- L = [] +- I = [] +- if platform == "cygwin": +- aDir(L, os.path.join("/usr/lib", "python%s" % sys.version[:3], "config")) +- elif platform == "darwin": +- # attempt to make sure we pick freetype2 over other versions +- aDir(I, "/sw/include/freetype2") +- aDir(I, "/sw/lib/freetype2/include") +- # fink installation directories +- aDir(L, "/sw/lib") +- aDir(I, "/sw/include") +- # darwin ports installation directories +- aDir(L, "/opt/local/lib") +- aDir(I, "/opt/local/include") +- aDir(I, "/usr/local/include") +- aDir(L, "/usr/local/lib") +- aDir(I, "/usr/include") +- aDir(L, "/usr/lib") +- aDir(I, "/usr/include/freetype2") +- prefix = sysconfig.get_config_var("prefix") +- if prefix: +- aDir(L, pjoin(prefix, "lib")) +- aDir(I, pjoin(prefix, "include")) +- self.L=L +- self.I=I +- return self.I,self.L +-inc_lib_dirs=inc_lib_dirs() +- + def getVersionFromCCode(fn): + import re + tag = re.search(r'^#define\s+VERSION\s+"([^"]*)"',open(fn,'r').read(),re.M) +@@ -244,11 +211,7 @@ + ] + + def get_fonts(PACKAGE_DIR, reportlab_files): +- import sys, os, os.path, zipfile, io +- if isPy3: +- import urllib.request as ureq +- else: +- import urllib2 as ureq ++ import os, os.path + rl_dir = PACKAGE_DIR['reportlab'] + if not [x for x in reportlab_files if not os.path.isfile(pjoin(rl_dir,x))]: + infoline("Standard T1 font curves already downloaded") +@@ -257,6 +220,11 @@ + infoline('not downloading T1 font curve files') + return + try: ++ if isPy3: ++ import urllib.request as ureq ++ else: ++ import urllib2 as ureq ++ import zipfile, io + infoline("Downloading standard T1 font curves") + + remotehandle = ureq.urlopen("http://www.reportlab.com/ftp/pfbfer-20070710.zip") +@@ -448,7 +416,8 @@ + FT_LIB_DIR=[FT_LIB_DIR] if FT_LIB_DIR else [] + FT_INC_DIR=config('FREETYPE_PATHS','inc') + FT_INC_DIR=[FT_INC_DIR] if FT_INC_DIR else [] +- I,L=inc_lib_dirs() ++ I=["_FT_INC_"] ++ L=["_FT_LIB_"] + ftv = None + for d in I: + if isfile(pjoin(d, "ft2build.h")): From 9109e2f165350143d396ecb62795b50435126fda Mon Sep 17 00:00:00 2001 From: Robin Becker Date: Mon, 20 Nov 2017 14:50:37 +0000 Subject: [PATCH 2/3] add .patched --- pythonforandroid/recipes/reportlab/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pythonforandroid/recipes/reportlab/__init__.py b/pythonforandroid/recipes/reportlab/__init__.py index 1553c96b63..d50d7ac56e 100644 --- a/pythonforandroid/recipes/reportlab/__init__.py +++ b/pythonforandroid/recipes/reportlab/__init__.py @@ -12,6 +12,7 @@ def prebuild_arch(self, arch): super(ReportLabRecipe, self).prebuild_arch(arch) self.apply_patch('patches/fix-setup.patch',arch.arch) recipe_dir = self.get_build_dir(arch.arch) + shprint(sh.touch, os.path.join(recipe_dir, '.patched')) ft = self.get_recipe('freetype',self.ctx) ft_dir = ft.get_build_dir(arch.arch) ft_lib_dir = os.environ.get('_FT_LIB_',os.path.join(ft_dir,'objs','.libs')) From 6fc4fb95d9569cfa9b90da6020074c2b1144a9ce Mon Sep 17 00:00:00 2001 From: Robin Becker Date: Tue, 21 Nov 2017 09:33:20 +0000 Subject: [PATCH 3/3] add preppy recipe --- pythonforandroid/recipes/preppy/__init__.py | 9 ++++ .../recipes/preppy/fix-setup.patch | 44 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 pythonforandroid/recipes/preppy/__init__.py create mode 100644 pythonforandroid/recipes/preppy/fix-setup.patch diff --git a/pythonforandroid/recipes/preppy/__init__.py b/pythonforandroid/recipes/preppy/__init__.py new file mode 100644 index 0000000000..2c7505adee --- /dev/null +++ b/pythonforandroid/recipes/preppy/__init__.py @@ -0,0 +1,9 @@ +from pythonforandroid.toolchain import PythonRecipe +class PreppyRecipe(PythonRecipe): + version = '27b7085' + url = 'https://bitbucket.org/rptlab/preppy/get/{version}.tar.gz' + depends = [] + patches = ['fix-setup.patch'] + call_hostpython_via_targetpython = False + +recipe = PreppyRecipe() diff --git a/pythonforandroid/recipes/preppy/fix-setup.patch b/pythonforandroid/recipes/preppy/fix-setup.patch new file mode 100644 index 0000000000..400614d3bf --- /dev/null +++ b/pythonforandroid/recipes/preppy/fix-setup.patch @@ -0,0 +1,44 @@ +--- a/setup.py 2017-11-20 13:53:42.000000000 +0000 ++++ b/setup.py 2017-11-20 14:00:44.862203526 +0000 +@@ -15,35 +15,6 @@ + + import preppy + version = preppy.VERSION +- scriptsPath=os.path.join(pkgDir,'build','scripts') +- +- def makeScript(modName): +- try: +- bat=sys.platform in ('win32','amd64') +- scriptPath=os.path.join(scriptsPath,modName+(bat and '.bat' or '')) +- exePath=sys.executable +- f = open(scriptPath,'w') +- try: +- if bat: +- text = '@echo off\nrem startup script for %s-%s\n"%s" -m "%s" %%*\n' % (modName,version,exePath,modName) +- else: +- text = '#!/bin/sh\n#startup script for %s-%s\nexec "%s" -m "%s" $*\n' % (modName,version,exePath,modName) +- f.write(text) +- finally: +- f.close() +- except: +- print('script for %s not created or erroneous' % modName) +- import traceback +- traceback.print_exc(file=sys.stdout) +- return None +- print('Created "%s"' % scriptPath) +- return scriptPath +- +- scripts = [] +- if not os.path.isdir(scriptsPath): os.makedirs(scriptsPath) +- scripts.extend(filter(None,[ +- makeScript('preppy'), +- ])) + + setup(name='preppy', + version=version, +@@ -52,5 +23,4 @@ + author_email='andy@reportlab.com', + url='http://bitbucket.org/rptlab/preppy', + py_modules=['preppy'], +- scripts=scripts, + )