ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/lang/python/python-pip/Makefile b/external/subpack/lang/python/python-pip/Makefile
new file mode 100644
index 0000000..7d50f3f
--- /dev/null
+++ b/external/subpack/lang/python/python-pip/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2023 Jeffery To
+#
+# 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:=23.3.1
+PKG_RELEASE:=1
+
+PYPI_NAME:=pip
+PKG_HASH:=1fcaa041308d01f14575f6d0d2ea4b75a3e2871fe4f9c694976f908768e14174
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE.txt
+PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
+PKG_CPE_ID:=cpe:/a:pypa:pip
+
+include ../pypi.mk
+include $(INCLUDE_DIR)/package.mk
+include ../python3-package.mk
+
+define Package/python3-pip
+ SECTION:=lang
+ CATEGORY:=Languages
+ SUBMENU:=Python
+ TITLE:=PyPA recommended tool for installing Python packages
+ URL:=https://pip.pypa.io/
+ DEPENDS:=+python3
+endef
+
+define Package/python3-pip/description
+pip is the package installer for Python. You can use pip to install
+packages from the Python Package Index and other indexes.
+endef
+
+define Package/python3-pip/conffiles
+/etc/pip.conf
+endef
+
+define Py3Package/python3-pip/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/pip$(PYTHON3_VERSION) $(1)/usr/bin/
+ $(LN) pip$(PYTHON3_VERSION) $(1)/usr/bin/pip3
+ $(LN) pip$(PYTHON3_VERSION) $(1)/usr/bin/pip
+
+ $(INSTALL_DIR) $(1)/etc
+ $(INSTALL_DATA) ./files/pip.conf $(1)/etc/
+endef
+
+$(eval $(call Py3Package,python3-pip))
+$(eval $(call BuildPackage,python3-pip))
+$(eval $(call BuildPackage,python3-pip-src))
diff --git a/external/subpack/lang/python/python-pip/files/pip.conf b/external/subpack/lang/python/python-pip/files/pip.conf
new file mode 100644
index 0000000..0890081
--- /dev/null
+++ b/external/subpack/lang/python/python-pip/files/pip.conf
@@ -0,0 +1,2 @@
+[global]
+cache-dir = /var/cache/pip
diff --git a/external/subpack/lang/python/python-pip/patches/001-pyproject-hooks-pyc-fix.patch b/external/subpack/lang/python/python-pip/patches/001-pyproject-hooks-pyc-fix.patch
new file mode 100644
index 0000000..e9eafab
--- /dev/null
+++ b/external/subpack/lang/python/python-pip/patches/001-pyproject-hooks-pyc-fix.patch
@@ -0,0 +1,19 @@
+--- a/src/pip/_vendor/pyproject_hooks/_in_process/__init__.py
++++ b/src/pip/_vendor/pyproject_hooks/_in_process/__init__.py
+@@ -11,8 +11,14 @@ try:
+ except AttributeError:
+ # Python 3.8 compatibility
+ def _in_proc_script_path():
+- return resources.path(__package__, '_in_process.py')
++ filename = '_in_process.pyc'
++ if resources.is_resource(__package__, '_in_process.py'):
++ filename = '_in_process.py'
++ return resources.path(__package__, filename)
+ else:
+ def _in_proc_script_path():
++ filename = '_in_process.pyc'
++ if resources.files(__package__).joinpath('_in_process.py').is_file():
++ filename = '_in_process.py'
+ return resources.as_file(
+- resources.files(__package__).joinpath('_in_process.py'))
++ resources.files(__package__).joinpath(filename))
diff --git a/external/subpack/lang/python/python-pip/patches/002-pip-runner-pyc-fix.patch b/external/subpack/lang/python/python-pip/patches/002-pip-runner-pyc-fix.patch
new file mode 100644
index 0000000..8f68049
--- /dev/null
+++ b/external/subpack/lang/python/python-pip/patches/002-pip-runner-pyc-fix.patch
@@ -0,0 +1,15 @@
+--- a/src/pip/_internal/build_env.py
++++ b/src/pip/_internal/build_env.py
+@@ -54,7 +54,11 @@ def get_runnable_pip() -> str:
+ # case, we can use that directly.
+ return str(source)
+
+- return os.fsdecode(source / "__pip-runner__.py")
++ filename = "__pip-runner__.pyc"
++ py = source / "__pip-runner__.py"
++ if py.is_file():
++ filename = "__pip-runner__.py"
++ return os.fsdecode(source / filename)
+
+
+ def _get_system_sitepackages() -> Set[str]:
diff --git a/external/subpack/lang/python/python-pip/patches/003-disable-pip-version-check.patch b/external/subpack/lang/python/python-pip/patches/003-disable-pip-version-check.patch
new file mode 100644
index 0000000..99a0258
--- /dev/null
+++ b/external/subpack/lang/python/python-pip/patches/003-disable-pip-version-check.patch
@@ -0,0 +1,20 @@
+From: Barry Warsaw <barry@python.org>
+Date: Fri, 18 Nov 2016 17:07:47 -0500
+Subject: Set --disable-pip-version-check=True by default.
+
+Patch-Name: disable-pip-version-check.patch
+---
+ src/pip/_internal/cli/cmdoptions.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/src/pip/_internal/cli/cmdoptions.py
++++ b/src/pip/_internal/cli/cmdoptions.py
+@@ -895,7 +895,7 @@ disable_pip_version_check: Callable[...,
+ "--disable-pip-version-check",
+ dest="disable_pip_version_check",
+ action="store_true",
+- default=False,
++ default=True,
+ help="Don't periodically check PyPI to determine whether a new version "
+ "of pip is available for download. Implied with --no-index.",
+ )
diff --git a/external/subpack/lang/python/python-pip/test.sh b/external/subpack/lang/python/python-pip/test.sh
new file mode 100644
index 0000000..10355b3
--- /dev/null
+++ b/external/subpack/lang/python/python-pip/test.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+[ "$1" = python3-pip ] || exit 0
+
+pip --version | grep -F "pip $PKG_VERSION "