python,python3: export mk files outside of python package dirs
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Wed, 10 Jan 2018 07:29:41 +0000 (09:29 +0200)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Wed, 10 Jan 2018 21:01:51 +0000 (23:01 +0200)
Since `lang/python` is it's own folder of Python packages
(for both Python 2 & 3), and these build rules are needed
in a lot of packages [especially Python packages],
putting them here makes sense architecturally,
to be shared.

This also helps get rid of the `include_mk` construct
which relies on OpenWrt core to provide, and seems
like a broken design idea that has persisted for a while.
Reason is: it requires that Python 2/3 be built to provide
these mk files for other Python packages,
which seems like a bad idea.

Long-term, there could be an issue where some other feeds
would require these mk files [e.g. telephony] for
some Python packages.
We'll see how we handle this a bit later.

For now we limit this to this feed.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
18 files changed:
lang/python/python-host.mk [new file with mode: 0644]
lang/python/python-package-install.sh [new file with mode: 0644]
lang/python/python-package.mk [new file with mode: 0644]
lang/python/python-version.mk [new file with mode: 0644]
lang/python/python/Makefile
lang/python/python/files/python-host.mk [deleted file]
lang/python/python/files/python-package-install.sh [deleted file]
lang/python/python/files/python-package.mk [deleted file]
lang/python/python/files/python-version.mk [deleted file]
lang/python/python3-host.mk [new file with mode: 0644]
lang/python/python3-package-install.sh [new file with mode: 0644]
lang/python/python3-package.mk [new file with mode: 0644]
lang/python/python3-version.mk [new file with mode: 0644]
lang/python/python3/Makefile
lang/python/python3/files/python3-host.mk [deleted file]
lang/python/python3/files/python3-package-install.sh [deleted file]
lang/python/python3/files/python3-package.mk [deleted file]
lang/python/python3/files/python3-version.mk [deleted file]

