recipes for pillow, libjpeg, host_setuptools, pkgresources
This commit is contained in:
parent
f353960298
commit
69813cd5da
10 changed files with 116 additions and 267 deletions
Binary file not shown.
21
recipes/host_setuptools/__init__.py
Normal file
21
recipes/host_setuptools/__init__.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
from toolchain import Recipe, shprint
|
||||
from os.path import join, exists
|
||||
import sh
|
||||
import os
|
||||
import fnmatch
|
||||
import shutil
|
||||
|
||||
|
||||
class HostSetuptools(Recipe):
|
||||
depends = ["hostpython"]
|
||||
archs = 'i386'
|
||||
url = ""
|
||||
|
||||
def prebuild_arch(self, arch):
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
sh.curl("-O", "https://bootstrap.pypa.io/ez_setup.py")
|
||||
shprint(hostpython, "./ez_setup.py")
|
||||
|
||||
recipe = HostSetuptools()
|
||||
|
||||
|
|
@ -2,26 +2,17 @@ from toolchain import Recipe, shprint
|
|||
from os.path import join, exists
|
||||
import sh
|
||||
import os
|
||||
import fnmatch
|
||||
import shutil
|
||||
|
||||
|
||||
class JpegRecipe(Recipe):
|
||||
version = "v9a"
|
||||
url = "http://www.ijg.org/files/jpegsrc.{}.tar.gz".format(version)
|
||||
library = "libjpeg.la"
|
||||
url = "http://www.ijg.org/files/jpegsrc.{version}.tar.gz"
|
||||
library = ".libs/libjpeg.a"
|
||||
include_dir = [
|
||||
("jpeglib.h", ""),
|
||||
("cdjpeg.h", ""),
|
||||
("jconfig.h", ""),
|
||||
("jdct.h", ""),
|
||||
("jerror.h", ""),
|
||||
("jinclude.h", ""),
|
||||
("jmemsys.h", ""),
|
||||
("jmorecfg.h", ""),
|
||||
("jpegint.h", ""),
|
||||
("jversion.h", ""),
|
||||
("transupp.h", "")
|
||||
]
|
||||
include_per_arch = True
|
||||
|
||||
|
@ -36,8 +27,7 @@ class JpegRecipe(Recipe):
|
|||
"LDFLAGS={}".format(build_env["LDFLAGS"]),
|
||||
"--prefix=/",
|
||||
"--host={}".format(arch.triple),
|
||||
"--enable-static=yes",
|
||||
"--enable-shared=no")
|
||||
"--disable-shared")
|
||||
shprint(sh.make, "clean")
|
||||
shprint(sh.make)
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
from toolchain import Recipe, shprint
|
||||
from os.path import join, exists
|
||||
import sh
|
||||
import os
|
||||
import fnmatch
|
||||
import shutil
|
||||
|
||||
|
||||
class ZlibRecipe(Recipe):
|
||||
version = "1.2.8"
|
||||
url = "http://liquidtelecom.dl.sourceforge.net/project/libpng/zlib/{version}/zlib-{version}.tar.gz".format(version=version)
|
||||
library = "libz.a"
|
||||
include_dir = [
|
||||
("zlib.h", ""),
|
||||
("crc32.h", ""),
|
||||
("deflate.h", ""),
|
||||
("gzguts.h", ""),
|
||||
("inffast.h", ""),
|
||||
("inffixed.h", ""),
|
||||
("inflate.h", ""),
|
||||
("inftrees.h", ""),
|
||||
("trees.h", ""),
|
||||
("zconf.h", ""),
|
||||
("zutil.h", ""),
|
||||
("contrib/iostream/zfstream.h", "contrib/iostream/"),
|
||||
("contrib/iostream2/zstream.h", "contrib/iostream/"),
|
||||
("contrib/iostream3/zfstream.h", "contrib/iostream/"),
|
||||
("contrib/puff/puff.h", "contrib/puff"),
|
||||
("contrib/minizip/crypt.h", "contrib/minizip"),
|
||||
("contrib/minizip/ioapi.h", "contrib/minizip"),
|
||||
("contrib/minizip/mztools.h", "contrib/minizip"),
|
||||
("contrib/minizip/unzip.h", "contrib/minizip"),
|
||||
("contrib/minizip/zip.h", "contrib/minizip")
|
||||
]
|
||||
include_per_arch = True
|
||||
|
||||
|
||||
def build_arch(self, arch):
|
||||
build_env = arch.get_env()
|
||||
build_env['prefix'] = '/'
|
||||
build_env['CHOST'] = arch.triple
|
||||
configure = sh.Command(join(self.build_dir, "configure"))
|
||||
shprint(configure,
|
||||
"--static",
|
||||
_env=build_env)
|
||||
shprint(sh.make, "clean")
|
||||
shprint(sh.make)
|
||||
|
||||
recipe = ZlibRecipe()
|
||||
|
||||
|
|
@ -7,9 +7,10 @@ import fnmatch
|
|||
|
||||
class PillowRecipe(Recipe):
|
||||
version = "2.7.0"
|
||||
url = "https://github.com/python-pillow/Pillow/archive/{}.zip".format(version)
|
||||
url = "https://github.com/python-pillow/Pillow/archive/{version}.zip"
|
||||
library = "libpil.a"
|
||||
depends = ["libz", "freetype", "libjpeg", "python", "ios"]
|
||||
depends = ["hostpython", "host_setuptools", "pkgresources", "freetype", "libjpeg", "python", "ios"]
|
||||
pbx_libraries = ["libz", "libbz2"]
|
||||
include_per_arch = True
|
||||
|
||||
def get_pil_env(self, arch):
|
||||
|
@ -19,75 +20,22 @@ class PillowRecipe(Recipe):
|
|||
build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink")
|
||||
build_env["ARM_LD"] = build_env["LD"]
|
||||
build_env["ARCH"] = arch.arch
|
||||
#build_env["C_INCLUDE_PATH"] = join(arch.sysroot, "usr", "include")
|
||||
#build_env["LIBRARY_PATH"] = join(arch.sysroot, "usr", "lib")
|
||||
build_env["C_INCLUDE_PATH"] = join(arch.sysroot, "usr", "include")
|
||||
build_env["LIBRARY_PATH"] = join(arch.sysroot, "usr", "lib")
|
||||
build_env["CFLAGS"] = " ".join([
|
||||
"-I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "freetype")) +
|
||||
" -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libjpeg")) +
|
||||
" -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libz"))
|
||||
" -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libjpeg")) +
|
||||
" -arch {}".format(arch.arch)
|
||||
])
|
||||
return build_env
|
||||
|
||||
def _patch_setup(self):
|
||||
# patch setup to remove some functionnalities
|
||||
pyconfig = join(self.build_dir, "setup.py")
|
||||
self.lines = []
|
||||
def _remove_line(pattern, pattern2 = '', replace=False):
|
||||
_lines = []
|
||||
for line in self.lines:
|
||||
if pattern in line:
|
||||
if replace:
|
||||
_lines.append(pattern2)
|
||||
#print 'replacing:\n {}\nwith:\n {} '.format(line, pattern2)
|
||||
continue
|
||||
_lines.append(line)
|
||||
self.lines = _lines
|
||||
|
||||
with open(pyconfig) as fd:
|
||||
self.lines = fd.readlines()
|
||||
|
||||
self.lines.insert(201, ' elif True:\n')
|
||||
self.lines.insert(202, ' pass\n')
|
||||
|
||||
_remove_line(
|
||||
" import _tkinter",
|
||||
pattern2=" _tkinter = None\n",
|
||||
replace=True)
|
||||
_remove_line('_add_directory(library_dirs, "/usr/local/lib")')
|
||||
_remove_line('_add_directory(include_dirs, "/usr/local/include")')
|
||||
_remove_line(
|
||||
'prefix = sysconfig.get_config_var("prefix")',
|
||||
pattern2=' prefix = False\n',
|
||||
replace=True)
|
||||
|
||||
_remove_line('import mp_compile')
|
||||
_remove_line('_add_directory(library_dirs, "/usr/lib")')
|
||||
_remove_line('_add_directory(include_dirs, "/usr/include")')
|
||||
_remove_line('if sys.platform == "darwin":',
|
||||
pattern2 = ' if False:\n', replace=True)
|
||||
_remove_line('zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = webpmux = None',
|
||||
pattern2 = ' zlib = jpeg = tiff = freetype = tcl = tk = lcms = webp = webpmux = None\n',
|
||||
replace=True)
|
||||
with open(pyconfig, "wb") as fd:
|
||||
fd.writelines(self.lines)
|
||||
|
||||
def _prebuild_pil(self, hostpython):
|
||||
sh.curl("-O", "https://bootstrap.pypa.io/ez_setup.py")
|
||||
shprint(hostpython, "./ez_setup.py")
|
||||
|
||||
def build_arch(self, arch):
|
||||
self._patch_setup()
|
||||
self.apply_patch('pil_setup.patch')
|
||||
build_env = self.get_pil_env(arch)
|
||||
#build_dir = self.get_build_dir(arch.arch)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
#build_env["PYTHONHOME"] = hostpython
|
||||
self._prebuild_pil(hostpython)
|
||||
# first try to generate .h
|
||||
try:
|
||||
shprint(hostpython, "setup.py", "build_ext", "-g",
|
||||
_env=build_env)
|
||||
except:
|
||||
pass
|
||||
shprint(hostpython, "setup.py", "build_ext", "-g",
|
||||
_env=build_env)
|
||||
self.biglink()
|
||||
|
@ -98,17 +46,11 @@ class PillowRecipe(Recipe):
|
|||
os.chdir(build_dir)
|
||||
hostpython = sh.Command(self.ctx.hostpython)
|
||||
build_env = self.get_pil_env(arch)
|
||||
dest_dir = join(self.ctx.dist_dir, "root", "python")
|
||||
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
|
||||
shprint(hostpython, "setup.py", "install", "-O2",
|
||||
"--prefix", join(build_dir, "iosbuild"),
|
||||
"--prefix", dest_dir,
|
||||
_env=build_env)
|
||||
dest_dir = join(self.ctx.dist_dir, "root", "python", "lib", "python2.7",
|
||||
"site-packages", "pil")
|
||||
if exists(dest_dir):
|
||||
shutil.rmtree(dest_dir)
|
||||
shutil.copytree(
|
||||
join(build_dir, "iosbuild", "lib",
|
||||
"python2.7", "site-packages", "pil"),
|
||||
dest_dir)
|
||||
|
||||
def biglink(self):
|
||||
dirs = []
|
||||
|
|
60
recipes/pil/pil_setup.patch
Normal file
60
recipes/pil/pil_setup.patch
Normal file
|
@ -0,0 +1,60 @@
|
|||
--- Pillow-2.7.0/setup.py 2014-12-31 20:42:56.000000000 +0530
|
||||
+++ Pillow-2.7.0/setup.py 2015-02-26 19:38:59.000000000 +0530
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
# monkey patch import hook. Even though flake8 says it's not used, it is.
|
||||
# comment this out to disable multi threaded builds.
|
||||
-import mp_compile
|
||||
|
||||
_IMAGING = (
|
||||
"decode", "encode", "map", "display", "outline", "path")
|
||||
@@ -83,7 +82,7 @@
|
||||
return open(file, 'rb').read()
|
||||
|
||||
try:
|
||||
- import _tkinter
|
||||
+ _tkinter = None
|
||||
except (ImportError, OSError):
|
||||
# pypy emits an oserror
|
||||
_tkinter = None
|
||||
@@ -186,7 +185,7 @@
|
||||
for d in os.environ[k].split(os.path.pathsep):
|
||||
_add_directory(library_dirs, d)
|
||||
|
||||
- prefix = sysconfig.get_config_var("prefix")
|
||||
+ prefix = False
|
||||
if prefix:
|
||||
_add_directory(library_dirs, os.path.join(prefix, "lib"))
|
||||
_add_directory(include_dirs, os.path.join(prefix, "include"))
|
||||
@@ -199,7 +198,9 @@
|
||||
_add_directory(library_dirs, os.path.join(
|
||||
"/usr/lib", "python%s" % sys.version[:3], "config"))
|
||||
|
||||
- elif sys.platform == "darwin":
|
||||
+ elif True:
|
||||
+ pass
|
||||
+ if False:
|
||||
# attempt to make sure we pick freetype2 over other versions
|
||||
_add_directory(include_dirs, "/sw/include/freetype2")
|
||||
_add_directory(include_dirs, "/sw/lib/freetype2/include")
|
||||
@@ -346,11 +347,7 @@
|
||||
_add_directory(include_dirs, tcl_dir)
|
||||
|
||||
# standard locations
|
||||
- _add_directory(library_dirs, "/usr/local/lib")
|
||||
- _add_directory(include_dirs, "/usr/local/include")
|
||||
|
||||
- _add_directory(library_dirs, "/usr/lib")
|
||||
- _add_directory(include_dirs, "/usr/include")
|
||||
|
||||
# on Windows, look for the OpenJPEG libraries in the location that
|
||||
# the official installer puts them
|
||||
@@ -575,7 +572,7 @@
|
||||
exts.append(Extension(
|
||||
"PIL._webp", ["_webp.c"], libraries=libs, define_macros=defs))
|
||||
|
||||
- if sys.platform == "darwin":
|
||||
+ if False:
|
||||
# locate Tcl/Tk frameworks
|
||||
frameworks = []
|
||||
framework_roots = [
|
17
recipes/pkgresources/__init__.py
Normal file
17
recipes/pkgresources/__init__.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from toolchain import Recipe, shprint
|
||||
from os.path import join
|
||||
import sh
|
||||
import os
|
||||
|
||||
|
||||
class pkg_resources(Recipe):
|
||||
depends = ["hostpython", "python"]
|
||||
archs = ['i386']
|
||||
url = ""
|
||||
|
||||
def prebuild_arch(self, arch):
|
||||
sh.cp("/Library/Python/2.7/site-packages/pkg_resources.py", join(self.ctx.dist_dir, "root", "python", "lib", "python2.7", "site-packages", "pkg_resources.py"))
|
||||
|
||||
recipe = pkg_resources()
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- Makefile_old 2013-07-12 14:23:38.000000000 +0200
|
||||
+++ Makefile 2013-07-12 14:26:34.000000000 +0200
|
||||
@@ -36,7 +36,7 @@
|
||||
LDLIBS=
|
||||
|
||||
# If using GNU libtool, LIBTOOL references it; if not, LIBTOOL is empty.
|
||||
-LIBTOOL = ./libtool
|
||||
+LIBTOOL =
|
||||
# $(O) expands to "lo" if using libtool, plain "o" if not.
|
||||
# Similarly, $(A) expands to "la" or "a".
|
||||
O = lo
|
|
@ -1,123 +0,0 @@
|
|||
diff -rupN Imaging-1.1.7/_imaging.c Imaging-1.1.7_patched/_imaging.c
|
||||
--- Imaging-1.1.7/_imaging.c 2009-11-02 05:18:48.000000000 -0600
|
||||
+++ Imaging-1.1.7_patched/_imaging.c 2013-10-25 15:07:23.000000000 -0500
|
||||
@@ -71,12 +71,28 @@
|
||||
* See the README file for information on usage and redistribution.
|
||||
*/
|
||||
|
||||
-
|
||||
#include "Python.h"
|
||||
|
||||
#include "Imaging.h"
|
||||
|
||||
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+FILE *fopen$UNIX2003( const char *filename, const char *mode )
|
||||
+{
|
||||
+ return fopen(filename, mode);
|
||||
+}
|
||||
+
|
||||
+size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
|
||||
+{
|
||||
+ return fwrite(a, b, c, d);
|
||||
+}
|
||||
+
|
||||
+ssize_t write$UNIX2003(int a, const void *b, size_t c)
|
||||
+{
|
||||
+ return write(a,b,c);
|
||||
+}
|
||||
+
|
||||
/* Configuration stuff. Feel free to undef things you don't need. */
|
||||
#define WITH_IMAGECHOPS /* ImageChops support */
|
||||
#define WITH_IMAGEDRAW /* ImageDraw support */
|
||||
diff -rupN Imaging-1.1.7/libImaging/Quant.c Imaging-1.1.7_patched/libImaging/Quant.c
|
||||
--- Imaging-1.1.7/libImaging/Quant.c 2009-10-31 20:29:14.000000000 -0500
|
||||
+++ Imaging-1.1.7_patched/libImaging/Quant.c 2013-10-25 15:07:23.000000000 -0500
|
||||
@@ -20,10 +20,15 @@
|
||||
|
||||
#include "Imaging.h"
|
||||
|
||||
+#include <time.h>
|
||||
+clock_t clock$UNIX2003(void)
|
||||
+{
|
||||
+ return clock();
|
||||
+}
|
||||
+
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
-#include <time.h>
|
||||
|
||||
#include "Quant.h"
|
||||
|
||||
@@ -33,6 +38,7 @@
|
||||
|
||||
#define NO_OUTPUT
|
||||
|
||||
+
|
||||
typedef struct {
|
||||
unsigned long scale;
|
||||
} PixelHashData;
|
||||
diff -rupN Imaging-1.1.7/setup.py Imaging-1.1.7_patched/setup.py
|
||||
--- Imaging-1.1.7/setup.py 2009-11-15 10:06:10.000000000 -0600
|
||||
+++ Imaging-1.1.7_patched/setup.py 2013-10-25 15:08:08.000000000 -0500
|
||||
@@ -88,6 +88,7 @@ from distutils.command.build_ext import
|
||||
|
||||
try:
|
||||
import _tkinter
|
||||
+ _tkinter = None
|
||||
except ImportError:
|
||||
_tkinter = None
|
||||
|
||||
@@ -208,11 +209,11 @@ class pil_build_ext(build_ext):
|
||||
add_directory(include_dirs, tcl_dir)
|
||||
|
||||
# standard locations
|
||||
- add_directory(library_dirs, "/usr/local/lib")
|
||||
- add_directory(include_dirs, "/usr/local/include")
|
||||
+ #add_directory(library_dirs, "/usr/local/lib")
|
||||
+ #add_directory(include_dirs, "/usr/local/include")
|
||||
|
||||
- add_directory(library_dirs, "/usr/lib")
|
||||
- add_directory(include_dirs, "/usr/include")
|
||||
+ #add_directory(library_dirs, "/usr/lib")
|
||||
+ #add_directory(include_dirs, "/usr/include")
|
||||
|
||||
#
|
||||
# insert new dirs *before* default libs, to avoid conflicts
|
||||
@@ -283,6 +284,14 @@ class pil_build_ext(build_ext):
|
||||
#
|
||||
# core library
|
||||
|
||||
+
|
||||
+ class feature:
|
||||
+ tiff = tcl = tk = lcms = None
|
||||
+ jpeg="jpeg"
|
||||
+ zlib="zlib"
|
||||
+ freetype="freetype";freetype_version=21
|
||||
+ feature = feature()
|
||||
+
|
||||
files = ["_imaging.c"]
|
||||
for file in IMAGING:
|
||||
files.append(file + ".c")
|
||||
@@ -348,7 +357,7 @@ class pil_build_ext(build_ext):
|
||||
dir = os.path.join(root, "Tk.framework", "Headers")
|
||||
add_directory(self.compiler.include_dirs, dir, 1)
|
||||
break
|
||||
- if frameworks:
|
||||
+ if False and frameworks:
|
||||
exts.append(Extension(
|
||||
"_imagingtk", ["_imagingtk.c", "Tk/tkImaging.c"],
|
||||
extra_compile_args=frameworks, extra_link_args=frameworks
|
||||
@@ -364,7 +373,9 @@ class pil_build_ext(build_ext):
|
||||
exts.append(Extension("_imagingmath", ["_imagingmath.c"]))
|
||||
|
||||
self.extensions[:] = exts
|
||||
-
|
||||
+ print "Extensions:"
|
||||
+ for e in exts:
|
||||
+ print e.name,str(e.sources)
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
#
|
|
@ -365,6 +365,8 @@ class Recipe(object):
|
|||
"""
|
||||
Download an `url` to `outfn`
|
||||
"""
|
||||
if not url:
|
||||
return
|
||||
def report_hook(index, blksize, size):
|
||||
if size <= 0:
|
||||
progression = '{0} bytes'.format(index * blksize)
|
||||
|
@ -387,6 +389,8 @@ class Recipe(object):
|
|||
"""
|
||||
Extract the `filename` into the directory `cwd`.
|
||||
"""
|
||||
if not filename:
|
||||
return
|
||||
print("Extract {} into {}".format(filename, cwd))
|
||||
if filename.endswith(".tgz") or filename.endswith(".tar.gz"):
|
||||
shprint(sh.tar, "-C", cwd, "-xvzf", filename)
|
||||
|
|
Loading…
Reference in a new issue