python3: Split pip into separate source package
authorJeffery To <jeffery.to@gmail.com>
Thu, 18 May 2023 05:36:24 +0000 (13:36 +0800)
committerJeffery To <jeffery.to@gmail.com>
Fri, 26 May 2023 14:06:08 +0000 (22:06 +0800)
Packaging pip from a separate source package allows it to stay updated
with upstream.

Host pip will remain installed as part of python3. Host pip is used in a
much more controlled way and so is less critical for it to track
upstream.

This also removes the python-pip-conf package and installs the pip.conf
file as part of python3-pip.

The patch 003-disable-pip-version-check.patch is originally from Debian:
https://salsa.debian.org/python-team/packages/python-pip/-/blob/bb079efb8c6dd2c284eee94cf90e61bce19a6f73/debian/patches/disable-pip-version-check.patch

pip was in a separate source package that was removed in
a53d0c5a403d1669e2cf6c59c2be6a9d3ed633a0; this work is not based on that
earlier package.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python-pip-conf/Makefile [deleted file]
lang/python/python-pip-conf/files/pip.conf [deleted file]
lang/python/python-pip/Makefile [new file with mode: 0644]
lang/python/python-pip/files/pip.conf [new file with mode: 0644]
lang/python/python-pip/patches/001-pyproject-hooks-pyc-fix.patch [new file with mode: 0644]
lang/python/python-pip/patches/002-pip-runner-pyc-fix.patch [new file with mode: 0644]
lang/python/python-pip/patches/003-disable-pip-version-check.patch [new file with mode: 0644]
lang/python/python3/Makefile
lang/python/python3/files/python3-package-pip.mk [deleted file]
lang/python/python3/patches-host-pip/.gitkeep [new file with mode: 0644]
lang/python/python3/patches-pip/001-pep517-pyc-fix.patch [deleted file]

diff --git a/lang/python/python-pip-conf/Makefile b/lang/python/python-pip-conf/Makefile
deleted file mode 100644 (file)
index b8ef7f6..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (C) 2017 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-conf
-PKG_VERSION:=0.1
-PKG_RELEASE:=1
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/python-pip-conf
-  SUBMENU:=Python
-  SECTION:=lang
-  CATEGORY:=Languages
-  TITLE:=Configuration file for pip/pip3
-  URL:=https://pip.pypa.io
-  MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
-endef
-
-define Package/python-pip-conf/description
- Configuration file for pip/pip3
-endef
-
-Build/Compile:=
-
-define Package/python-pip-conf/install
-       $(INSTALL_DIR) $(1)/etc
-       $(CP) ./files/pip.conf $(1)/etc
-endef
-
-$(eval $(call BuildPackage,python-pip-conf))
diff --git a/lang/python/python-pip-conf/files/pip.conf b/lang/python/python-pip-conf/files/pip.conf
deleted file mode 100644 (file)
index 89339e9..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[global]
-cache-dir=/tmp/.cache
-log-file=/tmp/pip-log.txt
diff --git a/lang/python/python-pip/Makefile b/lang/python/python-pip/Makefile
new file mode 100644 (file)
index 0000000..97a5326
--- /dev/null
@@ -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.1.2
+PKG_RELEASE:=1
+
+PYPI_NAME:=pip
+PKG_HASH:=0e7c86f486935893c708287b30bd050a36ac827ec7fe5e43fe7cb198dd835fba
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE.txt
+PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
+CPE_ID:=cpe:/a:python: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/lang/python/python-pip/files/pip.conf b/lang/python/python-pip/files/pip.conf
new file mode 100644 (file)
index 0000000..0890081
--- /dev/null
@@ -0,0 +1,2 @@
+[global]
+cache-dir = /var/cache/pip
diff --git a/lang/python/python-pip/patches/001-pyproject-hooks-pyc-fix.patch b/lang/python/python-pip/patches/001-pyproject-hooks-pyc-fix.patch
new file mode 100644 (file)
index 0000000..27681c1
--- /dev/null
@@ -0,0 +1,13 @@
+--- a/src/pip/_vendor/pyproject_hooks/_in_process/__init__.py
++++ b/src/pip/_vendor/pyproject_hooks/_in_process/__init__.py
+@@ -11,8 +11,8 @@ try:
+ except AttributeError:
+     # Python 3.8 compatibility
+     def _in_proc_script_path():
+-        return resources.path(__package__, '_in_process.py')
++        return resources.path(__package__, '_in_process.pyc')
+ else:
+     def _in_proc_script_path():
+         return resources.as_file(
+-            resources.files(__package__).joinpath('_in_process.py'))
++            resources.files(__package__).joinpath('_in_process.pyc'))
diff --git a/lang/python/python-pip/patches/002-pip-runner-pyc-fix.patch b/lang/python/python-pip/patches/002-pip-runner-pyc-fix.patch
new file mode 100644 (file)
index 0000000..4616fe0
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/src/pip/_internal/build_env.py
++++ b/src/pip/_internal/build_env.py
+@@ -54,7 +54,7 @@ def get_runnable_pip() -> str:
+         # case, we can use that directly.
+         return str(source)
+-    return os.fsdecode(source / "__pip-runner__.py")
++    return os.fsdecode(source / "__pip-runner__.pyc")
+ def _get_system_sitepackages() -> Set[str]:
diff --git a/lang/python/python-pip/patches/003-disable-pip-version-check.patch b/lang/python/python-pip/patches/003-disable-pip-version-check.patch
new file mode 100644 (file)
index 0000000..87a8178
--- /dev/null
@@ -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
+@@ -892,7 +892,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.",
+ )
index 8d81bc3f8c06e1812e7dbe430dff5ee7d300af1e..b478f5b6c2605d4cdde69ff6e785ccdc26c1c59c 100644 (file)
@@ -43,7 +43,7 @@ HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
 
 PKG_CONFIG_DEPENDS:= \
        CONFIG_PACKAGE_python3-pkg-resources \