diff --git a/lang/python/python-host.mk b/lang/python/python-host.mk
new file mode 100644 (file)
index 0000000..d4dc81f
--- /dev/null
@@ -0,0 +1,97 @@
+#
+# Copyright (C) 2015-2016 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
+#       if `python-package.mk` is included, this will already be included
+
+ifneq ($(__python_host_mk_inc),1)
+__python_host_mk_inc=1
+
+# For PYTHON_VERSION
+python_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
+include $(python_mk_path)python-version.mk
+
+HOST_PYTHON_DIR:=$(STAGING_DIR_HOSTPKG)
+HOST_PYTHON_INC_DIR:=$(HOST_PYTHON_DIR)/include/python$(PYTHON_VERSION)
+HOST_PYTHON_LIB_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)
+
+HOST_PYTHON_PKG_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)/site-packages
+
+HOST_PYTHON_BIN:=$(HOST_PYTHON_DIR)/bin/python$(PYTHON_VERSION)
+
+HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(HOST_PYTHON_PKG_DIR)
+
+define HostPython
+       if [ "$(strip $(3))" == "HOST" ]; then \
+               export PYTHONPATH="$(HOST_PYTHONPATH)"; \
+               export PYTHONDONTWRITEBYTECODE=0; \
+       else \
+               export PYTHONPATH="$(PYTHONPATH)"; \
+               export PYTHONDONTWRITEBYTECODE=1; \
+               export _python_sysroot="$(STAGING_DIR)"; \
+               export _python_prefix="/usr"; \
+               export _python_exec_prefix="/usr"; \
+       fi; \
+       export PYTHONOPTIMIZE=""; \
+       $(1) \
+       $(HOST_PYTHON_BIN) $(2);
+endef
+
+define host_python_settings
+       ARCH="$(HOST_ARCH)" \
+       CC="$(HOSTCC)" \
+       CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
+       CXX="$(HOSTCXX)" \
+       LD="$(HOSTCC)" \
+       LDSHARED="$(HOSTCC) -shared" \
+       CFLAGS="$(HOST_CFLAGS)" \
+       CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
+       LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
+       _PYTHON_HOST_PLATFORM=linux2
+endef
+
+# $(1) => commands to execute before running pythons script
+# $(2) => python script and its arguments
+# $(3) => additional variables
+define Build/Compile/HostPyRunHost
+       $(call HostPython, \
+               $(if $(1),$(1);) \
+               $(call host_python_settings) \
+               $(3) \
+               , \
+               $(2) \
+               , \
+               HOST \
+       )
+endef
+
+# Note: I shamelessly copied this from Yousong's logic (from python-packages);
+HOST_PYTHON_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON_VERSION)
+define host_python_pip_install
+       $(call host_python_settings) \
+       $(HOST_PYTHON_PIP) install \
+               --root=$(1) \
+               --prefix=$(2) \
+               --ignore-installed \
+               $(3)
+endef
+
+define host_python_pip_install_host
+$(call host_python_pip_install,$(STAGING_DIR_HOSTPKG),"",$(1))
+endef
+
+# $(1) => build subdir
+# $(2) => additional arguments to setup.py
+# $(3) => additional variables
+define Build/Compile/HostPyMod
+       $(call Build/Compile/HostPyRunHost, \
+               cd $(HOST_BUILD_DIR)/$(strip $(1)), \
+               ./setup.py $(2), \
+               $(3))
+endef
+
+endif # __python_host_mk_inc
diff --git a/lang/python/python-package-install.sh b/lang/python/python-package-install.sh
new file mode 100644 (file)
index 0000000..60c1e27
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+set -e
+
+process_filespec() {
+       local src_dir="$1"
+       local dst_dir="$2"
+       local filespec="$3"
+       echo "$filespec" | (
+       IFS='|'
+       while read fop fspec fperm; do
+               local fop=`echo "$fop" | tr -d ' \t\n'`
+               if [ "$fop" = "+" ]; then
+                       if [ ! -e "${src_dir}${fspec}" ]; then
+                               echo "File not found '${src_dir}${fspec}'"
+                               exit 1
+                       fi
+                       dpath=`dirname "$fspec"`
+                       if [ -z "$fperm" ]; then
+                               dperm=`stat -c "%a" ${src_dir}${dpath}`
+                       fi
+                       mkdir -p -m$dperm ${dst_dir}${dpath}
+                       echo "copying: '$fspec'"
+                       cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/
+                       if [ -n "$fperm" ]; then
+                               chmod -R $fperm ${dst_dir}${fspec}
+                       fi
+               elif [ "$fop" = "-" ]; then
+                       echo "removing: '$fspec'"
+                       rm -fR ${dst_dir}${fspec}
+               elif [ "$fop" = "=" ]; then
+                       echo "setting permissions: '$fperm' on '$fspec'"
+                       chmod -R $fperm ${dst_dir}${fspec}
+               fi
+       done
+       )
+}
+
+src_dir="$1"
+dst_dir="$2"
+python="$3"
+mode="$4"
+filespec="$5"
+
+process_filespec "$src_dir" "$dst_dir" "$filespec" || {
+       echo "process filespec error-ed"
+       exit 1
+}
+
+if [ "$mode" == "sources" ] ; then
+       # Copy only python source files
+       find $dst_dir -not -type d -not -name "*\.py" | xargs rm -f
+
+       # Delete empty folders (if the case)
+       if [ -d "$dst_dir/usr" ] ; then
+               find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
+               rmdir --ignore-fail-on-non-empty $dst_dir/usr
+       fi
+       exit 0
+fi
+
+# XXX [So that you won't goof as I did]
+# Note: Yes, I tried to use the -O & -OO flags here.
+#       However the generated byte-codes were not portable.
+#       So, we just stuck to un-optimized byte-codes,
+#       which is still way better/faster than running
+#       Python sources all the time.
+$python -m compileall -d '/' $dst_dir || {
+       echo "python -m compileall err-ed"
+       exit 1
+}
+
+# Delete source files and pyc [ un-optimized bytecode files ]
+# We may want to make this optimization thing configurable later, but not sure atm
+find $dst_dir -type f -name "*\.py" | xargs rm -f
+
+# Delete empty folders (if the case)
+if [ -d "$dst_dir/usr" ] ; then
+       find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
+       rmdir --ignore-fail-on-non-empty $dst_dir/usr
+fi
+
+exit 0
diff --git a/lang/python/python-package.mk b/lang/python/python-package.mk
new file mode 100644 (file)
index 0000000..2bcae91
--- /dev/null
@@ -0,0 +1,145 @@
+#
+# Copyright (C) 2006-2016 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
+
+python_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
+include $(python_mk_path)python-host.mk
+
+PYTHON_DIR:=$(STAGING_DIR)/usr
+PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
+PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
+PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
+
+PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
+
+PYTHON:=python$(PYTHON_VERSION)
+
+PYTHONPATH:=$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
+
+# These configure args are needed in detection of path to Python header files
+# using autotools.
+CONFIGURE_ARGS += \
+       _python_sysroot="$(STAGING_DIR)" \
+       _python_prefix="/usr" \
+       _python_exec_prefix="/usr"
+
+PKG_USE_MIPS16:=0
+# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
+# flags are inherited from the Python base package (via sysconfig module)
+ifdef CONFIG_USE_MIPS16
+  TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
+endif
+
+define PyPackage
+
+  define Package/$(1)-src
+    $(call Package/$(1))
+    TITLE+= (sources)
+    DEPENDS:=$$$$(foreach dep,$$$$(filter +python-%,$$$$(DEPENDS)),$$$$(dep)-src)
+  endef
+
+  define Package/$(1)-src/description
+    $(call Package/$(1)/description).
+    (Contains the Python sources for this package).
+  endef
+
+  # Add default PyPackage filespec none defined
+  ifndef PyPackage/$(1)/filespec
+    define PyPackage/$(1)/filespec
+      +|$(PYTHON_PKG_DIR)
+    endef
+  endif
+
+  ifndef PyPackage/$(1)/install
+    define PyPackage/$(1)/install
+               if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
+                       $(INSTALL_DIR) $$(1)/usr/bin ; \
+                       $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \
+               fi
+    endef
+  endif
+
+  ifndef Package/$(1)/install
+  $(call shexport,PyPackage/$(1)/filespec)
+
+  define Package/$(1)/install
+       $(call PyPackage/$(1)/install,$$(1))
+       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
+       if [ -e files/python-package-install.sh ] ; then \
+               $(SHELL) files/python-package-install.sh \
+                       "$(PKG_INSTALL_DIR)" "$$(1)" \
+                       "$(HOST_PYTHON_BIN)" "$$(2)" \
+                       "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" ; \
+       elif [ -e $(STAGING_DIR)/mk/python-package-install.sh ] ; then \
+               $(SHELL) $(STAGING_DIR)/mk/python-package-install.sh \
+                       "$(PKG_INSTALL_DIR)" "$$(1)" \
+                       "$(HOST_PYTHON_BIN)" "$$(2)" \
+                       "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" ; \
+       else \
+               echo "No 'python-package-install.sh' script found" ; \
+               exit 1 ; \
+       fi
+  endef
+
+  define Package/$(1)-src/install
+       $$(call Package/$(1)/install,$$(1),sources)
+  endef
+  endif # Package/$(1)/install
+endef
+
+# $(1) => commands to execute before running pythons script
+# $(2) => python script and its arguments
+# $(3) => additional variables
+define Build/Compile/HostPyRunTarget
+       $(call HostPython, \
+               $(if $(1),$(1);) \
+               CC="$(TARGET_CC)" \
+               CCSHARED="$(TARGET_CC) $(FPIC)" \
+               CXX="$(TARGET_CXX)" \
+               LD="$(TARGET_CC)" \
+               LDSHARED="$(TARGET_CC) -shared" \
+               CFLAGS="$(TARGET_CFLAGS)" \
+               CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON_INC_DIR)" \
+               LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON_VERSION)" \
+               _PYTHON_HOST_PLATFORM=linux2 \
+               __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
+               $(3) \
+               , \
+               $(2) \
+       )
+endef
+
+# $(1) => build subdir
+# $(2) => additional arguments to setup.py
+# $(3) => additional variables
+define Build/Compile/PyMod
+       $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
+       $(call Build/Compile/HostPyRunTarget, \
+               cd $(PKG_BUILD_DIR)/$(strip $(1)), \
+               ./setup.py $(2), \
+               $(3))
+       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
+endef
+
+define PyBuild/Compile/Default
+       $(foreach pkg,$(HOST_PYTHON_PACKAGE_BUILD_DEPENDS),
+               $(call host_python_pip_install_host,$(pkg))
+       )
+       $(call Build/Compile/PyMod,, \
+               install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
+               --single-version-externally-managed \
+       )
+endef
+
+PyBuild/Compile=$(PyBuild/Compile/Default)
+
+ifeq ($(BUILD_VARIANT),python)
+define Build/Compile
+       $(call PyBuild/Compile)
+endef
+endif # python
diff --git a/lang/python/python-version.mk b/lang/python/python-version.mk
new file mode 100644 (file)
index 0000000..200461d
--- /dev/null
@@ -0,0 +1,13 @@
+#
+# Copyright (C) 2016 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+PYTHON_VERSION:=2.7
+PYTHON_VERSION_MICRO:=14
+
+PYTHON_SETUPTOOLS_VERSION:=28.8.0
+PYTHON_PIP_VERSION:=9.0.1
+
index 3c7b3bf6ce76908b5dcc704e0c8271a909fed1e1..84415d6bf868e44182b2cd7beccc89efd9d9d983 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 # For PYTHON_VERSION
-include ./files/python-version.mk
+include ../python-version.mk
 
 PKG_NAME:=python
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
@@ -22,10 +22,10 @@ PKG_LICENSE:=PSF
 PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
 
 # This file provides the necsessary host build variables
