gunicorn: convert to Python packaging format + add Python3 variant
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Mon, 12 Aug 2019 07:14:16 +0000 (10:14 +0300)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 20 Sep 2019 11:11:08 +0000 (14:11 +0300)
And splitting the gunicorn[3] binary/executable away from the
python[3]-gunicorn libraries. This was inspired from Debian packaging.

The gunicorn[3] binaries require the new `python[3]-pkg-resources`
libraries to run, which add ~1.1 MB on the [ram]disk when uncompressed.

For the Python2 variant, the `_gaiohttp.py` is dropped as it fails to
compile, so it would likely be unusable anyway:
```
  File "/usr/lib/python2.7/site-packages/gunicorn/workers/_gaiohttp.py", line 84
    yield from self.wsgi.close()
             ^
  SyntaxError: invalid syntax

```

People around the web recommend this as well:
 https://stackoverflow.com/questions/25611140/syntax-error-installing-gunicorn
 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=803170
 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=803202

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
lang/python/gunicorn/Makefile

index 2aa87f4785942861589d7cea345b776912e6e97e..4ba9f2195960c487d1a283c3e6000bf11b609ecf 100644 (file)
@@ -10,43 +10,111 @@ include $(TOPDIR)/rules.mk
 PKG_NAME:=gunicorn
 PKG_VERSION:=19.9.0
 PKG_RELEASE=2
-PKG_LICENSE:=MIT
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://files.pythonhosted.org/packages/source/g/gunicorn
 PKG_HASH:=fa2662097c66f920f53f70621c6c58ca4a3c4d3434205e608e121b5b3b71f4f3
+
 PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(BUILD_VARIANT)-$(PKG_NAME)-$(PKG_VERSION)
 
 include $(INCLUDE_DIR)/package.mk
 include ../python-package.mk
+include ../python3-package.mk
+
+PKG_UNPACK:=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE)
+
+define Package/gunicorn/Default
+  SUBMENU:=Python
+  SECTION:=lang
+  CATEGORY:=Languages
+  TITLE:=WSGI HTTP Server for UNIX
+  URL:=https://gunicorn.org
+endef
+
+define Package/python-gunicorn
+$(call Package/gunicorn/Default)
+  DEPENDS:=+python
+  VARIANT:=python
+endef
+
+define Package/python-gunicorn/description
+    WSGI HTTP Server for UNIX (libraries)
+endef
+
+define PyPackage/python-gunicorn/filespec
++|$(PYTHON_PKG_DIR)
+-|$(PYTHON_PKG_DIR)/gunicorn/workers/_gaiohttp.py
+endef
+
+define Package/python3-gunicorn
+$(call Package/gunicorn/Default)
+  DEPENDS:=+python3
+  VARIANT:=python3
+endef
+
+define Package/python3-gunicorn/description
+$(call define Package/python-gunicorn/description)
+.
+(Variant for Python3)
+endef
+
+# Make sure that the binaries are not installed with the libraries
+# That means adding some empty Py[3]Package/gunicorn[3]/install rules
+define PyPackage/python-gunicorn/install
+       :
+endef
+
+define Py3Package/python3-gunicorn/install
+       :
+endef
 
 define Package/gunicorn
-    SUBMENU:=Python
-    SECTION:=lang
-    CATEGORY:=Languages
-    TITLE:=WSGI HTTP Server for UNIX
-    URL:=https://gunicorn.org
-    DEPENDS:=+python +python-setuptools
+$(call Package/gunicorn/Default)
+  DEPENDS:=+python +python-pkg-resources +python-gunicorn
 endef
 
 define Package/gunicorn/description
-    WSGI HTTP Server for UNIX
+    WSGI HTTP Server for UNIX (daemon)
+endef
+
+define Package/gunicorn/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+       $(call PyShebang,$(1)/usr/bin/*)
 endef
 
-define Build/Compile
-       $(call Build/Compile/PyMod,,install --prefix=/usr --root=$(PKG_INSTALL_DIR))
+define Package/gunicorn3
+$(call Package/gunicorn/Default)
+  DEPENDS:=+python3 +python3-pkg-resources +python3-gunicorn
 endef
 
-define Package/gunicorn/install
-       $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)
+define Package/gunicorn3/description
+$(call define Package/gunicorn/description)
+.
+(Variant for Python3)
+endef
+
+define Package/gunicorn3/install
        $(INSTALL_DIR) $(1)/usr/bin
-       $(CP) \
-           $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \
-           $(1)$(PYTHON_PKG_DIR)
-       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gunicorn* \
-           $(1)/usr/bin
-       # fix python exec path in scripts
-       $(SED) 's/#!.*/#!\/usr\/bin\/python/g' $(1)/usr/bin/gunicorn*
+       $(INSTALL_BIN) \
+               $(PKG_INSTALL_DIR)/usr/bin/gunicorn \
+               $(1)/usr/bin/gunicorn3
+       $(INSTALL_BIN) \
+               $(PKG_INSTALL_DIR)/usr/bin/gunicorn_paster \
+               $(1)/usr/bin/gunicorn3_paster
+       $(call Py3Shebang,$(1)/usr/bin/*)
 endef
 
+$(eval $(call PyPackage,python-gunicorn))
+$(eval $(call BuildPackage,python-gunicorn))
+$(eval $(call BuildPackage,python-gunicorn-src))
 $(eval $(call BuildPackage,gunicorn))
+
+$(eval $(call Py3Package,python3-gunicorn))
+$(eval $(call BuildPackage,python3-gunicorn))
+$(eval $(call BuildPackage,python3-gunicorn-src))
+$(eval $(call BuildPackage,gunicorn3))