python-setuptools: Fix error when installing from source 12247/head
authorJeffery To <jeffery.to@gmail.com>
Thu, 21 May 2020 12:18:25 +0000 (20:18 +0800)
committerJeffery To <jeffery.to@gmail.com>
Thu, 21 May 2020 14:07:17 +0000 (22:07 +0800)
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>
lang/python/python-version.mk
lang/python/python/files/python-package-setuptools.mk
lang/python/python/patches-setuptools/004-site-patch.patch [new file with mode: 0644]

index 16562c538b181a063589752119e22041989ea82c..d88db21bdd09d0b58f15907a21ec48596dfc1919 100644 (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
index 305a515b7466cabcbf69576c662c2ca5bd5d2ea3..c9696fb9611a2edd76a882a6216ef52d390b4b26 100644 (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, \
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 (file)
index 0000000..b4c89b5
--- /dev/null
@@ -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 = ""