chiark / gitweb /
Add initial python2 package
authorFredrik Fornwall <fredrik@fornwall.net>
Thu, 17 Sep 2015 01:08:59 +0000 (21:08 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Thu, 17 Sep 2015 01:08:59 +0000 (21:08 -0400)
packages/python2/Lib-tempfile.py.patch [new file with mode: 0644]
packages/python2/Makefile.pre.in.patch [new file with mode: 0644]
packages/python2/Modules-pwdmodule.c.patch [new file with mode: 0644]
packages/python2/Python-bltinmodule.c.patch [new file with mode: 0644]
packages/python2/build.sh [new file with mode: 0644]
packages/python2/fix-dlfcn.patch [new file with mode: 0644]
packages/python2/setup.py.patch [new file with mode: 0644]

diff --git a/packages/python2/Lib-tempfile.py.patch b/packages/python2/Lib-tempfile.py.patch
new file mode 100644 (file)
index 0000000..3680134
--- /dev/null
@@ -0,0 +1,12 @@
+diff -u -r ../Python-2.7.10/Lib/tempfile.py ./Lib/tempfile.py
+--- ../Python-2.7.10/Lib/tempfile.py   2015-05-23 12:09:07.000000000 -0400
++++ ./Lib/tempfile.py  2015-09-16 20:45:13.138695050 -0400
+@@ -163,7 +163,7 @@
+     elif _os.name == 'nt':
+         dirlist.extend([ r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ])
+     else:
+-        dirlist.extend([ '/tmp', '/var/tmp', '/usr/tmp' ])
++        dirlist.extend([ '@TERMUX_PREFIX@/tmp' ])
+     # As a last resort, the current directory.
+     try:
diff --git a/packages/python2/Makefile.pre.in.patch b/packages/python2/Makefile.pre.in.patch
new file mode 100644 (file)
index 0000000..c5a3b9b
--- /dev/null
@@ -0,0 +1,32 @@
+diff -u -r ../Python-2.7.10/Makefile.pre.in ./Makefile.pre.in
+--- ../Python-2.7.10/Makefile.pre.in   2015-05-23 12:09:16.000000000 -0400
++++ ./Makefile.pre.in  2015-09-16 20:40:00.390764778 -0400
+@@ -1042,28 +1042,6 @@
+               $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
+                       $(DESTDIR)$(LIBDEST)/distutils/tests ; \
+       fi
+-      PYTHONPATH=$(DESTDIR)$(LIBDEST)  $(RUNSHARED) \
+-              $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
+-              -d $(LIBDEST) -f \
+-              -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
+-              $(DESTDIR)$(LIBDEST)
+-      PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              $(PYTHON_FOR_BUILD) -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) \
+-              $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
+-              -d $(LIBDEST)/site-packages -f \
+-              -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+-      -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
+-              -d $(LIBDEST)/site-packages -f \
+-              -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
+-      -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
+-      -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
+-              $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
+ # Create the PLATDIR source directory, if one wasn't distributed..
+ $(srcdir)/Lib/$(PLATDIR):
diff --git a/packages/python2/Modules-pwdmodule.c.patch b/packages/python2/Modules-pwdmodule.c.patch
new file mode 100644 (file)
index 0000000..ed83b9b
--- /dev/null
@@ -0,0 +1,12 @@
+diff -u -r ../Python-2.7.10/Modules/pwdmodule.c ./Modules/pwdmodule.c
+--- ../Python-2.7.10/Modules/pwdmodule.c       2015-05-23 12:09:20.000000000 -0400
++++ ./Modules/pwdmodule.c      2015-09-16 17:42:37.197613340 -0400
+@@ -75,7 +75,7 @@
+ #endif
+     PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromUid(p->pw_uid));
+     PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromGid(p->pw_gid));
+-#ifdef __VMS
++#if defined (__VMS) || defined(__ANDROID__)
+     SETS(setIndex++, "");
+ #else
+     SETS(setIndex++, p->pw_gecos);
diff --git a/packages/python2/Python-bltinmodule.c.patch b/packages/python2/Python-bltinmodule.c.patch
new file mode 100644 (file)
index 0000000..a12c674
--- /dev/null
@@ -0,0 +1,12 @@
+diff -u -r ../Python-2.7.10/Python/bltinmodule.c ./Python/bltinmodule.c
+--- ../Python-2.7.10/Python/bltinmodule.c      2015-05-23 12:09:24.000000000 -0400
++++ ./Python/bltinmodule.c     2015-09-16 21:01:23.750245871 -0400
+@@ -22,7 +22,7 @@
+ #elif defined(__APPLE__)
+ const char *Py_FileSystemDefaultEncoding = "utf-8";
+ #else
+-const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
++const char *Py_FileSystemDefaultEncoding = "utf-8"; /* use default */
+ #endif
+ /* Forward */
diff --git a/packages/python2/build.sh b/packages/python2/build.sh
new file mode 100644 (file)
index 0000000..0547c77
--- /dev/null
@@ -0,0 +1,71 @@
+TERMUX_PKG_HOMEPAGE=http://python.org/
+TERMUX_PKG_DESCRIPTION="Programming language intended to enable clear programs on both a small and large scale"
+# lib/python3.4/lib-dynload/_ctypes.cpython-34m.so links to ffi
+# openssl for ensurepip
+TERMUX_PKG_DEPENDS="libandroid-support, ncurses, readline, libffi, openssl, libutil"
+TERMUX_PKG_HOSTBUILD=true
+
+_MAJOR_VERSION=2.7
+TERMUX_PKG_VERSION=${_MAJOR_VERSION}.10
+TERMUX_PKG_SRCURL=http://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz
+
+# The flag --with(out)-pymalloc (disable/enable specialized mallocs) is enabled by default and causes m suffix versions of python.
+# Set ac_cv_func_wcsftime=no to avoid errors such as "character U+ca0025 is not in range [U+0000; U+10ffff]"
+# when executing e.g. "from time import time, strftime, localtime; print(strftime(str('%Y-%m-%d %H:%M'), localtime()))"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_func_wcsftime=no"
+# Avoid trying to include <sys/timeb.h> which does not exist on android-21:
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_ftime=no"
+# Avoid trying to use AT_EACCESS which is not defined:
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_faccessat=no"
+# The gethostbyname_r function does not exist on device libc:
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_gethostbyname_r=no"
+# Android does not have langinfo.h:
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_header_langinfo_h=no"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --build=$TERMUX_HOST_TUPLE --disable-ipv6 --with-system-ffi --without-ensurepip"
+
+# Let 2to3 be in the python3 package:
+TERMUX_PKG_RM_AFTER_INSTALL="bin/2to3"
+
+# NOTE: termux_step_host_build may not be called if host build is cached.
+export TERMUX_ORIG_PATH=$PATH
+export PATH=$TERMUX_PKG_HOSTBUILD_DIR:$PATH
+termux_step_host_build () {
+       # We need a host-built Parser/pgen binary, copied into cross-compile build in termux_step_post_configure() below
+       $TERMUX_PKG_SRCDIR/configure
+       make Parser/pgen
+        # We need a python$_MAJOR_VERSION binary to be picked up by configure check:
+       make
+        rm -f python$_MAJOR_VERSION # Remove symlink if already exists to get a newer timestamp
+        ln -s python python$_MAJOR_VERSION
+}
+
+termux_step_post_configure () {
+       cp $TERMUX_PKG_HOSTBUILD_DIR/Parser/pgen $TERMUX_PKG_BUILDDIR/Parser/pgen
+       $TERMUX_TOUCH -d "next hour" $TERMUX_PKG_BUILDDIR/Parser/pgen
+}
+
+termux_step_post_make_install () {
+       # Avoid file clashes with the python (3) package:
+       mv $TERMUX_PREFIX/share/man/man1/{python.1,python2.1}
+       rm $TERMUX_PREFIX/bin/python
+        # Restore path which termux_step_host_build messed with
+        export PATH=$TERMUX_ORIG_PATH
+}
+
+termux_step_create_debscripts () {
+       ## POST INSTALL:
+       echo "echo 'Setting up pip2...'" > postinst
+       echo "$TERMUX_PREFIX/bin/python2 -m ensurepip --upgrade --no-default-pip" >> postinst
+       # Try to update pip, failing silently on e.g. network errors:
+       #echo "$TERMUX_PREFIX/bin/pip2 install --upgrade pip" >> postinst
+       echo "exit 0" >> postinst
+
+       ## PRE RM:
+       echo "pip2 freeze 2> /dev/null | xargs pip2 uninstall -y > /dev/null 2> /dev/null" > prerm
+       # Cleanup __pycache__ folders
+       echo "rm -rf $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/" >> prerm
+       echo "rm -f $TERMUX_PREFIX/bin/pip2*" >> prerm
+       echo "exit 0" >> prerm
+
+       chmod 0755 postinst prerm
+}
diff --git a/packages/python2/fix-dlfcn.patch b/packages/python2/fix-dlfcn.patch
new file mode 100644 (file)
index 0000000..7a685ca
--- /dev/null
@@ -0,0 +1,26 @@
+diff -Naur Python-2.7.2.orig/Lib/plat-linux2/DLFCN.py Python-2.7.2/Lib/plat-linux2/DLFCN.py
+--- Python-2.7.2.orig/Lib/plat-linux2/DLFCN.py 2011-06-11 17:46:24.000000000 +0200
++++ Python-2.7.2/Lib/plat-linux2/DLFCN.py      2013-07-29 16:34:45.318131844 +0200
+@@ -74,10 +74,17 @@
+ # Included from gnu/stubs.h
+ # Included from bits/dlfcn.h
++# PATCHED FOR ANDROID (the only supported symbols are):
++# enum {
++#  RTLD_NOW  = 0,
++#  RTLD_LAZY = 1,
++#  RTLD_LOCAL  = 0,
++#  RTLD_GLOBAL = 2,
++# };
+ RTLD_LAZY = 0x00001
+-RTLD_NOW = 0x00002
+-RTLD_BINDING_MASK = 0x3
+-RTLD_NOLOAD = 0x00004
+-RTLD_GLOBAL = 0x00100
++RTLD_NOW = 0x00000
++RTLD_BINDING_MASK = 0x0
++RTLD_NOLOAD = 0x00000
++RTLD_GLOBAL = 0x00002
+ RTLD_LOCAL = 0
+-RTLD_NODELETE = 0x01000
++RTLD_NODELETE = 0x00000
diff --git a/packages/python2/setup.py.patch b/packages/python2/setup.py.patch
new file mode 100644 (file)
index 0000000..0e01990
--- /dev/null
@@ -0,0 +1,13 @@
+diff -u -r ../Python-2.7.10/setup.py ./setup.py
+--- ../Python-2.7.10/setup.py  2015-05-23 12:09:25.000000000 -0400
++++ ./setup.py 2015-09-16 20:36:19.281639713 -0400
+@@ -294,6 +294,9 @@
+                           (ext.name, sys.exc_info()[1]))
+             self.failed.append(ext.name)
+             return
++
++      return # Skip import check which does not work when cross compiling
++
+         # 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: