diff --git a/lang/python/Makefile b/lang/python/Makefile index c333f8e08..3eb4e9dad 100644 --- a/lang/python/Makefile +++ b/lang/python/Makefile @@ -7,7 +7,13 @@ include $(TOPDIR)/rules.mk -# The file included below defines PYTHON_VERSION +# For PYTHON_VERSION +include ./files/python-version.mk + +# This file provides the necsessary host build variables +include ./files/python-host.mk + +# For PyPackage include ./files/python-package.mk PKG_NAME:=python @@ -139,18 +145,19 @@ 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) \ $(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 \ @@ -213,28 +220,21 @@ 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 \ --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 0a5eb4193..dc0c0c049 100644 --- a/lang/python/files/python-host.mk +++ b/lang/python/files/python-host.mk @@ -5,6 +5,12 @@ # See /LICENSE for more information. # +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) @@ -15,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 \ @@ -71,3 +77,4 @@ define Build/Compile/HostPyMod $(3)) endef +endif # __python_host_mk_inc 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 + diff --git a/lang/python3/Makefile b/lang/python3/Makefile index 2463f92a0..2e0f872a0 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)" @@ -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) \ @@ -208,22 +208,15 @@ 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 \ --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) \ - --with-ensurepip=upgrade \ + --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)" @@ -235,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