-include ./files/python-host.mk
+include ../python-host.mk
 
 # For PyPackage
-include ./files/python-package.mk
+include ../python-package.mk
 
 PKG_FIXUP:=autoreconf
 PKG_INSTALL:=1
diff --git a/lang/python/python/files/python-host.mk b/lang/python/python/files/python-host.mk
deleted file mode 100644 (file)
index e836eae..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# Copyright (C) 2015-2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-ifneq ($(__python_host_mk_inc),1)
-__python_host_mk_inc=1
-
-# For PYTHON_VERSION
-$(call include_mk, python-version.mk)
-
-HOST_PYTHON_DIR:=$(STAGING_DIR_HOSTPKG)
-HOST_PYTHON_INC_DIR:=$(HOST_PYTHON_DIR)/include/python$(PYTHON_VERSION)
-HOST_PYTHON_LIB_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)
-
-HOST_PYTHON_PKG_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)/site-packages
-
-HOST_PYTHON_BIN:=$(HOST_PYTHON_DIR)/bin/python$(PYTHON_VERSION)
-
-HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(HOST_PYTHON_PKG_DIR)
-
-define HostPython
-       if [ "$(strip $(3))" == "HOST" ]; then \
-               export PYTHONPATH="$(HOST_PYTHONPATH)"; \
-               export PYTHONDONTWRITEBYTECODE=0; \
-       else \
-               export PYTHONPATH="$(PYTHONPATH)"; \
-               export PYTHONDONTWRITEBYTECODE=1; \
-               export _python_sysroot="$(STAGING_DIR)"; \
-               export _python_prefix="/usr"; \
-               export _python_exec_prefix="/usr"; \
-       fi; \
-       export PYTHONOPTIMIZE=""; \
-       $(1) \
-       $(HOST_PYTHON_BIN) $(2);
-endef
-
-define host_python_settings
-       ARCH="$(HOST_ARCH)" \
-       CC="$(HOSTCC)" \
-       CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
-       CXX="$(HOSTCXX)" \
-       LD="$(HOSTCC)" \
-       LDSHARED="$(HOSTCC) -shared" \
-       CFLAGS="$(HOST_CFLAGS)" \
-       CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON_INC_DIR)" \
-       LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
-       _PYTHON_HOST_PLATFORM=linux2
-endef
-
-# $(1) => commands to execute before running pythons script
-# $(2) => python script and its arguments
-# $(3) => additional variables
-define Build/Compile/HostPyRunHost
-       $(call HostPython, \
-               $(if $(1),$(1);) \
-               $(call host_python_settings) \
-               $(3) \
-               , \
-               $(2) \
-               , \
-               HOST \
-       )
-endef
-
-# Note: I shamelessly copied this from Yousong's logic (from python-packages);
-HOST_PYTHON_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON_VERSION)
-define host_python_pip_install
-       $(call host_python_settings) \
-       $(HOST_PYTHON_PIP) install \
-               --root=$(1) \
-               --prefix=$(2) \
-               --ignore-installed \
-               $(3)
-endef
-
-define host_python_pip_install_host
-$(call host_python_pip_install,$(STAGING_DIR_HOSTPKG),"",$(1))
-endef
-
-# $(1) => build subdir
-# $(2) => additional arguments to setup.py
-# $(3) => additional variables
-define Build/Compile/HostPyMod
-       $(call Build/Compile/HostPyRunHost, \
-               cd $(HOST_BUILD_DIR)/$(strip $(1)), \
-               ./setup.py $(2), \
-               $(3))
-endef
-
-endif # __python_host_mk_inc
diff --git a/lang/python/python/files/python-package-install.sh b/lang/python/python/files/python-package-install.sh
deleted file mode 100644 (file)
index 60c1e27..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-set -e
-
-process_filespec() {
-       local src_dir="$1"
-       local dst_dir="$2"
-       local filespec="$3"
-       echo "$filespec" | (
-       IFS='|'
-       while read fop fspec fperm; do
-               local fop=`echo "$fop" | tr -d ' \t\n'`
-               if [ "$fop" = "+" ]; then
-                       if [ ! -e "${src_dir}${fspec}" ]; then
-                               echo "File not found '${src_dir}${fspec}'"
-                               exit 1
-                       fi
-                       dpath=`dirname "$fspec"`
-                       if [ -z "$fperm" ]; then
-                               dperm=`stat -c "%a" ${src_dir}${dpath}`
-                       fi
-                       mkdir -p -m$dperm ${dst_dir}${dpath}
-                       echo "copying: '$fspec'"
-                       cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/
-                       if [ -n "$fperm" ]; then
-                               chmod -R $fperm ${dst_dir}${fspec}
-                       fi
-               elif [ "$fop" = "-" ]; then
-                       echo "removing: '$fspec'"
-                       rm -fR ${dst_dir}${fspec}
-               elif [ "$fop" = "=" ]; then
-                       echo "setting permissions: '$fperm' on '$fspec'"
-                       chmod -R $fperm ${dst_dir}${fspec}
-               fi
-       done
-       )
-}
-
-src_dir="$1"
-dst_dir="$2"
-python="$3"
-mode="$4"
-filespec="$5"
-
-process_filespec "$src_dir" "$dst_dir" "$filespec" || {
-       echo "process filespec error-ed"
-       exit 1
-}
-
-if [ "$mode" == "sources" ] ; then
-       # Copy only python source files
-       find $dst_dir -not -type d -not -name "*\.py" | xargs rm -f
-
-       # Delete empty folders (if the case)
-       if [ -d "$dst_dir/usr" ] ; then
-               find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
-               rmdir --ignore-fail-on-non-empty $dst_dir/usr
-       fi
-       exit 0
-fi
-
-# XXX [So that you won't goof as I did]
-# Note: Yes, I tried to use the -O & -OO flags here.
-#       However the generated byte-codes were not portable.
-#       So, we just stuck to un-optimized byte-codes,
-#       which is still way better/faster than running
-#       Python sources all the time.
-$python -m compileall -d '/' $dst_dir || {
-       echo "python -m compileall err-ed"
-       exit 1
-}
-
-# Delete source files and pyc [ un-optimized bytecode files ]
-# We may want to make this optimization thing configurable later, but not sure atm
-find $dst_dir -type f -name "*\.py" | xargs rm -f
-
-# Delete empty folders (if the case)
-if [ -d "$dst_dir/usr" ] ; then
-       find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
-       rmdir --ignore-fail-on-non-empty $dst_dir/usr
-fi
-
-exit 0
diff --git a/lang/python/python/files/python-package.mk b/lang/python/python/files/python-package.mk
deleted file mode 100644 (file)
index 9c231f6..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-#
-# Copyright (C) 2006-2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-$(call include_mk, python-version.mk)
-
-PYTHON_DIR:=$(STAGING_DIR)/usr
-PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin
-PYTHON_INC_DIR:=$(PYTHON_DIR)/include/python$(PYTHON_VERSION)
-PYTHON_LIB_DIR:=$(PYTHON_DIR)/lib/python$(PYTHON_VERSION)
-
-PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
-
-PYTHON:=python$(PYTHON_VERSION)
-
-PYTHONPATH:=$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
-
-# These configure args are needed in detection of path to Python header files
-# using autotools.
-CONFIGURE_ARGS += \
-       _python_sysroot="$(STAGING_DIR)" \
-       _python_prefix="/usr" \
-       _python_exec_prefix="/usr"
-
-PKG_USE_MIPS16:=0
-# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
-# flags are inherited from the Python base package (via sysconfig module)
-ifdef CONFIG_USE_MIPS16
-  TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
-endif
-
-define PyPackage
-
-  define Package/$(1)-src
-    $(call Package/$(1))
-    TITLE+= (sources)
-    DEPENDS:=$$$$(foreach dep,$$$$(filter +python-%,$$$$(DEPENDS)),$$$$(dep)-src)
-  endef
-
-  define Package/$(1)-src/description
-    $(call Package/$(1)/description).
-    (Contains the Python sources for this package).
-  endef
-
-  # Add default PyPackage filespec none defined
-  ifndef PyPackage/$(1)/filespec
-    define PyPackage/$(1)/filespec
-      +|$(PYTHON_PKG_DIR)
-    endef
-  endif
-
-  ifndef PyPackage/$(1)/install
-    define PyPackage/$(1)/install
-               if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
-                       $(INSTALL_DIR) $$(1)/usr/bin ; \
-                       $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \
-               fi
-    endef
-  endif
-
-  ifndef Package/$(1)/install
-  $(call shexport,PyPackage/$(1)/filespec)
-
-  define Package/$(1)/install
-       $(call PyPackage/$(1)/install,$$(1))
-       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
-       if [ -e files/python-package-install.sh ] ; then \
-               $(SHELL) files/python-package-install.sh \
-                       "$(PKG_INSTALL_DIR)" "$$(1)" \
-                       "$(HOST_PYTHON_BIN)" "$$(2)" \
-                       "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" ; \
-       elif [ -e $(STAGING_DIR)/mk/python-package-install.sh ] ; then \
-               $(SHELL) $(STAGING_DIR)/mk/python-package-install.sh \
-                       "$(PKG_INSTALL_DIR)" "$$(1)" \
-                       "$(HOST_PYTHON_BIN)" "$$(2)" \
-                       "$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" ; \
-       else \
-               echo "No 'python-package-install.sh' script found" ; \
-               exit 1 ; \
-       fi
-  endef
-
-  define Package/$(1)-src/install
-       $$(call Package/$(1)/install,$$(1),sources)
-  endef
-  endif # Package/$(1)/install
-endef
-
-$(call include_mk, python-host.mk)
-
-# $(1) => commands to execute before running pythons script
-# $(2) => python script and its arguments
-# $(3) => additional variables
-define Build/Compile/HostPyRunTarget
-       $(call HostPython, \
-               $(if $(1),$(1);) \
-               CC="$(TARGET_CC)" \
-               CCSHARED="$(TARGET_CC) $(FPIC)" \
-               CXX="$(TARGET_CXX)" \
-               LD="$(TARGET_CC)" \
-               LDSHARED="$(TARGET_CC) -shared" \
-               CFLAGS="$(TARGET_CFLAGS)" \
-               CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON_INC_DIR)" \
-               LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON_VERSION)" \
-               _PYTHON_HOST_PLATFORM=linux2 \
-               __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON)" \
-               $(3) \
-               , \
-               $(2) \
-       )
-endef
-
-# $(1) => build subdir
-# $(2) => additional arguments to setup.py
-# $(3) => additional variables
-define Build/Compile/PyMod
-       $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
-       $(call Build/Compile/HostPyRunTarget, \
-               cd $(PKG_BUILD_DIR)/$(strip $(1)), \
-               ./setup.py $(2), \
-               $(3))
-       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
-endef
-
-define PyBuild/Compile/Default
-       $(foreach pkg,$(HOST_PYTHON_PACKAGE_BUILD_DEPENDS),
-               $(call host_python_pip_install_host,$(pkg))
-       )
-       $(call Build/Compile/PyMod,, \
-               install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
-               --single-version-externally-managed \
-       )
-endef
-
-PyBuild/Compile=$(PyBuild/Compile/Default)
-
-ifeq ($(BUILD_VARIANT),python)
-define Build/Compile
-       $(call PyBuild/Compile)
-endef
-endif # python
diff --git a/lang/python/python/files/python-version.mk b/lang/python/python/files/python-version.mk
deleted file mode 100644 (file)
index 200461d..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Copyright (C) 2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-PYTHON_VERSION:=2.7
-PYTHON_VERSION_MICRO:=14
-
-PYTHON_SETUPTOOLS_VERSION:=28.8.0
-PYTHON_PIP_VERSION:=9.0.1
-
diff --git a/lang/python/python3-host.mk b/lang/python/python3-host.mk
new file mode 100644 (file)
index 0000000..2a418d5
--- /dev/null
@@ -0,0 +1,97 @@
+#
+# Copyright (C) 2017 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
+#       if `python3-package.mk` is included, this will already be included
+
+ifneq ($(__python3_host_mk_inc),1)
+__python3_host_mk_inc=1
+
+# For PYTHON3_VERSION
+python3_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
+include $(python3_mk_path)python3-version.mk
+
+HOST_PYTHON3_DIR:=$(STAGING_DIR_HOSTPKG)
+HOST_PYTHON3_INC_DIR:=$(HOST_PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
+HOST_PYTHON3_LIB_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
+
+HOST_PYTHON3_PKG_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)/site-packages
+
+HOST_PYTHON3_BIN:=$(HOST_PYTHON3_DIR)/bin/python$(PYTHON3_VERSION)
+
+HOST_PYTHON3PATH:=$(HOST_PYTHON3_LIB_DIR):$(HOST_PYTHON3_PKG_DIR)
+
+define HostPython3
+       if [ "$(strip $(3))" == "HOST" ]; then \
+               export PYTHONPATH="$(HOST_PYTHON3PATH)"; \
+               export PYTHONDONTWRITEBYTECODE=0; \
+       else \
+               export PYTHONPATH="$(PYTHON3PATH)"; \
+               export PYTHONDONTWRITEBYTECODE=1; \
+               export _python_sysroot="$(STAGING_DIR)"; \
+               export _python_prefix="/usr"; \
+               export _python_exec_prefix="/usr"; \
+       fi; \
+       export PYTHONOPTIMIZE=""; \
+       $(1) \
+       $(HOST_PYTHON3_BIN) $(2);
+endef
+
+define host_python3_settings
+       ARCH="$(HOST_ARCH)" \
+       CC="$(HOSTCC)" \
+       CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
+       CXX="$(HOSTCXX)" \
+       LD="$(HOSTCC)" \
+       LDSHARED="$(HOSTCC) -shared" \
+       CFLAGS="$(HOST_CFLAGS)" \
+       CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
+       LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
+       _PYTHON_HOST_PLATFORM=linux2
+endef
+
+# $(1) => commands to execute before running pythons script
+# $(2) => python script and its arguments
+# $(3) => additional variables
+define Build/Compile/HostPy3RunHost
+       $(call HostPython3, \
+               $(if $(1),$(1);) \
+               $(call host_python3_settings) \
+               $(3) \
+               , \
+               $(2) \
+               , \
+               HOST \
+       )
+endef
+
+# Note: I shamelessly copied this from Yousong's logic (from python-packages);
+HOST_PYTHON3_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON3_VERSION)
+define host_python3_pip_install
+       $(call host_python3_settings) \
+       $(HOST_PYTHON3_PIP) install \
+               --root=$(1) \
+               --prefix=$(2) \
+               --ignore-installed \
+               $(3)
+endef
+
+define host_python3_pip_install_host
+$(call host_python3_pip_install,$(STAGING_DIR_HOSTPKG),"",$(1))
+endef
+
+# $(1) => build subdir
+# $(2) => additional arguments to setup.py
+# $(3) => additional variables
+define Build/Compile/HostPy3Mod
+       $(call Build/Compile/HostPy3RunHost, \
+               cd $(HOST_BUILD_DIR)/$(strip $(1)), \
+               ./setup.py $(2), \
+               $(3))
+endef
+
+endif # __python3_host_mk_inc
diff --git a/lang/python/python3-package-install.sh b/lang/python/python3-package-install.sh
new file mode 100644 (file)
index 0000000..373f315
--- /dev/null
@@ -0,0 +1,82 @@
+#!/bin/sh
+set -e
+
+process_filespec() {
+       local src_dir="$1"
+       local dst_dir="$2"
+       local filespec="$3"
+       echo "$filespec" | (
+       IFS='|'
+       while read fop fspec fperm; do
+               local fop=`echo "$fop" | tr -d ' \t\n'`
+               if [ "$fop" = "+" ]; then
+                       if [ ! -e "${src_dir}${fspec}" ]; then
+                               echo "File not found '${src_dir}${fspec}'"
+                               exit 1
+                       fi
+                       dpath=`dirname "$fspec"`
+                       if [ -z "$fperm" ]; then
+                               dperm=`stat -c "%a" ${src_dir}${dpath}`
+                       fi
+                       mkdir -p -m$dperm ${dst_dir}${dpath}
+                       echo "copying: '$fspec'"
+                       cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/
+                       if [ -n "$fperm" ]; then
+                               chmod -R $fperm ${dst_dir}${fspec}
+                       fi
+               elif [ "$fop" = "-" ]; then
+                       echo "removing: '$fspec'"
+                       rm -fR ${dst_dir}${fspec}
+               elif [ "$fop" = "=" ]; then
+                       echo "setting permissions: '$fperm' on '$fspec'"
+                       chmod -R $fperm ${dst_dir}${fspec}
+               fi
+       done
+       )
+}
+
+src_dir="$1"
+dst_dir="$2"
+python="$3"
+mode="$4"
+filespec="$5"
+
+process_filespec "$src_dir" "$dst_dir" "$filespec" || {
+       echo "process filespec error-ed"
+       exit 1
+}
+
+if [ "$mode" == "sources" ] ; then
+       # Copy only python source files
+       find $dst_dir -not -type d -not -name "*\.py" | xargs rm -f
+
+       # Delete empty folders (if the case)
+       if [ -d "$dst_dir/usr" ] ; then
+               find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
+               rmdir --ignore-fail-on-non-empty $dst_dir/usr
+       fi
+       exit 0
+fi
+
+# XXX [So that you won't goof as I did]
+# Note: Yes, I tried to use the -O & -OO flags here.
+#       However the generated byte-codes were not portable.
+#       So, we just stuck to un-optimized byte-codes,
+#       which is still way better/faster than running
+#       Python sources all the time.
+$python -m compileall -b -d '/' $dst_dir || {
+       echo "python -m compileall err-ed"
+       exit 1
+}
+
+# Delete source files and pyc [ un-optimized bytecode files ]
+# We may want to make this optimization thing configurable later, but not sure atm
+find $dst_dir -type f -name "*\.py" | xargs rm -f
+
+# Delete empty folders (if the case)
+if [ -d "$dst_dir/usr" ] ; then
+       find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
+       rmdir --ignore-fail-on-non-empty $dst_dir/usr
+fi
+
+exit 0
diff --git a/lang/python/python3-package.mk b/lang/python/python3-package.mk
new file mode 100644 (file)
index 0000000..25d9834
--- /dev/null
@@ -0,0 +1,144 @@
+#
+# Copyright (C) 2007-2016 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# Note: include this after `include $(TOPDIR)/rules.mk in your package Makefile
+python3_mk_path:=$(dir $(lastword $(MAKEFILE_LIST)))
+include $(python3_mk_path)python3-host.mk
+
+PYTHON3_DIR:=$(STAGING_DIR)/usr
+PYTHON3_BIN_DIR:=$(PYTHON3_DIR)/bin
+PYTHON3_INC_DIR:=$(PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
+PYTHON3_LIB_DIR:=$(PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
+
+PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
+
+PYTHON3:=python$(PYTHON3_VERSION)
+
+PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
+
+# These configure args are needed in detection of path to Python header files
+# using autotools.
+CONFIGURE_ARGS += \
+       _python_sysroot="$(STAGING_DIR)" \
+       _python_prefix="/usr" \
+       _python_exec_prefix="/usr"
+
+PKG_USE_MIPS16:=0
+# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
+# flags are inherited from the Python base package (via sysconfig module)
+ifdef CONFIG_USE_MIPS16
+  TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
+endif
+
+define Py3Package
+
+  define Package/$(1)-src
+    $(call Package/$(1))
+    TITLE+= (sources)
+    DEPENDS:=$$$$(foreach dep,$$$$(filter +python3-%,$$$$(DEPENDS)),$$$$(dep)-src)
+  endef
+
+  define Package/$(1)-src/description
+    $(call Package/$(1)/description).
+    (Contains the Python3 sources for this package).
+  endef
+
+  # Add default PyPackage filespec none defined
+  ifndef Py3Package/$(1)/filespec
+    define Py3Package/$(1)/filespec
+      +|$(PYTHON3_PKG_DIR)
+    endef
+  endif
+
+  ifndef Py3Package/$(1)/install
+    define Py3Package/$(1)/install
+               if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
+                       $(INSTALL_DIR) $$(1)/usr/bin ; \
+                       $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \
+               fi
+    endef
+  endif
+
+  ifndef Package/$(1)/install
+  $(call shexport,Py3Package/$(1)/filespec)
+
+  define Package/$(1)/install
+       $(call Py3Package/$(1)/install,$$(1))
+       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
+       if [ -e files/python3-package-install.sh ] ; then \
+               $(SHELL) files/python3-package-install.sh \
+                       "$(PKG_INSTALL_DIR)" "$$(1)" \
+                       "$(HOST_PYTHON3_BIN)" "$$(2)" \
+                       "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \
+       elif [ -e $(STAGING_DIR)/mk/python3-package-install.sh ] ; then \
+               $(SHELL) $(STAGING_DIR)/mk/python3-package-install.sh \
+                       "$(PKG_INSTALL_DIR)" "$$(1)" \
+                       "$(HOST_PYTHON3_BIN)" "$$(2)" \
+                       "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \
+       else \
+               echo "No 'python3-package-install.sh' script found" ; \
+               exit 1 ; \
+       fi
+  endef
+
+  define Package/$(1)-src/install
+       $$(call Package/$(1)/install,$$(1),sources)
+  endef
+  endif # Package/$(1)/install
+endef
+
+# $(1) => commands to execute before running pythons script
+# $(2) => python script and its arguments
+# $(3) => additional variables
+define Build/Compile/HostPy3RunTarget
+       $(call HostPython3, \
+               $(if $(1),$(1);) \
+               CC="$(TARGET_CC)" \
+               CCSHARED="$(TARGET_CC) $(FPIC)" \
+               CXX="$(TARGET_CXX)" \
+               LD="$(TARGET_CC)" \
+               LDSHARED="$(TARGET_CC) -shared" \
+               CFLAGS="$(TARGET_CFLAGS)" \
+               CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
+               LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
+               _PYTHON_HOST_PLATFORM=linux2 \
+               __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
+               $(3) \
+               , \
+               $(2) \
+       )
+endef
+
+# $(1) => build subdir
+# $(2) => additional arguments to setup.py
+# $(3) => additional variables
+define Build/Compile/Py3Mod
+       $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
+       $(call Build/Compile/HostPy3RunTarget, \
+               cd $(PKG_BUILD_DIR)/$(strip $(1)), \
+               ./setup.py $(2), \
+               $(3))
+       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
+endef
+
+define Py3Build/Compile/Default
+       $(foreach pkg,$(HOST_PYTHON3_PACKAGE_BUILD_DEPENDS),
+               $(call host_python3_pip_install_host,$(pkg))
+       )
+       $(call Build/Compile/Py3Mod,, \
+               install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
+               --single-version-externally-managed \
+       )
+endef
+
+Py3Build/Compile=$(Py3Build/Compile/Default)
+
+ifeq ($(BUILD_VARIANT),python3)
+define Build/Compile
+       $(call Py3Build/Compile)
+endef
+endif # python3
diff --git a/lang/python/python3-version.mk b/lang/python/python3-version.mk
new file mode 100644 (file)
index 0000000..e42eeb8
--- /dev/null
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2007-2016 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+# Note: keep in sync with setuptools & pip
+PYTHON3_VERSION_MAJOR:=3
+PYTHON3_VERSION_MINOR:=6
+PYTHON3_VERSION_MICRO:=4
+
+PYTHON3_VERSION:=$(PYTHON3_VERSION_MAJOR).$(PYTHON3_VERSION_MINOR)
+
+PYTHON3_SETUPTOOLS_VERSION:=28.8.0
+PYTHON3_PIP_VERSION:=9.0.1
+
index 6c293ef4d6547d42967981d944d968f7f0b6f11d..dbda239abea34f20ae7174ac92d4ee6fb6365756 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 # The file included below defines PYTHON_VERSION
-include ./files/python3-version.mk
+include ../python3-version.mk
 
 PYTHON_VERSION:=$(PYTHON3_VERSION)
 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
@@ -25,10 +25,10 @@ PKG_LICENSE:=PSF
 PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
 
 # This file provides the necsessary host build variables
-include ./files/python3-host.mk
+include ../python3-host.mk
 
 # For Py3Package
-include ./files/python3-package.mk
+include ../python3-package.mk
 
 PKG_FIXUP:=autoreconf
 PKG_INSTALL:=1
diff --git a/lang/python/python3/files/python3-host.mk b/lang/python/python3/files/python3-host.mk
deleted file mode 100644 (file)
index 4990d33..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# Copyright (C) 2017 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-ifneq ($(__python3_host_mk_inc),1)
-__python3_host_mk_inc=1
-
-# For PYTHON3_VERSION
-$(call include_mk, python3-version.mk)
-
-HOST_PYTHON3_DIR:=$(STAGING_DIR_HOSTPKG)
-HOST_PYTHON3_INC_DIR:=$(HOST_PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
-HOST_PYTHON3_LIB_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
-
-HOST_PYTHON3_PKG_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)/site-packages
-
-HOST_PYTHON3_BIN:=$(HOST_PYTHON3_DIR)/bin/python$(PYTHON3_VERSION)
-
-HOST_PYTHON3PATH:=$(HOST_PYTHON3_LIB_DIR):$(HOST_PYTHON3_PKG_DIR)
-
-define HostPython3
-       if [ "$(strip $(3))" == "HOST" ]; then \
-               export PYTHONPATH="$(HOST_PYTHON3PATH)"; \
-               export PYTHONDONTWRITEBYTECODE=0; \
-       else \
-               export PYTHONPATH="$(PYTHON3PATH)"; \
-               export PYTHONDONTWRITEBYTECODE=1; \
-               export _python_sysroot="$(STAGING_DIR)"; \
-               export _python_prefix="/usr"; \
-               export _python_exec_prefix="/usr"; \
-       fi; \
-       export PYTHONOPTIMIZE=""; \
-       $(1) \
-       $(HOST_PYTHON3_BIN) $(2);
-endef
-
-define host_python3_settings
-       ARCH="$(HOST_ARCH)" \
-       CC="$(HOSTCC)" \
-       CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
-       CXX="$(HOSTCXX)" \
-       LD="$(HOSTCC)" \
-       LDSHARED="$(HOSTCC) -shared" \
-       CFLAGS="$(HOST_CFLAGS)" \
-       CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
-       LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
-       _PYTHON_HOST_PLATFORM=linux2
-endef
-
-# $(1) => commands to execute before running pythons script
-# $(2) => python script and its arguments
-# $(3) => additional variables
-define Build/Compile/HostPy3RunHost
-       $(call HostPython3, \
-               $(if $(1),$(1);) \
-               $(call host_python3_settings) \
-               $(3) \
-               , \
-               $(2) \
-               , \
-               HOST \
-       )
-endef
-
-# Note: I shamelessly copied this from Yousong's logic (from python-packages);
-HOST_PYTHON3_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON3_VERSION)
-define host_python3_pip_install
-       $(call host_python3_settings) \
-       $(HOST_PYTHON3_PIP) install \
-               --root=$(1) \
-               --prefix=$(2) \
-               --ignore-installed \
-               $(3)
-endef
-
-define host_python3_pip_install_host
-$(call host_python3_pip_install,$(STAGING_DIR_HOSTPKG),"",$(1))
-endef
-
-# $(1) => build subdir
-# $(2) => additional arguments to setup.py
-# $(3) => additional variables
-define Build/Compile/HostPy3Mod
-       $(call Build/Compile/HostPy3RunHost, \
-               cd $(HOST_BUILD_DIR)/$(strip $(1)), \
-               ./setup.py $(2), \
-               $(3))
-endef
-
-endif # __python3_host_mk_inc
diff --git a/lang/python/python3/files/python3-package-install.sh b/lang/python/python3/files/python3-package-install.sh
deleted file mode 100644 (file)
index 373f315..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/sh
-set -e
-
-process_filespec() {
-       local src_dir="$1"
-       local dst_dir="$2"
-       local filespec="$3"
-       echo "$filespec" | (
-       IFS='|'
-       while read fop fspec fperm; do
-               local fop=`echo "$fop" | tr -d ' \t\n'`
-               if [ "$fop" = "+" ]; then
-                       if [ ! -e "${src_dir}${fspec}" ]; then
-                               echo "File not found '${src_dir}${fspec}'"
-                               exit 1
-                       fi
-                       dpath=`dirname "$fspec"`
-                       if [ -z "$fperm" ]; then
-                               dperm=`stat -c "%a" ${src_dir}${dpath}`
-                       fi
-                       mkdir -p -m$dperm ${dst_dir}${dpath}
-                       echo "copying: '$fspec'"
-                       cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/
-                       if [ -n "$fperm" ]; then
-                               chmod -R $fperm ${dst_dir}${fspec}
-                       fi
-               elif [ "$fop" = "-" ]; then
-                       echo "removing: '$fspec'"
-                       rm -fR ${dst_dir}${fspec}
-               elif [ "$fop" = "=" ]; then
-                       echo "setting permissions: '$fperm' on '$fspec'"
-                       chmod -R $fperm ${dst_dir}${fspec}
-               fi
-       done
-       )
-}
-
-src_dir="$1"
-dst_dir="$2"
-python="$3"
-mode="$4"
-filespec="$5"
-
-process_filespec "$src_dir" "$dst_dir" "$filespec" || {
-       echo "process filespec error-ed"
-       exit 1
-}
-
-if [ "$mode" == "sources" ] ; then
-       # Copy only python source files
-       find $dst_dir -not -type d -not -name "*\.py" | xargs rm -f
-
-       # Delete empty folders (if the case)
-       if [ -d "$dst_dir/usr" ] ; then
-               find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
-               rmdir --ignore-fail-on-non-empty $dst_dir/usr
-       fi
-       exit 0
-fi
-
-# XXX [So that you won't goof as I did]
-# Note: Yes, I tried to use the -O & -OO flags here.
-#       However the generated byte-codes were not portable.
-#       So, we just stuck to un-optimized byte-codes,
-#       which is still way better/faster than running
-#       Python sources all the time.
-$python -m compileall -b -d '/' $dst_dir || {
-       echo "python -m compileall err-ed"
-       exit 1
-}
-
-# Delete source files and pyc [ un-optimized bytecode files ]
-# We may want to make this optimization thing configurable later, but not sure atm
-find $dst_dir -type f -name "*\.py" | xargs rm -f
-
-# Delete empty folders (if the case)
-if [ -d "$dst_dir/usr" ] ; then
-       find $dst_dir/usr -type d | xargs rmdir --ignore-fail-on-non-empty
-       rmdir --ignore-fail-on-non-empty $dst_dir/usr
-fi
-
-exit 0
diff --git a/lang/python/python3/files/python3-package.mk b/lang/python/python3/files/python3-package.mk
deleted file mode 100644 (file)
index 93b14fa..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-#
-# Copyright (C) 2007-2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-$(call include_mk, python3-version.mk)
-
-PYTHON3_DIR:=$(STAGING_DIR)/usr
-PYTHON3_BIN_DIR:=$(PYTHON3_DIR)/bin
-PYTHON3_INC_DIR:=$(PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
-PYTHON3_LIB_DIR:=$(PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
-
-PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
-
-PYTHON3:=python$(PYTHON3_VERSION)
-
-PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
-
-# These configure args are needed in detection of path to Python header files
-# using autotools.
-CONFIGURE_ARGS += \
-       _python_sysroot="$(STAGING_DIR)" \
-       _python_prefix="/usr" \
-       _python_exec_prefix="/usr"
-
-PKG_USE_MIPS16:=0
-# This is required in addition to PKG_USE_MIPS16:=0 because otherwise MIPS16
-# flags are inherited from the Python base package (via sysconfig module)
-ifdef CONFIG_USE_MIPS16
-  TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
-endif
-
-define Py3Package
-
-  define Package/$(1)-src
-    $(call Package/$(1))
-    TITLE+= (sources)
-    DEPENDS:=$$$$(foreach dep,$$$$(filter +python3-%,$$$$(DEPENDS)),$$$$(dep)-src)
-  endef
-
-  define Package/$(1)-src/description
-    $(call Package/$(1)/description).
-    (Contains the Python3 sources for this package).
-  endef
-
-  # Add default PyPackage filespec none defined
-  ifndef Py3Package/$(1)/filespec
-    define Py3Package/$(1)/filespec
-      +|$(PYTHON3_PKG_DIR)
-    endef
-  endif
-
-  ifndef Py3Package/$(1)/install
-    define Py3Package/$(1)/install
-               if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
-                       $(INSTALL_DIR) $$(1)/usr/bin ; \
-                       $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/ ; \
-               fi
-    endef
-  endif
-
-  ifndef Package/$(1)/install
-  $(call shexport,Py3Package/$(1)/filespec)
-
-  define Package/$(1)/install
-       $(call Py3Package/$(1)/install,$$(1))
-       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
-       if [ -e files/python3-package-install.sh ] ; then \
-               $(SHELL) files/python3-package-install.sh \
-                       "$(PKG_INSTALL_DIR)" "$$(1)" \
-                       "$(HOST_PYTHON3_BIN)" "$$(2)" \
-                       "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \
-       elif [ -e $(STAGING_DIR)/mk/python3-package-install.sh ] ; then \
-               $(SHELL) $(STAGING_DIR)/mk/python3-package-install.sh \
-                       "$(PKG_INSTALL_DIR)" "$$(1)" \
-                       "$(HOST_PYTHON3_BIN)" "$$(2)" \
-                       "$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" ; \
-       else \
-               echo "No 'python3-package-install.sh' script found" ; \
-               exit 1 ; \
-       fi
-  endef
-
-  define Package/$(1)-src/install
-       $$(call Package/$(1)/install,$$(1),sources)
-  endef
-  endif # Package/$(1)/install
-endef
-
-$(call include_mk, python3-host.mk)
-
-# $(1) => commands to execute before running pythons script
-# $(2) => python script and its arguments
-# $(3) => additional variables
-define Build/Compile/HostPy3RunTarget
-       $(call HostPython3, \
-               $(if $(1),$(1);) \
-               CC="$(TARGET_CC)" \
-               CCSHARED="$(TARGET_CC) $(FPIC)" \
-               CXX="$(TARGET_CXX)" \
-               LD="$(TARGET_CC)" \
-               LDSHARED="$(TARGET_CC) -shared" \
-               CFLAGS="$(TARGET_CFLAGS)" \
-               CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
-               LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
-               _PYTHON_HOST_PLATFORM=linux2 \
-               __PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
-               $(3) \
-               , \
-               $(2) \
-       )
-endef
-
-# $(1) => build subdir
-# $(2) => additional arguments to setup.py
-# $(3) => additional variables
-define Build/Compile/Py3Mod
-       $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
-       $(call Build/Compile/HostPy3RunTarget, \
-               cd $(PKG_BUILD_DIR)/$(strip $(1)), \
-               ./setup.py $(2), \
-               $(3))
-       find $(PKG_INSTALL_DIR) -name "*\.exe" | xargs rm -f
-endef
-
-define Py3Build/Compile/Default
-       $(foreach pkg,$(HOST_PYTHON3_PACKAGE_BUILD_DEPENDS),
-               $(call host_python3_pip_install_host,$(pkg))
-       )
-       $(call Build/Compile/Py3Mod,, \
-               install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
-               --single-version-externally-managed \
-       )
-endef
-
-Py3Build/Compile=$(Py3Build/Compile/Default)
-
-ifeq ($(BUILD_VARIANT),python3)
-define Build/Compile
-       $(call Py3Build/Compile)
-endef
-endif # python3
diff --git a/lang/python/python3/files/python3-version.mk b/lang/python/python3/files/python3-version.mk
deleted file mode 100644 (file)
index e42eeb8..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Copyright (C) 2007-2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-# Note: keep in sync with setuptools & pip
-PYTHON3_VERSION_MAJOR:=3
-PYTHON3_VERSION_MINOR:=6
-PYTHON3_VERSION_MICRO:=4
-
-PYTHON3_VERSION:=$(PYTHON3_VERSION_MAJOR).$(PYTHON3_VERSION_MINOR)
-
-PYTHON3_SETUPTOOLS_VERSION:=28.8.0
-PYTHON3_PIP_VERSION:=9.0.1
-