Python 2.7.13 support based on https://github.com/kivy/kivy-ios/pull/242
This commit is contained in:
parent
822c712956
commit
45b97ea28e
17 changed files with 240 additions and 204 deletions
|
@ -8,7 +8,7 @@
|
|||
#_symtable symtablemodule.c
|
||||
array arraymodule.c # array objects
|
||||
cmath cmathmodule.c # -lm # complex math library functions
|
||||
math mathmodule.c # -lm # math library functions, e.g. sin()
|
||||
math _math.c mathmodule.c # -lm # math library functions, e.g. sin()
|
||||
_struct _struct.c # binary structure packing/unpacking
|
||||
time timemodule.c # -lm # time operations and variables
|
||||
operator operator.c # operator.add() and similar goodies
|
||||
|
|
|
@ -5,8 +5,8 @@ import os
|
|||
|
||||
|
||||
class PythonRecipe(Recipe):
|
||||
version = "2.7.1"
|
||||
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2"
|
||||
version = "2.7.13"
|
||||
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tgz"
|
||||
depends = ["hostpython", "libffi", ]
|
||||
optional_depends = ["openssl"]
|
||||
library = "libpython2.7.a"
|
||||
|
@ -15,7 +15,6 @@ class PythonRecipe(Recipe):
|
|||
def init_with_ctx(self, ctx):
|
||||
super(PythonRecipe, self).init_with_ctx(ctx)
|
||||
self.ctx.python_ver_dir = "python2.7"
|
||||
self.ctx.python_prefix = join(ctx.dist_dir, "root", "python")
|
||||
self.ctx.site_packages_dir = join(
|
||||
ctx.dist_dir, "root", "python", "lib", ctx.python_ver_dir,
|
||||
"site-packages")
|
||||
|
@ -31,36 +30,41 @@ class PythonRecipe(Recipe):
|
|||
self.copy_file("_scproxy.py", "Lib/_scproxy.py")
|
||||
self.apply_patch("xcompile.patch")
|
||||
self.apply_patch("setuppath.patch")
|
||||
self.apply_patch("posixmodule.patch")
|
||||
self.append_file("ModulesSetup.mobile", "Modules/Setup.local")
|
||||
self.apply_patch("ipv6.patch")
|
||||
if "openssl.build_all" in self.ctx.state:
|
||||
self.append_file("ModulesSetup.openssl", "Modules/Setup.local")
|
||||
self.apply_patch("posixmodule.patch")
|
||||
|
||||
self.set_marker("patched")
|
||||
|
||||
def build_arch(self, arch):
|
||||
build_env = arch.get_env()
|
||||
configure = sh.Command(join(self.build_dir, "configure"))
|
||||
local_arch = arch.arch
|
||||
if arch.arch == "arm64" :
|
||||
local_arch = "aarch64"
|
||||
shprint(configure,
|
||||
"CC={}".format(build_env["CC"]),
|
||||
"LD={}".format(build_env["LD"]),
|
||||
"CFLAGS={}".format(build_env["CFLAGS"]),
|
||||
"LDFLAGS={} -undefined dynamic_lookup".format(build_env["LDFLAGS"]),
|
||||
"ac_cv_file__dev_ptmx=no",
|
||||
"ac_cv_file__dev_ptc=no",
|
||||
"--without-pymalloc",
|
||||
"--disable-toolbox-glue",
|
||||
"--host={}-apple-darwin".format(arch),
|
||||
"--host={}-apple-darwin".format(local_arch),
|
||||
"--build=x86_64-apple-darwin16.4.0",
|
||||
"--prefix=/python",
|
||||
"--enable-ipv6",
|
||||
"--with-system-ffi",
|
||||
"--without-doc-strings",
|
||||
"--enable-ipv6",
|
||||
_env=build_env)
|
||||
|
||||
self._patch_pyconfig()
|
||||
self.apply_patch("random.patch")
|
||||
self.apply_patch("ctypes_duplicate.patch")
|
||||
self.apply_patch("ctypes_duplicate_longdouble.patch")
|
||||
|
||||
shprint(sh.make, self.ctx.concurrent_make,
|
||||
shprint(sh.make, "-j4",
|
||||
"CROSS_COMPILE_TARGET=yes",
|
||||
"HOSTPYTHON={}".format(self.ctx.hostpython),
|
||||
"HOSTPGEN={}".format(self.ctx.hostpgen))
|
||||
|
@ -70,7 +74,7 @@ class PythonRecipe(Recipe):
|
|||
build_env = arch.get_env()
|
||||
build_dir = self.get_build_dir(arch.arch)
|
||||
build_env["PATH"] = os.environ["PATH"]
|
||||
shprint(sh.make, self.ctx.concurrent_make,
|
||||
shprint(sh.make,
|
||||
"-C", build_dir,
|
||||
"install",
|
||||
"CROSS_COMPILE_TARGET=yes",
|
||||
|
@ -90,7 +94,7 @@ class PythonRecipe(Recipe):
|
|||
for line in lines[:]:
|
||||
if pattern in line:
|
||||
lines.remove(line)
|
||||
with open(pyconfig, "r") as fd:
|
||||
with open(pyconfig) as fd:
|
||||
lines = fd.readlines()
|
||||
_remove_line(lines, "#define HAVE_BIND_TEXTDOMAIN_CODESET 1")
|
||||
_remove_line(lines, "#define HAVE_FINITE 1")
|
||||
|
@ -111,7 +115,7 @@ class PythonRecipe(Recipe):
|
|||
_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, "w") as fd:
|
||||
with open(pyconfig, "wb") as fd:
|
||||
fd.writelines(lines)
|
||||
|
||||
def reduce_python(self):
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
--- Python2.7-old/Modules/_ctypes/cfield.c 2010-05-09 16:46:46.000000000 +0200
|
||||
+++ Python2.7-new/Modules/_ctypes/cfield.c 2013-08-27 00:21:15.000000000 +0200
|
||||
@@ -1747,24 +1747,6 @@
|
||||
--- Python-2.7.13/Modules/_ctypes/cfield.c.orig 2017-03-08 16:42:49.000000000 +0000
|
||||
+++ Python-2.7.13/Modules/_ctypes/cfield.c 2017-03-08 16:52:33.000000000 +0000
|
||||
@@ -1725,32 +1725,12 @@
|
||||
struct _ffi_type **elements;
|
||||
} ffi_type;
|
||||
*/
|
||||
|
||||
-
|
||||
-/* align and size are bogus for void, but they must not be zero */
|
||||
-ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID };
|
||||
-
|
||||
|
@ -13,8 +14,8 @@
|
|||
-ffi_type ffi_type_uint16 = { 2, 2, FFI_TYPE_UINT16 };
|
||||
-ffi_type ffi_type_sint16 = { 2, 2, FFI_TYPE_SINT16 };
|
||||
-
|
||||
-ffi_type ffi_type_uint32 = { 4, 4, FFI_TYPE_UINT32 };
|
||||
-ffi_type ffi_type_sint32 = { 4, 4, FFI_TYPE_SINT32 };
|
||||
-ffi_type ffi_type_uint32 = { 4, INT_ALIGN, FFI_TYPE_UINT32 };
|
||||
-ffi_type ffi_type_sint32 = { 4, INT_ALIGN, FFI_TYPE_SINT32 };
|
||||
-
|
||||
-ffi_type ffi_type_uint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_UINT64 };
|
||||
-ffi_type ffi_type_sint64 = { 8, LONG_LONG_ALIGN, FFI_TYPE_SINT64 };
|
||||
|
@ -22,13 +23,15 @@
|
|||
-ffi_type ffi_type_float = { sizeof(float), FLOAT_ALIGN, FFI_TYPE_FLOAT };
|
||||
-ffi_type ffi_type_double = { sizeof(double), DOUBLE_ALIGN, FFI_TYPE_DOUBLE };
|
||||
-
|
||||
+#if 0
|
||||
#ifdef ffi_type_longdouble
|
||||
#undef ffi_type_longdouble
|
||||
#endif
|
||||
@@ -1772,6 +1754,4 @@
|
||||
/* This is already defined on OSX */
|
||||
ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN,
|
||||
FFI_TYPE_LONGDOUBLE };
|
||||
|
||||
-
|
||||
-ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER };
|
||||
-
|
||||
+#endif
|
||||
/*---------------- EOF ----------------*/
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
diff -Naur Python-2.7.1.orig/Modules/_ctypes/cfield.c Python-2.7.1/Modules/_ctypes/cfield.c
|
||||
--- Python-2.7.1.orig/Modules/_ctypes/cfield.c 2015-02-11 13:00:42.000000000 +0100
|
||||
+++ Python-2.7.1/Modules/_ctypes/cfield.c 2015-02-11 13:01:12.000000000 +0100
|
||||
@@ -1747,11 +1747,12 @@
|
||||
} ffi_type;
|
||||
*/
|
||||
|
||||
+#if 0
|
||||
#ifdef ffi_type_longdouble
|
||||
#undef ffi_type_longdouble
|
||||
#endif
|
||||
/* This is already defined on OSX */
|
||||
ffi_type ffi_type_longdouble = { sizeof(long double), LONGDOUBLE_ALIGN,
|
||||
FFI_TYPE_LONGDOUBLE };
|
||||
-
|
||||
+#endif
|
||||
/*---------------- EOF ----------------*/
|
|
@ -1,15 +1,9 @@
|
|||
Index: Python-2.7.1/Modules/posixmodule.c
|
||||
IDEA additional info:
|
||||
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
|
||||
<+>UTF-8
|
||||
===================================================================
|
||||
--- Python-2.7.1/Modules/posixmodule.c (date 1290868829000)
|
||||
+++ Python-2.7.1/Modules/posixmodule.c (revision )
|
||||
@@ -2644,7 +2644,7 @@
|
||||
#endif
|
||||
--- Python-2.7.13/Modules/posixmodule.c 2016-12-17 21:05:07.000000000 +0100
|
||||
+++ Python-2.7.13-patch/Modules/posixmodule.c 2018-05-31 20:13:42.000000000 +0100
|
||||
@@ -2828,6 +2828,7 @@
|
||||
}
|
||||
|
||||
-
|
||||
|
||||
+#undef HAVE_SYSTEM
|
||||
#ifdef HAVE_SYSTEM
|
||||
PyDoc_STRVAR(posix_system__doc__,
|
||||
|
|
31
recipes/python/random.patch
Normal file
31
recipes/python/random.patch
Normal file
|
@ -0,0 +1,31 @@
|
|||
--- Python-2.7.13/Python/random.c.orig 2017-02-19 13:55:43.000000000 +0000
|
||||
+++ Python-2.7.13/Python/random.c 2017-02-19 13:56:29.000000000 +0000
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <fcntl.h>
|
||||
-#if defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY)
|
||||
+#if defined(HAVE_GETRANDOM)// || defined(HAVE_GETENTROPY)
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -114,7 +114,7 @@
|
||||
|
||||
if (!fatal) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
- res = getentropy(buffer, len);
|
||||
+ res = 0;
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (res < 0) {
|
||||
@@ -123,8 +123,8 @@
|
||||
}
|
||||
}
|
||||
else {
|
||||
- res = getentropy(buffer, len);
|
||||
- if (res < 0)
|
||||
+ res = 0;
|
||||
+ if (res < 0)
|
||||
Py_FatalError("getentropy() failed");
|
||||
}
|
||||
|
|
@ -1,138 +1,28 @@
|
|||
diff -Naur Python-2.7-old/Makefile.pre.in Python-2.7-new/Makefile.pre.in
|
||||
--- Python-2.7-old/Makefile.pre.in 2010-04-11 17:10:46.000000000 -0700
|
||||
+++ Python-2.7-new/Makefile.pre.in 2010-07-09 13:40:47.000000000 -0700
|
||||
@@ -179,6 +179,7 @@
|
||||
|
||||
PYTHON= python$(EXE)
|
||||
BUILDPYTHON= python$(BUILDEXE)
|
||||
+HOSTPYTHON= ./$(BUILDPYTHON)
|
||||
|
||||
# The task to run while instrument when building the profile-opt target
|
||||
PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
|
||||
@@ -212,6 +213,8 @@
|
||||
# Parser
|
||||
PGEN= Parser/pgen$(EXE)
|
||||
|
||||
+HOSTPGEN= $(PGEN)
|
||||
+
|
||||
POBJS= \
|
||||
Parser/acceler.o \
|
||||
Parser/grammar1.o \
|
||||
@@ -404,8 +407,8 @@
|
||||
# Build the shared modules
|
||||
sharedmods: $(BUILDPYTHON)
|
||||
@case $$MAKEFLAGS in \
|
||||
- *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \
|
||||
- *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \
|
||||
+ *s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py -q build;; \
|
||||
+ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' $(HOSTPYTHON) -E $(srcdir)/setup.py build;; \
|
||||
esac
|
||||
|
||||
# Build static library
|
||||
@@ -538,7 +541,7 @@
|
||||
|
||||
$(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
|
||||
-@$(INSTALL) -d Include
|
||||
- -$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
|
||||
+ -$(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
|
||||
|
||||
$(PGEN): $(PGENOBJS)
|
||||
$(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
|
||||
@@ -919,26 +922,26 @@
|
||||
done; \
|
||||
done
|
||||
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
|
||||
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- ./$(BUILDPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST) -f \
|
||||
-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
|
||||
$(DESTDIR)$(LIBDEST)
|
||||
- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- ./$(BUILDPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST) -f \
|
||||
-x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
|
||||
$(DESTDIR)$(LIBDEST)
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- ./$(BUILDPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST)/site-packages -f \
|
||||
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- ./$(BUILDPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
|
||||
-d $(LIBDEST)/site-packages -f \
|
||||
-x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
|
||||
-PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
|
||||
- ./$(BUILDPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
|
||||
+ $(HOSTPYTHON) -Wi -t -c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"
|
||||
|
||||
# Create the PLATDIR source directory, if one wasn't distributed..
|
||||
$(srcdir)/Lib/$(PLATDIR):
|
||||
@@ -1042,8 +1045,10 @@
|
||||
|
||||
# Install the dynamically loadable modules
|
||||
# This goes into $(exec_prefix)
|
||||
-sharedinstall: sharedmods
|
||||
- $(RUNSHARED) ./$(BUILDPYTHON) -E $(srcdir)/setup.py install \
|
||||
+sharedinstall: sharedmods
|
||||
+ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ $(RUNSHARED) $(HOSTPYTHON) -E $(srcdir)/setup.py install \
|
||||
+ --skip-build \
|
||||
--prefix=$(prefix) \
|
||||
--install-scripts=$(BINDIR) \
|
||||
--install-platlib=$(DESTSHARED) \
|
||||
diff -Naur Python-2.7-old/setup.py Python-2.7-new/setup.py
|
||||
--- Python-2.7-old/setup.py 2010-06-27 05:36:16.000000000 -0700
|
||||
+++ Python-2.7-new/setup.py 2010-07-09 13:54:29.000000000 -0700
|
||||
@@ -23,6 +23,10 @@
|
||||
# This global variable is used to hold the list of modules to be disabled.
|
||||
disabled_module_list = []
|
||||
|
||||
+# _ctypes fails to cross-compile due to the libffi configure script.
|
||||
+if os.environ.has_key('PYTHONXCPREFIX'):
|
||||
+ disabled_module_list.append('_ctypes')
|
||||
+
|
||||
def add_dir_to_list(dirlist, dir):
|
||||
"""Add the directory 'dir' to the list 'dirlist' (at the front) if
|
||||
1) 'dir' is not already in 'dirlist'
|
||||
@@ -278,6 +282,14 @@
|
||||
(ext.name, sys.exc_info()[1]))
|
||||
self.failed.append(ext.name)
|
||||
return
|
||||
+
|
||||
+ # Inport check will not work when cross-compiling.
|
||||
+ if os.environ.has_key('PYTHONXCPREFIX'):
|
||||
+ self.announce(
|
||||
+ 'WARNING: skipping inport check for cross-compiled: "%s"' %
|
||||
+ ext.name)
|
||||
+ return
|
||||
+
|
||||
# Workaround for Mac OS X: The Carbon-based modules cannot be
|
||||
# reliably imported into a command-line Python
|
||||
if 'Carbon' in ext.extra_link_args:
|
||||
|
||||
--- Python-2.7Orig/configure 2011-04-29 22:30:59.231331437 +1000
|
||||
+++ Python-2.7/configure 2010-05-29 01:28:47.000000000 +1000
|
||||
@@ -13517,7 +13517,7 @@
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test "$cross_compiling" = yes; then :
|
||||
- ac_cv_have_long_long_format=no
|
||||
+ ac_cv_have_long_long_format="cross -- assuming yes"
|
||||
else
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
@@ -13569,7 +13569,7 @@
|
||||
$as_echo "$ac_cv_have_long_long_format" >&6; }
|
||||
fi
|
||||
|
||||
-if test "$ac_cv_have_long_long_format" = yes
|
||||
+if test "$ac_cv_have_long_long_format" != no
|
||||
then
|
||||
|
||||
$as_echo "#define PY_FORMAT_LONG_LONG \"ll\"" >>confdefs.h
|
||||
|
||||
--- Python-2.7.13/configure.orig 2017-02-08 10:11:52.000000000 +0000
|
||||
+++ Python-2.7.13/configure 2017-02-08 10:15:10.000000000 +0000
|
||||
@@ -3242,6 +3242,9 @@
|
||||
*-*-linux*)
|
||||
ac_sys_system=Linux
|
||||
;;
|
||||
+ *-*-darwin*)
|
||||
+ ac_sys_system=Darwin
|
||||
+ ;;
|
||||
*-*-cygwin*)
|
||||
ac_sys_system=Cygwin
|
||||
;;
|
||||
@@ -3288,6 +3291,15 @@
|
||||
_host_cpu=$host_cpu
|
||||
esac
|
||||
;;
|
||||
+ *-*-darwin*)
|
||||
+ case "$host_cpu" in
|
||||
+ arm*)
|
||||
+ _host_cpu=arm
|
||||
+ ;;
|
||||
+ *)
|
||||
+ _host_cpu=$host_cpu
|
||||
+ esac
|
||||
+ ;;
|
||||
*-*-cygwin*)
|
||||
_host_cpu=
|
||||
;;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue