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

index 5a521f37341c044025e5b73d865760f8c973f879..0a9f0ea85eb732fa0e8f5444f1c5973581c64b0d 100644 (file)
@@ -12,7 +12,7 @@ PYTHON3_VERSION_MICRO:=3
 
 PYTHON3_VERSION:=$(PYTHON3_VERSION_MAJOR).$(PYTHON3_VERSION_MINOR)
 
-PYTHON3_SETUPTOOLS_PKG_RELEASE:=1
+PYTHON3_SETUPTOOLS_PKG_RELEASE:=2
 PYTHON3_PIP_PKG_RELEASE:=3
 
 PYTHON3_SETUPTOOLS_VERSION:=41.2.0
index 64a86b81d621c9bf1b881063129babf70f56c42f..3a562c26219c4873f694d03480c4b3c2d3fcdf29 100644 (file)
@@ -24,6 +24,9 @@ define Py3Package/python3-setuptools/install
                $(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages/setuptools-$(PYTHON3_SETUPTOOLS_VERSION).dist-info \
                $(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages/easy_install.py \
                $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
+       $(CP) \
+               $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/setuptools/site-patch.py \
+               $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/setuptools/site-patch.py.txt
        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
diff --git a/lang/python/python3/patches-setuptools/004-site-patch.patch b/lang/python/python3/patches-setuptools/004-site-patch.patch
new file mode 100644 (file)
index 0000000..39b8c90
--- /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 FileNotFoundError:
++            source = resource_string("setuptools", "site-patch.py.txt")
+         source = source.decode('utf-8')
+         current = ""