+
+ # 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
+
+ # This makefile is used by pip to compile C code, and thinks that ${TERMUX_HOST_PLATFORM}-gcc
+ # and other prefixed tools should be used, but we want unprefixed ones.
+ # Also Remove the specs flag since that is default in the gcc Termux package:
+ perl -p -i -e "s|${TERMUX_HOST_PLATFORM}-||g,s|${_SPECSFLAG}||g" $TERMUX_PREFIX/lib/python${_MAJOR_VERSION}/config-${_MAJOR_VERSION}m/Makefile
+}
+
+termux_step_post_massage () {
+ # Restore pyconfig.h saved away in termux_step_post_make_install() above:
+ mkdir -p $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/include/python${_MAJOR_VERSION}m/
+ mv $TERMUX_PKG_TMPDIR/pyconfig.h $TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX/include/python${_MAJOR_VERSION}m/
+}
+
+termux_step_create_debscripts () {
+ ## POST INSTALL:
+ echo "$TERMUX_PREFIX/bin/python -m ensurepip --default-pip > /dev/null" > postinst
+ # Try to update pip, failing silently on e.g. network errors:
+ echo "$TERMUX_PREFIX/bin/pip install --upgrade pip > /dev/null 2> /dev/null" >> postinst
+ echo "exit 0" >> postinst
+
+ ## PRE RM:
+ echo "pip freeze 2> /dev/null | xargs pip uninstall -y > /dev/null 2> /dev/null" > prerm
+ # Cleanup __pycache__ folders
+ echo "rm -rf $TERMUX_PREFIX/lib/python3.4/" >> prerm
+ echo "rm -f $TERMUX_PREFIX/bin/pip $TERMUX_PREFIX/bin/pip3*" >> prerm
+ echo "exit 0" >> prerm
+
+ chmod 0755 postinst prerm