diff --git a/lang/python-pip/Makefile b/lang/python-pip/Makefile
deleted file mode 100644
index b20177887..000000000
--- a/lang/python-pip/Makefile
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright (C) 2014 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-# 
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=python-pip
-PKG_VERSION:=8.1.2
-PKG_RELEASE:=1
-
-PKG_SOURCE:=pip-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/
-PKG_MD5SUM:=87083c0b9867963b29f7aba3613e8f4a
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/python-pip-$(PKG_VERSION)
-PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-PKG_USE_MIPS16:=0
-
-include $(INCLUDE_DIR)/package.mk
-$(call include_mk, python-package.mk)
-
-define Package/python-pip
-  SUBMENU:=Python
-  SECTION:=lang
-  CATEGORY:=Languages
-  TITLE:=Tool for installing Python packages.
-  URL:=https://pip.pypa.io
-  DEPENDS:=+python +python-setuptools +ca-certificates
-  MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
-endef
-
-define Package/python-pip/description
-  A tool for installing and managing Python packages.
-endef
-
-define Build/Compile
-	$(call Build/Compile/PyMod,,\
-		install --root="$(PKG_INSTALL_DIR)" --prefix="/usr" \
-		--single-version-externally-managed \
-	)
-endef
-
-define PyPackage/python-pip/filespec
-+|$(PYTHON_PKG_DIR)
--|$(PYTHON_PKG_DIR)/pip/_vendor/distlib/*.exe
-endef
-
-define PyPackage/python-pip/install
-	$(INSTALL_DIR) $(1)/usr/bin $(1)/etc
-	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
-	$(INSTALL_CONF) ./files/pip.conf $(1)/etc/
-endef
-
-$(eval $(call PyPackage,python-pip))
-$(eval $(call BuildPackage,python-pip))
diff --git a/lang/python-pip/files/pip.conf b/lang/python-pip/files/pip.conf
deleted file mode 100644
index 89339e98a..000000000
--- a/lang/python-pip/files/pip.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-[global]
-cache-dir=/tmp/.cache
-log-file=/tmp/pip-log.txt
diff --git a/lang/python-setuptools/Makefile b/lang/python-setuptools/Makefile
deleted file mode 100644
index 8a714514d..000000000
--- a/lang/python-setuptools/Makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# Copyright (C) 2014-2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=python-setuptools
-PKG_VERSION:=27.2.0
-PKG_RELEASE:=1
-
-PKG_SOURCE:=setuptools-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=https://pypi.python.org/packages/87/ba/54197971d107bc06f5f3fbdc0d728a7ae0b10cafca46acfddba65a0899d8/
-PKG_MD5SUM:=b39715612fdc0372dbfd7b3fcf5d4fe5
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
-PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-
-include $(INCLUDE_DIR)/package.mk
-$(call include_mk, python-package.mk)
-
-define Package/python-setuptools
-  SUBMENU:=Python
-  SECTION:=lang
-  CATEGORY:=Languages
-  TITLE:=Tool for installing Python packages.
-  URL:=https://bitbucket.org/pypa/setuptools
-  DEPENDS:=+python +ca-certificates
-  MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
-endef
-
-define Package/python-setuptools/description
-  Easily download, build, install, upgrade, and uninstall Python packages
-endef
-
-define Build/Compile
-	$(call Build/Compile/PyMod,,\
-		install --root="$(PKG_INSTALL_DIR)" --prefix="/usr" \
-		--single-version-externally-managed \
-	)
-endef
-
-define Build/InstallDev
-	$(INSTALL_DIR) $(PYTHON_LIB_DIR)
-	$(CP) \
-		$(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \
-		$(PYTHON_LIB_DIR)
-endef
-
-define PyPackage/python-setuptools/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
-endef
-
-$(eval $(call PyPackage,python-setuptools))
-$(eval $(call BuildPackage,python-setuptools))
-
diff --git a/lang/python-setuptools/patches/0001-remove-windows-support.patch b/lang/python-setuptools/patches/0001-remove-windows-support.patch
deleted file mode 100644
index 86e5bba05..000000000
--- a/lang/python-setuptools/patches/0001-remove-windows-support.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/setuptools/dist.py b/setuptools/dist.py
-index b004f92..66b9d89 100644
---- a/setuptools/dist.py
-+++ b/setuptools/dist.py
-@@ -17,7 +17,6 @@ from setuptools.extern.six.moves import map
- from pkg_resources.extern import packaging
- 
- from setuptools.depends import Require
--from setuptools import windows_support
- from setuptools.monkey import get_unpatched
- import pkg_resources
- 
-@@ -383,7 +382,6 @@ class Distribution(_Distribution):
-         egg_cache_dir = os.path.join(os.curdir, '.eggs')
-         if not os.path.exists(egg_cache_dir):
-             os.mkdir(egg_cache_dir)
--            windows_support.hide_file(egg_cache_dir)
-             readme_txt_filename = os.path.join(egg_cache_dir, 'README.txt')
-             with open(readme_txt_filename, 'w') as f:
-                 f.write('This directory contains eggs that were downloaded '
diff --git a/lang/python-setuptools/patches/0002-fix-pyvenv-environment-get.patch b/lang/python-setuptools/patches/0002-fix-pyvenv-environment-get.patch
deleted file mode 100644
index d96ab089c..000000000
--- a/lang/python-setuptools/patches/0002-fix-pyvenv-environment-get.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
-index e8b90c7..8598c44 100755
---- a/setuptools/command/easy_install.py
-+++ b/setuptools/command/easy_install.py
-@@ -1946,6 +1946,8 @@ class CommandSpec(list):
-         Construct a CommandSpec from a parameter to build_scripts, which may
-         be None.
-         """
-+        if os.environ.get('__PYVENV_LAUNCHER__'):
-+            return cls.from_environment()
-         if isinstance(param, cls):
-             return param
-         if isinstance(param, list):
diff --git a/lang/python/Makefile b/lang/python/Makefile
index c3f26800a..f12e0361b 100644
--- a/lang/python/Makefile
+++ b/lang/python/Makefile
@@ -12,7 +12,7 @@ include ./files/python-version.mk
 
 PKG_NAME:=python
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
@@ -92,7 +92,9 @@ define PyBasePackage
   endif
   PYTHON_LIB_FILES_DEL+=$(2)
   define PyPackage/$(1)/filespec
-    $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
+    ifneq ($(2),)
+      $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
+    endif
   endef
 endef
 
@@ -136,6 +138,7 @@ CONFIGURE_ARGS+= \
 	--without-cxx-main \
 	--with-threads \
 	--with-system-ffi \
+	--with-ensurepip=no \
 	--without-pymalloc \
 	PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
 	$(ENABLE_IPV6) \
@@ -147,6 +150,31 @@ define Build/Prepare
 	$(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
 endef
 
+ifdef CONFIG_PACKAGE_python-setuptools
+define Build/Compile/python-setuptools
+	$(STAGING_DIR_HOSTPKG)/bin/pip install \
+		--ignore-installed \
+		--root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
+		$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
+endef
+endif # CONFIG_PACKAGE_python-setuptools
+
+ifdef CONFIG_PACKAGE_python-pip
+define Build/Compile/python-pip
+	$(STAGING_DIR_HOSTPKG)/bin/pip install \
+		--ignore-installed \
+		--root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
+		$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
+endef
+endif # CONFIG_PACKAGE_python-pip
+
+define Build/Compile
+	$(call Build/Compile/Default)
+	# Use host pip to install python-setuptools
+	$(call Build/Compile/python-setuptools)
+	$(call Build/Compile/python-pip)
+endef
+
 define Build/InstallDev
 	$(INSTALL_DIR) $(STAGING_DIR)/mk/
 	$(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/ $(1)/usr/lib/pkgconfig
diff --git a/lang/python/files/python-package-pip.mk b/lang/python/files/python-package-pip.mk
new file mode 100644
index 000000000..66bd6553f
--- /dev/null
+++ b/lang/python/files/python-package-pip.mk
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2017 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Package/python-pip
+$(call Package/python/Default)
+  TITLE:=Python $(PYTHON_VERSION) pip module
+  DEPENDS:=+python +python-setuptools
+endef
+
+define PyPackage/python-pip/install
+	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
+	# Adjust shebang to proper python location on target
+	sed "1s/.*/#\!\/usr\/bin\/python$(PYTHON_VERSION)/" -i $(PKG_BUILD_DIR)/install-pip/bin/*
+	$(CP) $(PKG_BUILD_DIR)/install-pip/bin/* $(1)/usr/bin
+	$(CP) \
+		$(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON_VERSION)/site-packages/pip \
+		$(1)/usr/lib/python$(PYTHON_VERSION)/site-packages/
+endef
+
+$(eval $(call PyBasePackage,python-pip, \
+	, \
+	DO_NOT_ADD_TO_PACKAGE_DEPENDS \
+))
diff --git a/lang/python/files/python-package-setuptools.mk b/lang/python/files/python-package-setuptools.mk
new file mode 100644
index 000000000..7025ebbc0
--- /dev/null
+++ b/lang/python/files/python-package-setuptools.mk
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2017 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Package/python-setuptools
+$(call Package/python/Default)
+  TITLE:=Python $(PYTHON_VERSION) setuptools module
+  DEPENDS:=+python
+endef
+
+define PyPackage/python-setuptools/install
+	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
+	# Adjust shebang to proper python location on target
+	sed "1s/.*/#\!\/usr\/bin\/python$(PYTHON_VERSION)/" -i $(PKG_BUILD_DIR)/install-setuptools/bin/*
+	$(CP) $(PKG_BUILD_DIR)/install-setuptools/bin/* $(1)/usr/bin
+	$(CP) \
+		$(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON_VERSION)/site-packages/pkg_resources \
+		$(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON_VERSION)/site-packages/setuptools \
+		$(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON_VERSION)/site-packages/easy_install.py \
+		$(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
+endef
+
+$(eval $(call PyBasePackage,python-setuptools, \
+	, \
+	DO_NOT_ADD_TO_PACKAGE_DEPENDS \
+))
diff --git a/lang/python3-pip/Makefile b/lang/python3-pip/Makefile
deleted file mode 100644
index b7680b933..000000000
--- a/lang/python3-pip/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# Copyright (C) 2014-2015 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=python3-pip
-PKG_VERSION:=8.1.2
-PKG_RELEASE:=1
-
-PKG_SOURCE:=pip-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=https://pypi.python.org/packages/e7/a8/7556133689add8d1a54c0b14aeff0acb03c64707ce100ecd53934da1aa13/
-PKG_MD5SUM:=87083c0b9867963b29f7aba3613e8f4a
-
-PKG_LICENSE:=MIT
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/python3-pip-$(PKG_VERSION)
-PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-PKG_USE_MIPS16:=0
-
-include $(INCLUDE_DIR)/package.mk
-$(call include_mk, python3-package.mk)
-
-define Package/python3-pip
-	SUBMENU:=Python
-	SECTION:=lang
-	CATEGORY:=Languages
-	TITLE:=Tool for installing Python $(PYTHON3_VERSION) packages.
-	URL:=https://pip.pypa.io
-	DEPENDS:=+python3 +python3-dev +python3-lib2to3 +python3-setuptools
-	MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
-endef
-
-define Package/python3-pip/description
-	A tool for installing and managing Python $(PYTHON3_VERSION) packages.
-endef
-
-define Build/Compile
-	$(call Build/Compile/Py3Mod,,\
-		install --root="$(PKG_INSTALL_DIR)" --prefix="/usr" \
-		--single-version-externally-managed \
-	)
-endef
-
-define Py3Package/python3-pip/filespec
-+|$(PYTHON3_PKG_DIR)
--|$(PYTHON3_PKG_DIR)/_vendor/distlib/*.exe
--|$(PYTHON3_PKG_DIR)/utils/outdated.py
-endef
-
-define Py3Package/python3-pip/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(CP) $(PKG_INSTALL_DIR)/usr/bin/pip$(PYTHON3_VERSION) $(1)/usr/bin
-	$(LN) pip$(PYTHON3_VERSION) $(1)/usr/bin/pip3
-endef
-
-$(eval $(call Py3Package,python3-pip))
-$(eval $(call BuildPackage,python3-pip))
diff --git a/lang/python3-pip/patches/0001-remove-self-version-checking.patch b/lang/python3-pip/patches/0001-remove-self-version-checking.patch
deleted file mode 100644
index b8c0bb647..000000000
--- a/lang/python3-pip/patches/0001-remove-self-version-checking.patch
+++ /dev/null
@@ -1,70 +0,0 @@
-From 771a1407b15538697a7f38209e40dbbf58828d33 Mon Sep 17 00:00:00 2001
-From: Florian Fieber <florian@florianfieber.de>
-Date: Tue, 9 Jun 2015 15:59:04 +0200
-Subject: [PATCH] Remove self version checking
-
-Signed-off-by: Florian Fieber <florian@florianfieber.de>
----
- pip/basecommand.py | 10 ----------
- pip/cmdoptions.py  | 10 ----------
- 2 files changed, 20 deletions(-)
-
-diff --git a/pip/basecommand.py b/pip/basecommand.py
-index 854d113..c2337a4 100644
---- a/pip/basecommand.py
-+++ b/pip/basecommand.py
-@@ -22,7 +22,6 @@ from pip.status_codes import (
- from pip.utils import get_prog, normalize_path
- from pip.utils.deprecation import RemovedInPip8Warning
- from pip.utils.logging import IndentingFormatter
--from pip.utils.outdated import pip_version_check
- 
- 
- __all__ = ['Command']
-@@ -237,15 +236,6 @@ class Command(object):
-             logger.critical('Exception:', exc_info=True)
- 
-             return UNKNOWN_ERROR
--        finally:
--            # Check if we're using the latest version of pip available
--            if (not options.disable_pip_version_check and not
--                    getattr(options, "no_index", False)):
--                with self._build_session(
--                        options,
--                        retries=0,
--                        timeout=min(5, options.timeout)) as session:
--                    pip_version_check(session)
- 
-         return SUCCESS
- 
-diff --git a/pip/cmdoptions.py b/pip/cmdoptions.py
-index 9a0446a..4fa29d3 100644
---- a/pip/cmdoptions.py
-+++ b/pip/cmdoptions.py
-@@ -514,15 +514,6 @@ no_clean = partial(
-     default=False,
-     help="Don't clean up build directories.")
- 
--disable_pip_version_check = partial(
--    Option,
--    "--disable-pip-version-check",
--    dest="disable_pip_version_check",
--    action="store_true",
--    default=False,
--    help="Don't periodically check PyPI to determine whether a new version "
--         "of pip is available for download. Implied with --no-index.")
--
- # Deprecated, Remove later
- always_unzip = partial(
-     Option,
-@@ -560,7 +551,6 @@ general_group = {
-         client_cert,
-         cache_dir,
-         no_cache,
--        disable_pip_version_check,
-     ]
- }
- 
--- 
-2.6.2
-
diff --git a/lang/python3-setuptools/Makefile b/lang/python3-setuptools/Makefile
deleted file mode 100644
index b112a3b66..000000000
--- a/lang/python3-setuptools/Makefile
+++ /dev/null
@@ -1,61 +0,0 @@
-#
-# Copyright (C) 2014-2016 OpenWrt.org
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=python3-setuptools
-PKG_VERSION:=27.2.0
-PKG_RELEASE:=1
-
-PKG_SOURCE:=setuptools-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=https://pypi.python.org/packages/87/ba/54197971d107bc06f5f3fbdc0d728a7ae0b10cafca46acfddba65a0899d8/
-PKG_MD5SUM:=b39715612fdc0372dbfd7b3fcf5d4fe5
-
-PKG_LICENSE:=PSF
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/python3-setuptools-$(PKG_VERSION)
-PKG_UNPACK=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
-
-include $(INCLUDE_DIR)/package.mk
-$(call include_mk, python3-package.mk)
-
-define Package/python3-setuptools
-	SUBMENU:=Python
-	SECTION:=lang
-	CATEGORY:=Languages
-	TITLE:=Tool for installing Python $(PYTHON3_VERSION) packages.
-	URL:=https://bitbucket.org/pypa/setuptools
-	DEPENDS:=+python3 +python3-dev +python3-lib2to3
-	MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
-endef
-
-define Package/python3-setuptools/description
-	Easily download, build, install, upgrade, and uninstall Python $(PYTHON3_VERSION) packages
-endef
-
-define Build/Compile
-	$(call Build/Compile/Py3Mod,,\
-		install --root="$(PKG_INSTALL_DIR)" --prefix="/usr" \
-		--single-version-externally-managed \
-	)
-endef
-
-define Build/InstallDev
-	$(INSTALL_DIR) $(PYTHON3_LIB_DIR)
-	$(CP) \
-		$(PKG_INSTALL_DIR)$(PYTHON3_PKG_DIR)/* \
-		$(PYTHON3_LIB_DIR)
-endef
-
-define Py3Package/python3-setuptools/install
-	$(INSTALL_DIR) $(1)/usr/bin
-	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/easy_install-$(PYTHON3_VERSION) $(1)/usr/bin/
-	$(LN) easy_install-$(PYTHON3_VERSION) $(1)/usr/bin/easy_install3
-endef
-
-$(eval $(call Py3Package,python3-setuptools))
-$(eval $(call BuildPackage,python3-setuptools))
diff --git a/lang/python3-setuptools/patches/0001-remove-windows-support.patch b/lang/python3-setuptools/patches/0001-remove-windows-support.patch
deleted file mode 100644
index 86e5bba05..000000000
--- a/lang/python3-setuptools/patches/0001-remove-windows-support.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/setuptools/dist.py b/setuptools/dist.py
-index b004f92..66b9d89 100644
---- a/setuptools/dist.py
-+++ b/setuptools/dist.py
-@@ -17,7 +17,6 @@ from setuptools.extern.six.moves import map
- from pkg_resources.extern import packaging
- 
- from setuptools.depends import Require
--from setuptools import windows_support
- from setuptools.monkey import get_unpatched
- import pkg_resources
- 
-@@ -383,7 +382,6 @@ class Distribution(_Distribution):
-         egg_cache_dir = os.path.join(os.curdir, '.eggs')
-         if not os.path.exists(egg_cache_dir):
-             os.mkdir(egg_cache_dir)
--            windows_support.hide_file(egg_cache_dir)
-             readme_txt_filename = os.path.join(egg_cache_dir, 'README.txt')
-             with open(readme_txt_filename, 'w') as f:
-                 f.write('This directory contains eggs that were downloaded '
diff --git a/lang/python3-setuptools/patches/0002-fix-pyvenv-environment-get.patch b/lang/python3-setuptools/patches/0002-fix-pyvenv-environment-get.patch
deleted file mode 100644
index d96ab089c..000000000
--- a/lang/python3-setuptools/patches/0002-fix-pyvenv-environment-get.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
-index e8b90c7..8598c44 100755
---- a/setuptools/command/easy_install.py
-+++ b/setuptools/command/easy_install.py
-@@ -1946,6 +1946,8 @@ class CommandSpec(list):
-         Construct a CommandSpec from a parameter to build_scripts, which may
-         be None.
-         """
-+        if os.environ.get('__PYVENV_LAUNCHER__'):
-+            return cls.from_environment()
-         if isinstance(param, cls):
-             return param
-         if isinstance(param, list):
diff --git a/lang/python3/Makefile b/lang/python3/Makefile
index 2899b86c1..67a594de6 100644
--- a/lang/python3/Makefile
+++ b/lang/python3/Makefile
@@ -14,7 +14,7 @@ PYTHON_VERSION:=$(PYTHON3_VERSION)
 PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
 
 PKG_NAME:=python3
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
@@ -96,7 +96,9 @@ define Py3BasePackage
   endif
   PYTHON3_LIB_FILES_DEL+=$(2)
   define Py3Package/$(1)/filespec
-    $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
+    ifneq ($(2),)
+      $(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
+    endif
   endef
 endef
 
@@ -140,8 +142,8 @@ CONFIGURE_ARGS+= \
 	--without-cxx-main \
 	--with-threads \
 	--with-system-ffi \
-	--without-pymalloc \
 	--with-ensurepip=no \
+	--without-pymalloc \
 	PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)" \
 	$(ENABLE_IPV6) \
 	CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \
@@ -152,6 +154,31 @@ define Build/Prepare
 	$(CP) ./files/config.site $(PKG_BUILD_DIR)/config.site
 endef
 
+ifdef CONFIG_PACKAGE_python3-setuptools
+define Build/Compile/python3-setuptools
+	$(STAGING_DIR_HOSTPKG)/bin/pip3 install \
+		--ignore-installed \
+		--root=$(PKG_BUILD_DIR)/install-setuptools --prefix=. \
+		$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-*.whl
+endef
+endif # CONFIG_PACKAGE_python3-setuptools
+
+ifdef CONFIG_PACKAGE_python3-pip
+define Build/Compile/python3-pip
+	$(STAGING_DIR_HOSTPKG)/bin/pip3 install \
+		--ignore-installed \
+		--root=$(PKG_BUILD_DIR)/install-pip --prefix=. \
+		$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-*.whl
+endef
+endif # CONFIG_PACKAGE_python3-pip
+
+define Build/Compile
+	$(call Build/Compile/Default)
+	# Use host pip to install python-setuptools
+	$(call Build/Compile/python3-setuptools)
+	$(call Build/Compile/python3-pip)
+endef
+
 define Build/InstallDev
 	$(INSTALL_DIR) $(STAGING_DIR)/mk/
 	$(INSTALL_DIR) $(1)/usr/include/ $(1)/usr/lib/
diff --git a/lang/python3/files/python3-package-pip.mk b/lang/python3/files/python3-package-pip.mk
new file mode 100644
index 000000000..e346e22c5
--- /dev/null
+++ b/lang/python3/files/python3-package-pip.mk
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2017 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Package/python3-pip
+$(call Package/python3/Default)
+  TITLE:=Python $(PYTHON3_VERSION) pip module
+  DEPENDS:=+python3 +python3-setuptools
+endef
+
+define Py3Package/python3-pip/install
+	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
+	# Adjust shebang to proper python location on target
+	sed "1s/.*/#\!\/usr\/bin\/python$(PYTHON3_VERSION)/" -i $(PKG_BUILD_DIR)/install-pip/bin/*
+	$(CP) $(PKG_BUILD_DIR)/install-pip/bin/pip3* $(1)/usr/bin
+	$(CP) \
+		$(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON3_VERSION)/site-packages/pip \
+		$(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/
+endef
+
+$(eval $(call Py3BasePackage,python3-pip, \
+	, \
+	DO_NOT_ADD_TO_PACKAGE_DEPENDS \
+))
diff --git a/lang/python3/files/python3-package-setuptools.mk b/lang/python3/files/python3-package-setuptools.mk
new file mode 100644
index 000000000..063acb80e
--- /dev/null
+++ b/lang/python3/files/python3-package-setuptools.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2017 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Package/python3-setuptools
+$(call Package/python3/Default)
+  TITLE:=Python $(PYTHON3_VERSION) setuptools module
+  DEPENDS:=+python3
+endef
+
+define Py3Package/python3-setuptools/install
+	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
+	# Adjust shebang to proper python location on target
+	sed "1s/.*/#\!\/usr\/bin\/python$(PYTHON3_VERSION)/" -i $(PKG_BUILD_DIR)/install-setuptools/bin/*
+	$(CP) $(PKG_BUILD_DIR)/install-setuptools/bin/easy_install-* $(1)/usr/bin
+	$(LN) easy_install-$(PYTHON3_VERSION) $(1)/usr/bin/easy_install-3
+	$(CP) \
+		$(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON3_VERSION)/site-packages/pkg_resources \
+		$(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON3_VERSION)/site-packages/setuptools \
+		$(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON3_VERSION)/site-packages/easy_install.py \
+		$(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
+endef
+
+$(eval $(call Py3BasePackage,python3-setuptools, \
+	, \
+	DO_NOT_ADD_TO_PACKAGE_DEPENDS \
+))