python now compiles for all arch \o/

This commit is contained in:
Mathieu Virbel 2015-02-03 18:42:17 +01:00
parent d4c1ac88d7
commit bfd8532e0e
5 changed files with 101 additions and 36 deletions
recipes/python

View file

@ -7,6 +7,7 @@ class PythonRecipe(Recipe):
version = "2.7.1"
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2"
depends = ["hostpython", "libffi", ]
library = "libpython2.7.a"
def prebuild_arch(self, arch):
# common to all archs
@ -24,24 +25,7 @@ class PythonRecipe(Recipe):
self.set_marker("patched")
def build_arch(self, arch):
build_env = self.ctx.env.copy()
build_env["CC"] = sh.xcrun("-find", "-sdk", arch.sdk, "clang").strip()
build_env["AR"] = sh.xcrun("-find", "-sdk", arch.sdk, "ar").strip()
build_env["LD"] = sh.xcrun("-find", "-sdk", arch.sdk, "ld").strip()
build_env["CFLAGS"] = " ".join([
"-arch", arch.arch,
"-pipe", "-no-cpp-precomp",
"-isysroot", arch.sysroot,
"-O3",
"-miphoneos-version-min={}".format(arch.version_min)])
build_env["LDFLAGS"] = " ".join([
"-arch", arch.arch,
"-undefined dynamic_lookup",
"-Lextralibs/",
"-lsqlite3",
"-isysroot", arch.sysroot])
build_env = arch.get_env()
configure = sh.Command(join(self.build_dir, "configure"))
shprint(configure,
"CC={}".format(build_env["CC"]),
@ -54,7 +38,8 @@ class PythonRecipe(Recipe):
"--prefix=/python",
"--without-doc-strings",
_env=build_env)
self.apply_patch("pyconfig.patch")
self._patch_pyconfig()
self.apply_patch("ctypes_duplicate.patch")
shprint(sh.make, "-j4",
@ -62,5 +47,40 @@ class PythonRecipe(Recipe):
"HOSTPYTHON={}".format(self.ctx.hostpython),
"HOSTPGEN={}".format(self.ctx.hostpgen))
def _patch_pyconfig(self):
# patch pyconfig to remove some functionnalities
# (to have uniform build accross all platfors)
# this was before in a patch itself, but because the different
# architecture can lead to different pyconfig.h, we would need one patch
# per arch. Instead, express here the line we don't want / we want.
pyconfig = join(self.build_dir, "pyconfig.h")
def _remove_line(lines, pattern):
for line in lines[:]:
if pattern in line:
lines.remove(line)
with open(pyconfig) as fd:
lines = fd.readlines()
_remove_line(lines, "#define HAVE_BIND_TEXTDOMAIN_CODESET 1")
_remove_line(lines, "#define HAVE_FINITE 1")
_remove_line(lines, "#define HAVE_FSEEK64 1")
_remove_line(lines, "#define HAVE_FTELL64 1")
_remove_line(lines, "#define HAVE_GAMMA 1")
_remove_line(lines, "#define HAVE_GETHOSTBYNAME_R 1")
_remove_line(lines, "#define HAVE_GETHOSTBYNAME_R_6_ARG 1")
_remove_line(lines, "#define HAVE_GETRESGID 1")
_remove_line(lines, "#define HAVE_GETRESUID 1")
_remove_line(lines, "#define HAVE_GETSPENT 1")
_remove_line(lines, "#define HAVE_GETSPNAM 1")
_remove_line(lines, "#define HAVE_MREMAP 1")
_remove_line(lines, "#define HAVE_PLOCK 1")
_remove_line(lines, "#define HAVE_SEM_TIMEDWAIT 1")
_remove_line(lines, "#define HAVE_SETRESGID 1")
_remove_line(lines, "#define HAVE_SETRESUID 1")
_remove_line(lines, "#define HAVE_TMPNAM_R 1")
_remove_line(lines, "#define HAVE__GETPTY 1")
lines.append("#define HAVE_GETHOSTBYNAME 1\n")
with open(pyconfig, "wb") as fd:
fd.writelines(lines)
recipe = PythonRecipe()