python,python3: Record PKG_RELEASE for host setuptools/pip
authorJeffery To <jeffery.to@gmail.com>
Fri, 31 May 2019 19:52:23 +0000 (03:52 +0800)
committerJeffery To <jeffery.to@gmail.com>
Fri, 31 May 2019 19:52:23 +0000 (03:52 +0800)
This changes the "patched" indicator files for host setuptools and pip
to include their PKG_RELEASE values. This also removes host setuptools
and/or pip before host install, if the installed copy does not match the
version (and PKG_RELEASE) of the copy to be installed.

This will allow added or removed patches to affect host setuptools /
pip, since these changes will cause PKG_RELEASE to be incremented.

This also fixes the host install error, when the install tries to patch
an already patched copy of setuptools. (This error occurs because the
existing indicator files do not have version numbers in their file
names, whereas host install expected version numbers to be present.)

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/python/python/Makefile
lang/python/python3/Makefile

index 27f6a5bf8101cd0b23a05cbb5a21a5e45552f348..c73997e8a6b609ea3a8fc41c738f4630fbe54d4b 100644 (file)
@@ -311,18 +311,32 @@ define Host/Compile
 endef
 
 define Host/Install
+       $(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)),,
+               rm -rf \
+                       $(HOST_PYTHON_PKG_DIR)/easy_install.py \
+                       $(HOST_PYTHON_PKG_DIR)/pkg_resources \
+                       $(HOST_PYTHON_PKG_DIR)/setuptools \
+                       $(HOST_PYTHON_PKG_DIR)/setuptools-* \
+                       $(HOST_PYTHON_PKG_DIR)/.setuptools-patched* \
+                       $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_*
+       )
+       $(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.pip_installed_$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)),,
+               rm -rf \
+                       $(HOST_PYTHON_PKG_DIR)/pip \
+                       $(HOST_PYTHON_PKG_DIR)/pip-* \
+                       $(HOST_PYTHON_PKG_DIR)/.pip-patched* \
+                       $(HOST_PYTHON_PKG_DIR)/.pip_installed_*
+       )
        $(MAKE) -C $(HOST_BUILD_DIR) install
        $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/
        $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2
-       $(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.setuptools-patched-$(PYTHON_SETUPTOOLS_VERSION)),,
+       $(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)),,
                $(call HostPatchDir,$(HOST_PYTHON_PKG_DIR),./patches-setuptools,)
-               rm -f $(HOST_PYTHON_PKG_DIR)/.setuptools-patched-*
-               touch $(HOST_PYTHON_PKG_DIR)/.setuptools-patched-$(PYTHON_SETUPTOOLS_VERSION)
+               touch $(HOST_PYTHON_PKG_DIR)/.setuptools_installed_$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)
        )
-       $(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.pip-patched-$(PYTHON_PIP_VERSION)),,
+       $(if $(wildcard $(HOST_PYTHON_PKG_DIR)/.pip_installed_$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)),,
                $(call HostPatchDir,$(HOST_PYTHON_PKG_DIR),./patches-pip,)
-               rm -f $(HOST_PYTHON_PKG_DIR)/.pip-patched-*
-               touch $(HOST_PYTHON_PKG_DIR)/.pip-patched-$(PYTHON_PIP_VERSION)
+               touch $(HOST_PYTHON_PKG_DIR)/.pip_installed_$(PYTHON_PIP_VERSION)-$(PYTHON_PIP_PKG_RELEASE)
        )
 endef
 
index 76be3147245c3f29aa3dd5b21f59f0f10f564732..9c63beae0f4f84023de3cb61b17dee8847754268 100644 (file)
@@ -306,18 +306,32 @@ define Host/Compile
 endef
 
 define Host/Install
+       $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
+               rm -rf \
+                       $(HOST_PYTHON3_PKG_DIR)/easy_install.py \
+                       $(HOST_PYTHON3_PKG_DIR)/pkg_resources \
+                       $(HOST_PYTHON3_PKG_DIR)/setuptools \
+                       $(HOST_PYTHON3_PKG_DIR)/setuptools-* \
+                       $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched* \
+                       $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_*
+       )
+       $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
+               rm -rf \
+                       $(HOST_PYTHON3_PKG_DIR)/pip \
+                       $(HOST_PYTHON3_PKG_DIR)/pip-* \
+                       $(HOST_PYTHON3_PKG_DIR)/.pip-patched* \
+                       $(HOST_PYTHON3_PKG_DIR)/.pip_installed_*
+       )
        $(MAKE) -C $(HOST_BUILD_DIR) install
        $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/
        $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3
-       $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched-$(PYTHON3_SETUPTOOLS_VERSION)),,
+       $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)),,
                $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-setuptools,)
-               rm -f $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched-*
-               touch $(HOST_PYTHON3_PKG_DIR)/.setuptools-patched-$(PYTHON3_SETUPTOOLS_VERSION)
+               touch $(HOST_PYTHON3_PKG_DIR)/.setuptools_installed_$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
        )
-       $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip-patched-$(PYTHON3_PIP_VERSION)),,
+       $(if $(wildcard $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)),,
                $(call HostPatchDir,$(HOST_PYTHON3_PKG_DIR),./patches-pip,)
-               rm -f $(HOST_PYTHON3_PKG_DIR)/.pip-patched-*
-               touch $(HOST_PYTHON3_PKG_DIR)/.pip-patched-$(PYTHON3_PIP_VERSION)
+               touch $(HOST_PYTHON3_PKG_DIR)/.pip_installed_$(PYTHON3_PIP_VERSION)-$(PYTHON3_PIP_PKG_RELEASE)
        )
 endef