From 45bdb70e1ed411f24aae4624563d682a372f287c Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 4 Nov 2016 10:35:03 +0200 Subject: [PATCH 1/5] python: add include guard for python-host.mk and include in Makefile So that it can be included twice. python-package.mk include python-host.mk, but at some point in time python-host.mk is not exported to staging_dir yet. So, to have in python's Makefile, we need to include it in the Makefile, and to prevent double inclusion (if python-host.mk is exported from a previous build), the include guard is added. Also, moved the includes after some vars were set. Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 3 +++ lang/python/files/python-host.mk | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lang/python/Makefile b/lang/python/Makefile index c333f8e08..336c3b0a6 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -7,6 +7,9 @@ include $(TOPDIR)/rules.mk +# This file provides the necsessary host build variables +include ./files/python-host.mk + # The file included below defines PYTHON_VERSION include ./files/python-package.mk diff --git a/lang/python/files/python-host.mk b/lang/python/files/python-host.mk index 0a5eb4193..da24f3dc1 100644 --- a/lang/python/files/python-host.mk +++ b/lang/python/files/python-host.mk @@ -5,6 +5,9 @@ # See /LICENSE for more information. # +ifneq ($(__python_host_mk_inc),1) +__python_host_mk_inc=1 + # Compatibility fallback for older OpenWrt and LEDE versions ifeq ($(STAGING_DIR_HOSTPKG),) $(warning STAGING_DIR_HOSTPKG is unset - falling back to $$(STAGING_DIR)/host) @@ -71,3 +74,4 @@ define Build/Compile/HostPyMod $(3)) endef +endif # __python_host_mk_inc From 6a670f42b117afd2ddbfeb3320e88d701b39dddc Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Mon, 7 Nov 2016 09:31:18 +0200 Subject: [PATCH 2/5] python: move PYTHON_VERSION in own .mk file Allows for more granularity with respect to python-host.mk and python-package.mk inclusions. Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 6 +++++- lang/python/files/python-host.mk | 3 +++ lang/python/files/python-package.mk | 3 +-- lang/python/files/python-version.mk | 10 ++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 lang/python/files/python-version.mk diff --git a/lang/python/Makefile b/lang/python/Makefile index 336c3b0a6..687481fab 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -7,10 +7,13 @@ include $(TOPDIR)/rules.mk +# For PYTHON_VERSION +include ./files/python-version.mk + # This file provides the necsessary host build variables include ./files/python-host.mk -# The file included below defines PYTHON_VERSION +# For PyPackage include ./files/python-package.mk PKG_NAME:=python @@ -142,6 +145,7 @@ define Build/InstallDev $(INSTALL_DATA) \ ./files/python-package.mk \ ./files/python-host.mk \ + ./files/python-version.mk \ $(STAGING_DIR)/mk/ $(CP) \ $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \ diff --git a/lang/python/files/python-host.mk b/lang/python/files/python-host.mk index da24f3dc1..21f238fe0 100644 --- a/lang/python/files/python-host.mk +++ b/lang/python/files/python-host.mk @@ -8,6 +8,9 @@ ifneq ($(__python_host_mk_inc),1) __python_host_mk_inc=1 +# For PYTHON_VERSION +$(call include_mk, python-version.mk) + # Compatibility fallback for older OpenWrt and LEDE versions ifeq ($(STAGING_DIR_HOSTPKG),) $(warning STAGING_DIR_HOSTPKG is unset - falling back to $$(STAGING_DIR)/host) diff --git a/lang/python/files/python-package.mk b/lang/python/files/python-package.mk index 52b6cf37e..2a2e371c3 100644 --- a/lang/python/files/python-package.mk +++ b/lang/python/files/python-package.mk @@ -5,8 +5,7 @@ # See /LICENSE for more information. # -PYTHON_VERSION:=2.7 -PYTHON_VERSION_MICRO:=12 +$(call include_mk, python-version.mk) PYTHON_DIR:=$(STAGING_DIR)/usr PYTHON_BIN_DIR:=$(PYTHON_DIR)/bin diff --git a/lang/python/files/python-version.mk b/lang/python/files/python-version.mk new file mode 100644 index 000000000..6905c3d68 --- /dev/null +++ b/lang/python/files/python-version.mk @@ -0,0 +1,10 @@ +# +# Copyright (C) 2016 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +PYTHON_VERSION:=2.7 +PYTHON_VERSION_MICRO:=12 + From e81632ab90c63237eab0acb092a226ea1367b3cb Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Mon, 7 Nov 2016 09:45:32 +0200 Subject: [PATCH 3/5] python3: disable ensurepip on package & host builds Signed-off-by: Alexandru Ardelean --- lang/python3/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/python3/Makefile b/lang/python3/Makefile index 2463f92a0..2d177ab3a 100644 --- a/lang/python3/Makefile +++ b/lang/python3/Makefile @@ -127,7 +127,7 @@ CONFIGURE_ARGS+= \ --with-threads \ --with-system-ffi="$(STAGING_DIR)/usr" \ --without-pymalloc \ - --without-ensurepip \ + --with-ensurepip=no \ $(ENABLE_IPV6) \ CONFIG_SITE="$(PKG_BUILD_DIR)/config.site" \ OPT="$(TARGET_CFLAGS)" @@ -223,7 +223,7 @@ HOST_CONFIGURE_ARGS+= \ --sbindir=$(HOST_BUILD_PREFIX)/bin \ --with-system-expat=$(HOST_BUILD_PREFIX) \ --with-system-ffi=$(HOST_BUILD_PREFIX) \ - --with-ensurepip=upgrade \ + --with-ensurepip=no \ CONFIG_SITE= \ CFLAGS="$(HOST_CFLAGS)" From 7d89234b86df46b4a11fbf35fba8e5102396b539 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Mon, 7 Nov 2016 09:46:47 +0200 Subject: [PATCH 4/5] python,python3: get rid of HOST_CFLAGS They rely on system paths and are a bit misleading/confusing. As seen here: https://github.com/openwrt/packages/issues/3339 Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 4 ---- lang/python3/Makefile | 4 ---- 2 files changed, 8 deletions(-) diff --git a/lang/python/Makefile b/lang/python/Makefile index 687481fab..3235b4557 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -220,10 +220,6 @@ define PyPackage/python/filespec -|$(PYTHON_PKG_DIR) endef -HOST_CFLAGS+= \ - -I/usr/include/ncursesw \ - -I/usr/include/ncurses - HOST_CONFIGURE_ARGS+= \ --without-cxx-main \ --without-pymalloc \ diff --git a/lang/python3/Makefile b/lang/python3/Makefile index 2d177ab3a..c46f3bd56 100644 --- a/lang/python3/Makefile +++ b/lang/python3/Makefile @@ -208,10 +208,6 @@ define Py3Package/python3/filespec -|$(PYTHON3_PKG_DIR) endef -HOST_CFLAGS+= \ - -I/usr/include/ncursesw \ - -I/usr/include/ncurses - HOST_CONFIGURE_ARGS+= \ --without-cxx-main \ --without-pymalloc \ From 9eca45fdf16bcf8237102663fe7c91795687929d Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 4 Nov 2016 11:00:07 +0200 Subject: [PATCH 5/5] python, python3: unify HOST_ vars and get rid of HOST_CFLAGS --sysconfigdir and --sbindir are obtained from --prefix and --exec-prefix, so no need to have them explicitly Signed-off-by: Alexandru Ardelean --- lang/python/Makefile | 23 ++++++++++------------- lang/python/files/python-host.mk | 4 ++-- lang/python3/Makefile | 19 ++++++++----------- lang/python3/files/python3-package.mk | 5 +++-- 4 files changed, 23 insertions(+), 28 deletions(-) diff --git a/lang/python/Makefile b/lang/python/Makefile index 3235b4557..3eb4e9dad 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -151,13 +151,13 @@ define Build/InstallDev $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \ $(1)/usr/include/ $(CP) \ - $(HOST_BUILD_PREFIX)/lib/python$(PYTHON_VERSION) \ + $(HOST_PYTHON_LIB_DIR) \ $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \ $(1)/usr/lib/ $(CP) \ - $(HOST_BUILD_PREFIX)/lib/pkgconfig/python.pc \ - $(HOST_BUILD_PREFIX)/lib/pkgconfig/python2.pc \ - $(HOST_BUILD_PREFIX)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \ + $(HOST_PYTHON_DIR)/lib/pkgconfig/python.pc \ + $(HOST_PYTHON_DIR)/lib/pkgconfig/python2.pc \ + $(HOST_PYTHON_DIR)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \ $(1)/usr/lib/pkgconfig $(CP) \ $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \ @@ -224,20 +224,17 @@ HOST_CONFIGURE_ARGS+= \ --without-cxx-main \ --without-pymalloc \ --with-threads \ - --prefix=$(HOST_BUILD_PREFIX) \ - --exec-prefix=$(HOST_BUILD_PREFIX) \ - --sysconfdir=$(HOST_BUILD_PREFIX)/etc \ - --localstatedir=$(HOST_BUILD_PREFIX)/var \ - --sbindir=$(HOST_BUILD_PREFIX)/bin \ - --with-system-expat=$(HOST_BUILD_PREFIX) \ - --with-system-ffi=$(HOST_BUILD_PREFIX) \ + --prefix=$(HOST_PYTHON_DIR) \ + --exec-prefix=$(HOST_PYTHON_DIR) \ + --with-system-expat=$(STAGING_DIR_HOSTPKG) \ + --with-system-ffi=$(STAGING_DIR_HOSTPKG) \ CONFIG_SITE= \ CFLAGS="$(HOST_CFLAGS)" define Host/Install $(MAKE) -C $(HOST_BUILD_DIR) install - $(INSTALL_DIR) $(HOST_BUILD_PREFIX)/bin/ - $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_BUILD_PREFIX)/bin/pgen2 + $(INSTALL_DIR) $(HOST_PYTHON_DIR)/bin/ + $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON_DIR)/bin/pgen2 endef $(eval $(call HostBuild)) diff --git a/lang/python/files/python-host.mk b/lang/python/files/python-host.mk index 21f238fe0..dc0c0c049 100644 --- a/lang/python/files/python-host.mk +++ b/lang/python/files/python-host.mk @@ -21,11 +21,11 @@ HOST_PYTHON_DIR:=$(STAGING_DIR_HOSTPKG) HOST_PYTHON_INC_DIR:=$(HOST_PYTHON_DIR)/include/python$(PYTHON_VERSION) HOST_PYTHON_LIB_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION) -HOST_PYTHON_PKG_DIR:=/lib/python$(PYTHON_VERSION)/site-packages +HOST_PYTHON_PKG_DIR:=$(HOST_PYTHON_DIR)/lib/python$(PYTHON_VERSION)/site-packages HOST_PYTHON_BIN:=$(HOST_PYTHON_DIR)/bin/python$(PYTHON_VERSION) -HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR_HOSTPKG)/$(HOST_PYTHON_PKG_DIR) +HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(HOST_PYTHON_PKG_DIR) define HostPython if [ "$(strip $(3))" == "HOST" ]; then \ diff --git a/lang/python3/Makefile b/lang/python3/Makefile index c46f3bd56..2e0f872a0 100644 --- a/lang/python3/Makefile +++ b/lang/python3/Makefile @@ -146,7 +146,7 @@ define Build/InstallDev $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \ $(1)/usr/include/ $(CP) \ - $(HOST_BUILD_PREFIX)/lib/python$(PYTHON_VERSION) \ + $(HOST_PYTHON3_LIB_DIR) \ $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \ $(1)/usr/lib/ $(CP) \ @@ -212,13 +212,10 @@ HOST_CONFIGURE_ARGS+= \ --without-cxx-main \ --without-pymalloc \ --with-threads \ - --prefix=$(HOST_BUILD_PREFIX) \ - --exec-prefix=$(HOST_BUILD_PREFIX) \ - --sysconfdir=$(HOST_BUILD_PREFIX)/etc \ - --localstatedir=$(HOST_BUILD_PREFIX)/var \ - --sbindir=$(HOST_BUILD_PREFIX)/bin \ - --with-system-expat=$(HOST_BUILD_PREFIX) \ - --with-system-ffi=$(HOST_BUILD_PREFIX) \ + --prefix=$(HOST_PYTHON3_DIR) \ + --exec-prefix=$(HOST_PYTHON3_DIR) \ + --with-system-expat=$(STAGING_DIR_HOSTPKG) \ + --with-system-ffi=$(STAGING_DIR_HOSTPKG) \ --with-ensurepip=no \ CONFIG_SITE= \ CFLAGS="$(HOST_CFLAGS)" @@ -231,9 +228,9 @@ endef define Host/Install $(MAKE) -C $(HOST_BUILD_DIR) install - $(INSTALL_DIR) $(HOST_BUILD_PREFIX)/bin/ - $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_BUILD_PREFIX)/bin/pgen3 - $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(HOST_BUILD_PREFIX)/bin/_freeze_importlib + $(INSTALL_DIR) $(HOST_PYTHON3_DIR)/bin/ + $(INSTALL_BIN) $(HOST_BUILD_DIR)/Parser/pgen $(HOST_PYTHON3_DIR)/bin/pgen3 + $(INSTALL_BIN) $(HOST_BUILD_DIR)/Programs/_freeze_importlib $(HOST_PYTHON3_DIR)/bin/_freeze_importlib endef $(eval $(call HostBuild)) diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk index 1a12d13dd..60feaf195 100644 --- a/lang/python3/files/python3-package.mk +++ b/lang/python3/files/python3-package.mk @@ -26,8 +26,9 @@ PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages PYTHON3:=python$(PYTHON3_VERSION) -HOST_PYTHON3_LIB_DIR:=$(STAGING_DIR_HOSTPKG)/lib/python$(PYTHON3_VERSION) -HOST_PYTHON3_BIN:=$(STAGING_DIR_HOSTPKG)/bin/python3 +HOST_PYTHON3_DIR:=$(STAGING_DIR_HOSTPKG) +HOST_PYTHON3_LIB_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION) +HOST_PYTHON3_BIN:=$(HOST_PYTHON3_DIR)/bin/python3 PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR) define HostPython3