Browse Source

Merge pull request #9971 from commodo/python-gunicorn

gunicorn: convert to Python packaging format + add Python3 variant
lilik-openwrt-22.03
Hannu Nyman 5 years ago
committed by GitHub
parent
commit
e1aa365822
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 187 additions and 40 deletions
  1. +87
    -19
      lang/python/gunicorn/Makefile
  2. +3
    -10
      lang/python/python-package-install.sh
  3. +8
    -2
      lang/python/python-package.mk
  4. +10
    -1
      lang/python/python/Makefile
  5. +28
    -0
      lang/python/python/files/python-package-pkg-resources.mk
  6. +1
    -2
      lang/python/python/files/python-package-setuptools.mk
  7. +9
    -3
      lang/python/python3-package.mk
  8. +10
    -1
      lang/python/python3/Makefile
  9. +30
    -0
      lang/python/python3/files/python3-package-pkg-resources.mk
  10. +1
    -2
      lang/python/python3/files/python3-package-setuptools.mk

+ 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))

+ 3
- 10
lang/python/python-package-install.sh View File

@ -54,8 +54,6 @@ python="$4"
mode="$5"
filespec="$6"
SED="${SED:-sed -e}"
find "$src_dir" -name "*.exe" -delete
process_filespec "$src_dir" "$dst_dir" "$filespec" || {
@ -63,12 +61,6 @@ process_filespec "$src_dir" "$dst_dir" "$filespec" || {
exit 1
}
usr_bin_dir="$dst_dir/usr/bin"
if [ -d "$usr_bin_dir" ] ; then
$SED "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python${ver}," -i --follow-symlinks $usr_bin_dir/*
fi
if [ "$mode" == "sources" ] ; then
# Copy only python source files
find "$dst_dir" -not -type d -not -name "*.py" -delete
@ -77,8 +69,9 @@ if [ "$mode" == "sources" ] ; then
exit 0
fi
legacy=
[ "$ver" == "3" ] && legacy="-b"
if [ "$ver" == "3" ] ; then
legacy="-b"
fi
# default max recursion is 10
max_recursion_level=20


+ 8
- 2
lang/python/python-package.mk View File

@ -35,6 +35,10 @@ ifdef CONFIG_USE_MIPS16
TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
endif
define PyShebang
$(SED) "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python2," -i --follow-symlinks $(1)
endef
define PyPackage
define Package/$(1)-src
@ -74,11 +78,13 @@ define PyPackage
define Package/$(1)/install
$$(call PyPackage/$(1)/install,$$(1))
SED="$(SED)" \
$(SHELL) $(python_mk_path)python-package-install.sh "2" \
"$(PKG_INSTALL_DIR)" "$$(1)" \
"$(HOST_PYTHON_BIN)" "$$(2)" \
"$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)"
"$$$$$$$$$$(call shvar,PyPackage/$(1)/filespec)" && \
if [ -d "$$(1)/usr/bin" ]; then \
$(call PyShebang,$$(1)/usr/bin/*) ; \
fi
endef
define Package/$(1)-src/install


+ 10
- 1
lang/python/python/Makefile View File

@ -12,7 +12,7 @@ include ../python-version.mk
PKG_NAME:=python
PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
PKG_RELEASE:=9
PKG_RELEASE:=10
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
@ -39,6 +39,7 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_python-pkg-resources \
CONFIG_PACKAGE_python-setuptools CONFIG_PACKAGE_python-pip \
CONFIG_PYTHON_BLUETOOTH_SUPPORT
@ -169,6 +170,14 @@ define Build/Prepare
endef
ifdef CONFIG_PACKAGE_python-setuptools
PYTHON_SETUPTOOLS_BUILD:=1
endif
ifdef CONFIG_PACKAGE_python-pkg-resources
PYTHON_SETUPTOOLS_BUILD:=1
endif
ifeq ($(PYTHON_SETUPTOOLS_BUILD),1)
define Build/Compile/python-setuptools
$(HOST_PYTHON_PIP) \
--disable-pip-version-check \


+ 28
- 0
lang/python/python/files/python-package-pkg-resources.mk View File

@ -0,0 +1,28 @@
#
# Copyright (C) 2019 Alexandru Ardelean <ardeleanalex@gmail.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python-pkg-resources
$(call Package/python/Default)
TITLE:=Python $(PYTHON_VERSION) pkg_resources module (part of etuptools)
VERSION:=$(PYTHON_SETUPTOOLS_VERSION)-$(PYTHON_SETUPTOOLS_PKG_RELEASE)
LICENSE:=MIT
LICENSE_FILES:=LICENSE
# CPE_ID:=cpe:/a:python:setuptools # not currently handled this way by uscan
DEPENDS:=+python
endef
define PyPackage/python-pkg-resources/install
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
$(CP) \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/pkg_resources \
$(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
endef
$(eval $(call PyBasePackage,python-pkg-resources, \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 1
- 2
lang/python/python/files/python-package-setuptools.mk View File

@ -12,14 +12,13 @@ $(call Package/python/Default)
LICENSE:=MIT
LICENSE_FILES:=LICENSE
# CPE_ID:=cpe:/a:python:setuptools # not currently handled this way by uscan
DEPENDS:=+python
DEPENDS:=+python +python-pkg-resources
endef
define PyPackage/python-setuptools/install
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages
$(CP) $(PKG_BUILD_DIR)/install-setuptools/usr/bin/* $(1)/usr/bin
$(CP) \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/pkg_resources \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON_VERSION)/site-packages/setuptools \
$(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 \


+ 9
- 3
lang/python/python3-package.mk View File

@ -34,6 +34,10 @@ ifdef CONFIG_USE_MIPS16
TARGET_CFLAGS += -mno-mips16 -mno-interlink-mips16
endif
define Py3Shebang
$(SED) "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python3," -i --follow-symlinks $(1)
endef
define Py3Package
define Package/$(1)-src
@ -73,12 +77,14 @@ define Py3Package
define Package/$(1)/install
$$(call Py3Package/$(1)/install,$$(1))
SED="$(SED)" \
$(SHELL) $(python3_mk_path)python-package-install.sh "3" \
"$(PKG_INSTALL_DIR)" "$$(1)" \
"$(HOST_PYTHON3_BIN)" "$$(2)" \
"$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)"
endef
"$$$$$$$$$$(call shvar,Py3Package/$(1)/filespec)" && \
if [ -d "$$(1)/usr/bin" ]; then \
$(call Py3Shebang,$$(1)/usr/bin/*) ; \
fi
endef
define Package/$(1)-src/install
$$(call Package/$(1)/install,$$(1),sources)


+ 10
- 1
lang/python/python3/Makefile View File

@ -14,7 +14,7 @@ PYTHON_VERSION:=$(PYTHON3_VERSION)
PYTHON_VERSION_MICRO:=$(PYTHON3_VERSION_MICRO)
PKG_NAME:=python3
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
@ -41,6 +41,7 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_python3-pkg-resources \
CONFIG_PACKAGE_python3-setuptools CONFIG_PACKAGE_python3-pip \
CONFIG_PYTHON3_BLUETOOTH_SUPPORT
@ -172,6 +173,14 @@ define Build/Prepare
endef
ifdef CONFIG_PACKAGE_python3-setuptools
PYTHON3_SETUPTOOLS_BUILD:=1
endif
ifdef CONFIG_PACKAGE_python3-pkg-resources
PYTHON3_SETUPTOOLS_BUILD:=1
endif
ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
define Build/Compile/python3-setuptools
$(HOST_PYTHON3_PIP) \
--disable-pip-version-check \


+ 30
- 0
lang/python/python3/files/python3-package-pkg-resources.mk View File

@ -0,0 +1,30 @@
#
# Copyright (C) 2019 Alexandru Ardelean <ardeleanalex@gmail.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
define Package/python3-pkg-resources
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) pkg_resources module (part of setuptools)
VERSION:=$(PYTHON3_SETUPTOOLS_VERSION)-$(PYTHON3_SETUPTOOLS_PKG_RELEASE)
LICENSE:=MIT
LICENSE_FILES:=LICENSE
# CPE_ID:=cpe:/a:python:setuptools # not currently handled this way by uscan
DEPENDS:=+python3
endef
define Py3Package/python3-pkg-resources/install
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
$(CP) \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages/pkg_resources \
$(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages
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
$(eval $(call Py3BasePackage,python3-pkg-resources, \
, \
DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))

+ 1
- 2
lang/python/python3/files/python3-package-setuptools.mk View File

@ -12,7 +12,7 @@ $(call Package/python3/Default)
LICENSE:=MIT
LICENSE_FILES:=LICENSE
# CPE_ID:=cpe:/a:python:setuptools # not currently handled this way by uscan
DEPENDS:=+python3
DEPENDS:=+python3 +python3-pkg-resources
endef
define Py3Package/python3-setuptools/install
@ -20,7 +20,6 @@ define Py3Package/python3-setuptools/install
$(CP) $(PKG_BUILD_DIR)/install-setuptools/usr/bin/easy_install-* $(1)/usr/bin
$(LN) easy_install-$(PYTHON3_VERSION) $(1)/usr/bin/easy_install-3
$(CP) \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages/pkg_resources \
$(PKG_BUILD_DIR)/install-setuptools/usr/lib/python$(PYTHON3_VERSION)/site-packages/setuptools \
$(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 \


Loading…
Cancel
Save