Browse Source

gunicorn: convert to Python packaging format + add Python3 variant

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>
lilik-openwrt-22.03
Alexandru Ardelean 5 years ago
parent
commit
5f9ea76e7a
1 changed files with 87 additions and 19 deletions
  1. +87
    -19
      lang/python/gunicorn/Makefile

+ 87
- 19
lang/python/gunicorn/Makefile View 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))

Loading…
Cancel
Save