From 32fb2ba0d6b85676d882977f81cbeecac45aa81d Mon Sep 17 00:00:00 2001 From: Jeffery To Date: Thu, 21 May 2020 20:18:25 +0800 Subject: [PATCH] python-setuptools: Fix error when installing from source When a Python package is installed from source (i.e. using setup.py) into a custom location (with --home), setuptools may want to create a site.py file in the custom location. This file is created based on the source code of site-patch.py, a file bundled with setuptools. Because the normal OpenWrt setuptools package does not contain Python source code, this file is missing and the installation will end with an error. This copies site-patch.py to site-patch.py.txt so that it will be included in python3-setuptools, and patches setuptools to look for this file. See https://github.com/openwrt/packages/issues/12223 Signed-off-by: Jeffery To --- lang/python/python-version.mk | 2 +- .../python/files/python-package-setuptools.mk | 3 +++ .../python/patches-setuptools/004-site-patch.patch | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lang/python/python/patches-setuptools/004-site-patch.patch diff --git a/lang/python/python-version.mk b/lang/python/python-version.mk index 16562c538b..d88db21bdd 100644 --- a/lang/python/python-version.mk +++ b/lang/python/python-version.mk @@ -8,7 +8,7 @@ PYTHON_VERSION:=2.7 PYTHON_VERSION_MICRO:=18 -PYTHON_SETUPTOOLS_PKG_RELEASE:=1 +PYTHON_SETUPTOOLS_PKG_RELEASE:=2 PYTHON_PIP_PKG_RELEASE:=2 PYTHON_SETUPTOOLS_VERSION:=41.2.0 diff --git a/lang/python/python/files/python-package-setuptools.mk b/lang/python/python/files/python-package-setuptools.mk index 305a515b74..c9696fb961 100644 --- a/lang/python/python/files/python-package-setuptools.mk +++ b/lang/python/python/files/python-package-setuptools.mk @@ -23,6 +23,9 @@ define PyPackage/python-setuptools/install $(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/setuptools-$(PYTHON_SETUPTOOLS_VERSION).dist-info \ $(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/easy_install.py \ $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages + $(CP) \ + $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages/setuptools/site-patch.py \ + $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages/setuptools/site-patch.py.txt endef $(eval $(call PyBasePackage,python-setuptools, \ diff --git a/lang/python/python/patches-setuptools/004-site-patch.patch b/lang/python/python/patches-setuptools/004-site-patch.patch new file mode 100644 index 0000000000..b4c89b5d09 --- /dev/null +++ b/lang/python/python/patches-setuptools/004-site-patch.patch @@ -0,0 +1,14 @@ +--- a/setuptools/command/easy_install.py ++++ b/setuptools/command/easy_install.py +@@ -1315,7 +1315,10 @@ class easy_install(Command): + return # already did it, or don't need to + + sitepy = os.path.join(self.install_dir, "site.py") +- source = resource_string("setuptools", "site-patch.py") ++ try: ++ source = resource_string("setuptools", "site-patch.py") ++ except IOError: ++ source = resource_string("setuptools", "site-patch.py.txt") + source = source.decode('utf-8') + current = "" + -- 2.30.2