-       CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip
+       CONFIG_PACKAGE_python3-setuptools
 
 PKG_BUILD_DEPENDS:=bluez python3/host python-build/host python-installer/host python-wheel/host
 HOST_BUILD_DEPENDS:=bzip2/host libffi/host
@@ -213,29 +213,10 @@ define Build/Compile/python3-setuptools
 endef
 endif # CONFIG_PACKAGE_python3-setuptools
 
-ifdef CONFIG_PACKAGE_python3-pip
-define Build/Compile/python3-pip
-       $(HOST_PYTHON3_PIP_VARS) \
-       $(HOST_PYTHON3_PIP) \
-               install \
-               --ignore-installed \
-               --progress-bar off \
-               --root=$(PKG_BUILD_DIR)/install-pip \
-               --prefix=/usr \
-               $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
-       $(call PatchDir,$(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages,./patches-pip,)
-endef
-else
-define Build/Compile/python3-pip
-       ls $(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.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
@@ -366,6 +347,7 @@ HOST_CONFIGURE_ARGS += \
 define Host/Configure
        $(SED) 's/^ENABLE_USER_SITE = None$$$$/ENABLE_USER_SITE = False/' $(HOST_BUILD_DIR)/Lib/site.py
        $(call Host/Configure/Default)
+       ls $(HOST_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
 endef
 
 define Host/Install
@@ -390,7 +372,7 @@ define Host/Install
                touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
        )
        $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
-               $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
+               $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-host-pip,)
                touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
        )
 endef
diff --git a/lang/python/python3/files/python3-package-pip.mk b/lang/python/python3/files/python3-package-pip.mk
deleted file mode 100644 (file)
index 8b547ce..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# 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
-  VERSION:=$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
-  LICENSE:=MIT
-  LICENSE_FILES:=LICENSE.txt
-#  CPE_ID:=cpe:/a:python:pip # not currently handled this way by uscan
-  DEPENDS:=+python3 +python3-setuptools +python-pip-conf
-endef
-
-define Py3Package/python3-pip/install
-       $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
-       $(CP) $(PKG_BUILD_DIR)/install-pip/usr/bin/pip$(PYTHON3_VERSION) $(1)/usr/bin
-       $(LN) pip$(PYTHON3_VERSION) $(1)/usr/bin/pip3
-       $(LN) pip$(PYTHON3_VERSION) $(1)/usr/bin/pip
-       $(CP) \
-               $(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages/pip \
-               $(PKG_BUILD_DIR)/install-pip/usr/lib/python$(PYTHON3_VERSION)/site-packages/pip-$(PYTHON3_PIP_VERSION).dist-info \
-               $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/
-       find $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/ -path '*/__pycache__/*' -delete
-       find $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/ -type d -name __pycache__ -delete
-endef
-
-$(eval $(call Py3BasePackage,python3-pip, \
-       , \
-       DO_NOT_ADD_TO_PACKAGE_DEPENDS \
-))
diff --git a/lang/python/python3/patches-host-pip/.gitkeep b/lang/python/python3/patches-host-pip/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lang/python/python3/patches-pip/001-pep517-pyc-fix.patch b/lang/python/python3/patches-pip/001-pep517-pyc-fix.patch
deleted file mode 100644 (file)
index df5f90c..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-diff --git a/pip/_vendor/pep517/in_process/__init__.py b/pip/_vendor/pep517/in_process/__init__.py
-index 281a356cfe26..77acbfc2670b 100644
---- a/pip/_vendor/pep517/in_process/__init__.py
-+++ b/pip/_vendor/pep517/in_process/__init__.py
-@@ -14,13 +14,21 @@ try:
-     except AttributeError:
-         # Python 3.8 compatibility
-         def _in_proc_script_path():
--            return resources.path(__package__, '_in_process.py')
-+            if resources.is_resource(__package__, '_in_process.py'):
-+                return resources.path(__package__, '_in_process.py')
-+            return resources.path(__package__, '_in_process.pyc')
-     else:
-         def _in_proc_script_path():
-+            if resources.files(__package__).joinpath('_in_process.py').is_file():
-+                return resources.as_file(
-+                    resources.files(__package__).joinpath('_in_process.py'))
-             return resources.as_file(
--                resources.files(__package__).joinpath('_in_process.py'))
-+                resources.files(__package__).joinpath('_in_process.pyc'))
- except ImportError:
-     # Python 3.6 compatibility
-     @contextmanager
-     def _in_proc_script_path():
--        yield pjoin(dirname(abspath(__file__)), '_in_process.py')
-+        _in_proc_script = pjoin(dirname(abspath(__file__)), '_in_process.py')
-+        if not os.path.isfile(_in_proc_script):
-+            _in_proc_script = pjoin(dirname(abspath(__file__)), '_in_process.pyc')
-+        yield _in_proc_script