Browse Source

python: update to 3.8

android-5
Leonid Plyushch 5 years ago
parent
commit
a9ce60894f
No known key found for this signature in database GPG Key ID: 45F2964132545795
  1. 57
      packages/python/0001-compileall-Fix-ddir-when-recursing.patch
  2. 16
      packages/python/Lib-pathlib.py.patch
  3. 86
      packages/python/build.sh
  4. 11
      packages/python/distutils-command-build.py.patch
  5. 16
      packages/python/setup.py.patch

57
packages/python/0001-compileall-Fix-ddir-when-recursing.patch

@ -0,0 +1,57 @@
From 84fdbc156ed424d030686de350fbfc6c3593263f Mon Sep 17 00:00:00 2001
Message-Id: <84fdbc156ed424d030686de350fbfc6c3593263f.1537028533.git.jan.steffens@gmail.com>
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Sat, 15 Sep 2018 18:22:06 +0200
Subject: [PATCH] compileall: Fix ddir when recursing
---
Lib/compileall.py | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/Lib/compileall.py b/Lib/compileall.py
index 72592126d7..70e246fd96 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -45,12 +45,16 @@ def _walk_dir(dir, ddir=None, maxlevels=10, quiet=0):
else:
dfile = None
if not os.path.isdir(fullname):
- yield fullname
+ yield fullname, ddir
elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
os.path.isdir(fullname) and not os.path.islink(fullname)):
yield from _walk_dir(fullname, ddir=dfile,
maxlevels=maxlevels - 1, quiet=quiet)
+def _compile_one(file_ddir, *args, **kwargs):
+ file, ddir = file_ddir
+ return compile_file(file, ddir, *args, **kwargs)
+
def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
quiet=0, legacy=False, optimize=-1, workers=1,
invalidation_mode=py_compile.PycInvalidationMode.TIMESTAMP):
@@ -79,17 +83,17 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
workers = workers or None
with ProcessPoolExecutor(max_workers=workers) as executor:
- results = executor.map(partial(compile_file,
- ddir=ddir, force=force,
+ results = executor.map(partial(_compile_one,
+ force=force,
rx=rx, quiet=quiet,
legacy=legacy,
optimize=optimize,
invalidation_mode=invalidation_mode),
files)
success = min(results, default=True)
else:
- for file in files:
- if not compile_file(file, ddir, force, rx, quiet,
+ for file_ddir in files:
+ if not _compile_one(file_ddir, force, rx, quiet,
legacy, optimize, invalidation_mode):
success = False
return success
--
2.18.0

16
packages/python/Lib-pathlib.py.patch

@ -0,0 +1,16 @@
diff -uNr Python-3.8.0/Lib/pathlib.py Python-3.8.0.mod/Lib/pathlib.py
--- Python-3.8.0/Lib/pathlib.py 2019-10-14 16:34:47.000000000 +0300
+++ Python-3.8.0.mod/Lib/pathlib.py 2019-11-17 23:35:51.224429521 +0200
@@ -412,7 +412,11 @@
unlink = os.unlink
- link_to = os.link
+ if hasattr(os, "link"):
+ link_to = os.link
+ else:
+ def link_to(self, src, dst):
+ NotImplementedError("link() not available on this system")
rmdir = os.rmdir

86
packages/python/build.sh

@ -1,12 +1,11 @@
TERMUX_PKG_HOMEPAGE=https://python.org/
TERMUX_PKG_DESCRIPTION="Python 3 programming language intended to enable clear programs"
TERMUX_PKG_LICENSE="PythonPL"
TERMUX_PKG_DEPENDS="libandroid-support, ncurses, readline, libffi, openssl, libutil, libbz2, libsqlite, gdbm, ncurses-ui-libs, libcrypt, liblzma, zlib"
# Python.h includes crypt.h:
_MAJOR_VERSION=3.7
TERMUX_PKG_VERSION=${_MAJOR_VERSION}.5
TERMUX_PKG_SHA256=e85a76ea9f3d6c485ec1780fca4e500725a4a7bbc63c78ebc44170de9b619d94
_MAJOR_VERSION=3.8
TERMUX_PKG_VERSION=${_MAJOR_VERSION}.0
TERMUX_PKG_SRCURL=https://www.python.org/ftp/python/${TERMUX_PKG_VERSION}/Python-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=b356244e13fb5491da890b35b13b2118c3122977c2cd825e3eb6e7d462030d84
TERMUX_PKG_DEPENDS="libandroid-support, ncurses, readline, libffi, openssl, libutil, libbz2, libsqlite, gdbm, ncurses-ui-libs, libcrypt, liblzma, zlib"
# 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]"
@ -53,60 +52,57 @@ termux_step_pre_configure() {
termux_step_post_make_install() {
(cd $TERMUX_PREFIX/bin
ln -sf python${_MAJOR_VERSION}m python${_MAJOR_VERSION}
ln -sf python3 python
ln -sf python3-config python-config
ln -sf pydoc3 pydoc)
ln -sf python${_MAJOR_VERSION} python
ln -sf python${_MAJOR_VERSION}-config python-config
ln -sf pydoc${_MAJOR_VERSION} pydoc)
(cd $TERMUX_PREFIX/share/man/man1
ln -sf python3.1 python.1)
# Save away pyconfig.h so that the python-dev subpackage does not take it.
# It is required by ensurepip so bundled with the main python package.
# Copied back in termux_step_post_massage() after the python-dev package has been built.
mv $TERMUX_PREFIX/include/python${_MAJOR_VERSION}m/pyconfig.h $TERMUX_PKG_TMPDIR/pyconfig.h
ln -sf python${_MAJOR_VERSION}.1 python.1)
}
termux_step_post_massage() {
# Verify that desired modules have been included:
for module in _ssl _bz2 zlib _curses _sqlite3 _lzma; do
if [ ! -f lib/python${_MAJOR_VERSION}/lib-dynload/${module}.*.so ]; then
for module in _bz2 _curses _lzma _sqlite3 _ssl zlib; do
if [ ! -f "${TERMUX_PREFIX}/lib/python${_MAJOR_VERSION}/lib-dynload/${module}".*.so ]; then
termux_error_exit "Python module library $module not built"
fi
done
# Restore pyconfig.h saved away in termux_step_post_make_install() above:
mkdir -p $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/include/python${_MAJOR_VERSION}m/
cp $TERMUX_PKG_TMPDIR/pyconfig.h $TERMUX_PREFIX/include/python${_MAJOR_VERSION}m/
mv $TERMUX_PKG_TMPDIR/pyconfig.h $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/include/python${_MAJOR_VERSION}m/
#FIXME: Is this necessary?
find $TERMUX_PKG_MASSAGEDIR -depth -name __pycache__ -exec rm -rf {} +
}
termux_step_create_debscripts() {
## POST INSTALL:
echo "#!$TERMUX_PREFIX/bin/sh" > postinst
echo 'echo "Setting up pip..."' >> postinst
# Post-installation script for setting up pip.
cat <<- POSTINST_EOF > ./postinst
#!$TERMUX_PREFIX/bin/sh
echo "Setting up pip..."
# Fix historical mistake which removed bin/pip but left site-packages/pip-*.dist-info,
# which causes ensurepip to avoid installing pip due to already existing pip install:
echo "if [ ! -f $TERMUX_PREFIX/bin/pip -a -d $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/site-packages/pip-*.dist-info ]; then rm -Rf $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/site-packages/pip-*.dist-info ; fi" >> postinst
# Setup bin/pip:
echo "$TERMUX_PREFIX/bin/python -m ensurepip --upgrade --default-pip" >> postinst
if [ ! -f "$TERMUX_PREFIX/bin/pip" ]; then
rm -Rf ${TERMUX_PREFIX}/lib/python${_MAJOR_VERSION}/site-packages/pip-*.dist-info
fi
${TERMUX_PREFIX}/bin/python3 -m ensurepip --upgrade --default-pip
exit 0
POSTINST_EOF
# Pre-rm script to cleanup runtime-generated files.
cat <<- PRERM_EOF > ./prerm
#!$TERMUX_PREFIX/bin/sh
if [ "\$1" != "remove" ]; then
exit 0
fi
echo "Uninstalling python modules..."
pip3 freeze 2>/dev/null | xargs pip3 uninstall -y >/dev/null 2>/dev/null
rm -f $TERMUX_PREFIX/bin/pip $TERMUX_PREFIX/bin/pip3* $TERMUX_PREFIX/bin/easy_install $TERMUX_PREFIX/bin/easy_install-3*
echo "Deleting remaining files from site-packages..."
rm -Rf $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/site-packages/*
## PRE RM:
# Avoid running on update
echo "#!$TERMUX_PREFIX/bin/sh" > prerm:
echo 'if [ $1 != "remove" ]; then exit 0; fi' >> prerm
# Uninstall everything installed through pip:
echo "pip freeze 2> /dev/null | xargs pip uninstall -y > /dev/null 2> /dev/null" >> prerm
# Cleanup __pycache__ folders:
echo "find $TERMUX_PREFIX/lib/python${_MAJOR_VERSION} -depth -name __pycache__ -exec rm -rf {} +" >> prerm
# Remove contents of site-packages/ folder:
echo "rm -Rf $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/site-packages/*" >> prerm
# Remove pip and easy_install installed by ensurepip in postinst:
echo "rm -f $TERMUX_PREFIX/bin/pip $TERMUX_PREFIX/bin/pip3* $TERMUX_PREFIX/bin/easy_install $TERMUX_PREFIX/bin/easy_install-3*" >> prerm
exit 0
PRERM_EOF
echo "exit 0" >> postinst
echo "exit 0" >> prerm
chmod 0755 postinst prerm
}

11
packages/python/distutils-command-build.py.patch

@ -0,0 +1,11 @@
--- ./Lib/distutils/command/build.py.orig 2019-11-19 23:19:08.878782120 +0000
+++ ./Lib/distutils/command/build.py 2019-11-19 23:19:18.410915201 +0000
@@ -118,7 +118,7 @@
if self.executable is None and sys.executable:
self.executable = os.path.normpath(sys.executable)
-
+ self.parallel = 1
if isinstance(self.parallel, str):
try:
self.parallel = int(self.parallel)

16
packages/python/setup.py.patch

@ -1,13 +1,13 @@
diff -u -r ../Python-3.5.0/setup.py ./setup.py
--- ../Python-3.5.0/setup.py 2015-09-13 07:41:26.000000000 -0400
+++ ./setup.py 2015-11-07 17:31:45.332321322 -0500
@@ -661,7 +663,8 @@
diff -uNr Python-3.8.0/setup.py Python-3.8.0.mod/setup.py
--- Python-3.8.0/setup.py 2019-10-14 16:34:47.000000000 +0300
+++ Python-3.8.0.mod/setup.py 2019-11-17 21:16:46.524157731 +0200
@@ -824,7 +824,8 @@
# Lance Ellinghaus's syslog module
# syslog daemon interface
- exts.append( Extension('syslog', ['syslogmodule.c']) )
- self.add(Extension('syslog', ['syslogmodule.c']))
+ # Termux: Add 'log' android library since we use android logging:
+ exts.append( Extension('syslog', ['syslogmodule.c'], libraries=['log']) )
+ self.add(Extension('syslog', ['syslogmodule.c'], libraries=['log']))
#
# Here ends the simple stuff. From here on, modules need certain
# Python interface to subinterpreter C-API.
self.add(Extension('_xxsubinterpreters', ['_xxsubinterpretersmodule.c']))

Loading…
Cancel
Save