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 <jeffery.to@gmail.com>
This commit is contained in:
Jeffery To 2020-05-21 20:18:25 +08:00
parent 6dac29693f
commit 32fb2ba0d6
3 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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, \

View file

@ -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 = ""