Skip to content

add recipes for pyrxp & reportlab #1173

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

Merged
merged 3 commits into from
Nov 25, 2017
Merged
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
9 changes: 9 additions & 0 deletions pythonforandroid/recipes/preppy/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
44 changes: 44 additions & 0 deletions pythonforandroid/recipes/preppy/fix-setup.patch
Original file line number Diff line number Diff line change
@@ -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,
)
8 changes: 8 additions & 0 deletions pythonforandroid/recipes/pyrxp/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
39 changes: 39 additions & 0 deletions pythonforandroid/recipes/reportlab/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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)
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'))
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()
89 changes: 89 additions & 0 deletions pythonforandroid/recipes/reportlab/patches/fix-setup.patch
Original file line number Diff line number Diff line change
@@ -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")):