Python3 pillow recipe (#394)

* Pillow 6.1.0 building for python 3

* Added tiff disabling

* Removed prefix patch

* Removed darwin patch

* Removed standard locations patch

* Removed patch file altogether

* Removed easy_install, renamed to libpillow.a

* Added back destdir prefix

* Switched to python3 directory

* Removed commented code

* Remove pkgresources dependency

* Adde pillow 6.1.0 to docs
This commit is contained in:
Richard Larkin 2019-09-27 23:59:42 +02:00 committed by Mathieu Virbel
parent a2de53bc85
commit 1d01005ba5
5 changed files with 98 additions and 1 deletions

View file

@ -83,6 +83,7 @@ You can list the available recipes and their versions with:
openssl 1.0.2k
photolibrary master
pil 2.8.2
pillow 6.1.0
plyer master
pycrypto 2.6.1
pykka 1.2.1

View file

@ -0,0 +1,35 @@
from toolchain import Recipe, shprint
from os.path import join, exists
import sh
import os
import fnmatch
import shutil
class HostSetuptools3(Recipe):
depends = ["openssl", "hostpython3"]
archs = ["x86_64"]
url = "setuptools"
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")
# Extract setuptools egg and remove .pth files. Otherwise subsequent
# python package installations using setuptools will raise exceptions.
# Setuptools version 28.3.0
site_packages_path = join(
self.ctx.dist_dir, 'hostpython3',
'lib', 'python3.7', 'site-packages')
os.chdir(site_packages_path)
with open('setuptools.pth', 'r') as f:
setuptools_egg_path = f.read().strip('./').strip('\n')
print("setuptools_egg_path=", setuptools_egg_path)
unzip = sh.Command('unzip')
shprint(unzip, "-o", setuptools_egg_path)
os.remove(setuptools_egg_path)
os.remove('setuptools.pth')
os.remove('easy-install.pth')
shutil.rmtree('EGG-INFO')
recipe = HostSetuptools3()

View file

@ -0,0 +1 @@
Make toolchain happy

View file

@ -0,0 +1,60 @@
from toolchain import Recipe, shprint
from os.path import join
import sh
import os
import fnmatch
class PillowRecipe(Recipe):
version = "6.1.0"
url = "https://pypi.python.org/packages/source/P/Pillow/Pillow-{version}.tar.gz"
library = "libpillow.a"
depends = ["hostpython3", "host_setuptools3", "freetype", "libjpeg", "python3", "ios"]
pbx_libraries = ["libz", "libbz2"]
include_per_arch = True
def get_pil_env(self, arch):
build_env = arch.get_env()
build_env["IOSROOT"] = self.ctx.root_dir
build_env["IOSSDKROOT"] = arch.sysroot
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["CFLAGS"] = " ".join([
"-I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "freetype")) +
" -I{}".format(join(self.ctx.dist_dir, "include", arch.arch, "libjpeg")) +
" -arch {}".format(arch.arch)
])
build_env['PATH'] = os.environ['PATH']
return build_env
def build_arch(self, arch):
build_env = self.get_pil_env(arch)
hostpython3 = sh.Command(self.ctx.hostpython)
shprint(hostpython3, "setup.py", "build_ext", "--disable-tiff",
"--disable-webp", "-g", _env=build_env)
self.biglink()
def install(self):
arch = list(self.filtered_archs)[0]
build_dir = self.get_build_dir(arch.arch)
os.chdir(build_dir)
hostpython3 = sh.Command(self.ctx.hostpython)
build_env = self.get_pil_env(arch)
dest_dir = join(self.ctx.dist_dir, "root", "python3")
build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python3.7', 'site-packages')
shprint(hostpython3, "setup.py", "install", "--prefix", dest_dir,
_env=build_env)
def biglink(self):
dirs = []
for root, dirnames, filenames in os.walk(self.build_dir):
if fnmatch.filter(filenames, "*.so.libs"):
dirs.append(root)
cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink"))
shprint(cmd, join(self.build_dir, "libpillow.a"), *dirs)
recipe = PillowRecipe()

View file

@ -714,7 +714,7 @@ class Recipe(object):
def archive_root(self):
key = "{}.archive_root".format(self.name)
value = self.ctx.state.get(key)
if not value:
if not value and self.url != "":
value = self.get_archive_rootdir(self.archive_fn)
if value is not None:
self.ctx.state[key] = value