aboutsummaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorAlexandru Ardelean <ardeleanalex@gmail.com>2017-01-04 11:27:36 +0200
committerAlexandru Ardelean <ardeleanalex@gmail.com>2017-01-04 17:18:50 +0200
commit3af20278869ad43ead7361616887685231a2fb97 (patch)
tree464fa25f9b903d9fc1e742dedf1fbb8ba907100f /lang
parentae5d8d674b43e1590c5a064a24bc84ae78ba1408 (diff)
python3: sync makefiles with python package
Technically, this just updates build details. No functionality change to package itself. So, no need to increase PKG_RELEASE on this change. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Diffstat (limited to 'lang')
-rw-r--r--lang/python3/Makefile13
-rw-r--r--lang/python3/files/python3-host.mk96
-rw-r--r--lang/python3/files/python3-package-dev.mk4
-rw-r--r--lang/python3/files/python3-package-lib2to3.mk2
-rw-r--r--lang/python3/files/python3-package.mk67
5 files changed, 152 insertions, 30 deletions
diff --git a/lang/python3/Makefile b/lang/python3/Makefile
index 7304affe7..aa758b563 100644
--- a/lang/python3/Makefile
+++ b/lang/python3/Makefile
@@ -25,6 +25,10 @@ PKG_HASH:=b0c5f904f685e32d9232f7bdcbece9819a892929063b6e385414ad2dd6a23622
PKG_LICENSE:=PSF
PKG_LICENSE_FILES:=LICENSE Modules/_ctypes/libffi_msvc/LICENSE Modules/_ctypes/darwin/LICENSE Modules/_ctypes/libffi/LICENSE Modules/_ctypes/libffi_osx/LICENSE Tools/pybench/LICENSE
+# This file provides the necsessary host build variables
+include ./files/python3-host.mk
+
+# For Py3Package
include ./files/python3-package.mk
PKG_INSTALL:=1
@@ -34,7 +38,7 @@ HOST_BUILD_PARALLEL:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/Python-$(PKG_VERSION)
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/Python-$(PKG_VERSION)
-PKG_BUILD_DEPENDS:=libbz2/host expat/host python3/host
+PKG_BUILD_DEPENDS:=python3/host
HOST_BUILD_DEPENDS:=bzip2/host expat/host libffi/host
include $(INCLUDE_DIR)/host-build.mk
@@ -84,8 +88,12 @@ endef
PYTHON3_LIB_FILES_DEL:=
PYTHON3_PACKAGES:=
PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
+PYTHON3_PACKAGES_DEPENDS:=
define Py3BasePackage
PYTHON3_PACKAGES+=$(1)
+ ifeq ($(3),)
+ PYTHON3_PACKAGES_DEPENDS+=$(1)
+ endif
PYTHON3_LIB_FILES_DEL+=$(2)
define Py3Package/$(1)/filespec
$(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
@@ -96,7 +104,7 @@ include ./files/python3-package-*.mk
define Package/python3
$(call Package/python3/Default)
- DEPENDS:=+python3-light $(foreach package,$(filter-out python3-dev python3-lib2to3,$(PYTHON3_PACKAGES)),+$(package))
+ DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES_DEPENDS),+$(package))
endef
define Package/python3/description
@@ -154,6 +162,7 @@ define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON_VERSION)/
$(INSTALL_DATA) \
./files/python3-package.mk \
+ ./files/python3-host.mk \
./files/python3-version.mk \
$(STAGING_DIR)/mk/
$(CP) \
diff --git a/lang/python3/files/python3-host.mk b/lang/python3/files/python3-host.mk
new file mode 100644
index 000000000..278b90d90
--- /dev/null
+++ b/lang/python3/files/python3-host.mk
@@ -0,0 +1,96 @@
+#
+# Copyright (C) 2017 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+ifneq ($(__python3_host_mk_inc),1)
+__python3_host_mk_inc=1
+
+# For PYTHON3_VERSION
+$(call include_mk, python3-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)
+ STAGING_DIR_HOSTPKG := $(STAGING_DIR)/host
+endif
+
+HOST_PYTHON3_DIR:=$(STAGING_DIR_HOSTPKG)
+HOST_PYTHON3_INC_DIR:=$(HOST_PYTHON3_DIR)/include/python$(PYTHON3_VERSION)
+HOST_PYTHON3_LIB_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)
+
+HOST_PYTHON3_PKG_DIR:=$(HOST_PYTHON3_DIR)/lib/python$(PYTHON3_VERSION)/site-packages
+
+HOST_PYTHON3_BIN:=$(HOST_PYTHON3_DIR)/bin/python$(PYTHON3_VERSION)
+
+HOST_PYTHON3PATH:=$(HOST_PYTHON3_LIB_DIR):$(HOST_PYTHON3_PKG_DIR)
+
+define HostPython3
+ if [ "$(strip $(3))" == "HOST" ]; then \
+ export PYTHONPATH="$(HOST_PYTHON3PATH)"; \
+ export PYTHONDONTWRITEBYTECODE=0; \
+ else \
+ export PYTHONPATH="$(PYTHON3PATH)"; \
+ export PYTHONDONTWRITEBYTECODE=1; \
+ export _python_sysroot="$(STAGING_DIR)"; \
+ export _python_prefix="/usr"; \
+ export _python_exec_prefix="/usr"; \
+ fi; \
+ export PYTHONOPTIMIZE=""; \
+ $(1) \
+ $(HOST_PYTHON3_BIN) $(2);
+endef
+
+# $(1) => commands to execute before running pythons script
+# $(2) => python script and its arguments
+# $(3) => additional variables
+define Build/Compile/HostPy3RunHost
+ $(call HostPython3, \
+ $(if $(1),$(1);) \
+ CC="$(HOSTCC)" \
+ CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
+ CXX="$(HOSTCXX)" \
+ LD="$(HOSTCC)" \
+ LDSHARED="$(HOSTCC) -shared" \
+ CFLAGS="$(HOST_CFLAGS)" \
+ CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
+ LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
+ _PYTHON_HOST_PLATFORM=linux2 \
+ $(3) \
+ , \
+ $(2) \
+ , \
+ HOST \
+ )
+endef
+
+
+# $(1) => build subdir
+# $(2) => additional arguments to setup.py
+# $(3) => additional variables
+define Build/Compile/HostPy3Mod
+ $(call Build/Compile/HostPy3RunHost, \
+ cd $(HOST_BUILD_DIR)/$(strip $(1)), \
+ ./setup.py $(2), \
+ $(3))
+endef
+
+define HostPy3/Compile/Default
+ $(call Build/Compile/HostPy3Mod,,\
+ install --root="$(HOST_BUILD_PREFIX)" --prefix="" \
+ --single-version-externally-managed \
+ )
+endef
+
+ifeq ($(BUILD_VARIANT),python3)
+define Host/Compile
+ $(call HostPy3/Compile/Default)
+endef
+
+define Host/Install
+endef
+endif # python3
+
+endif # __python3_host_mk_inc
diff --git a/lang/python3/files/python3-package-dev.mk b/lang/python3/files/python3-package-dev.mk
index 7c2fc0d4b..19d9592d6 100644
--- a/lang/python3/files/python3-package-dev.mk
+++ b/lang/python3/files/python3-package-dev.mk
@@ -8,7 +8,7 @@
define Package/python3-dev
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) development files
- DEPENDS:=+python3
+ DEPENDS:=+python3 +python3-lib2to3
endef
define Py3Package/python3-dev/install
@@ -22,4 +22,6 @@ $(eval $(call Py3BasePackage,python3-dev, \
/usr/lib/python$(PYTHON_VERSION)/config-$(PYTHON_VERSION) \
/usr/include/python$(PYTHON_VERSION) \
/usr/lib/pkgconfig \
+ , \
+ DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))
diff --git a/lang/python3/files/python3-package-lib2to3.mk b/lang/python3/files/python3-package-lib2to3.mk
index 801fd915a..ed712b6fd 100644
--- a/lang/python3/files/python3-package-lib2to3.mk
+++ b/lang/python3/files/python3-package-lib2to3.mk
@@ -13,4 +13,6 @@ endef
$(eval $(call Py3BasePackage,python3-lib2to3, \
/usr/lib/python$(PYTHON3_VERSION)/lib2to3 \
+ , \
+ DO_NOT_ADD_TO_PACKAGE_DEPENDS \
))
diff --git a/lang/python3/files/python3-package.mk b/lang/python3/files/python3-package.mk
index 56dbedc9c..f13e737ae 100644
--- a/lang/python3/files/python3-package.mk
+++ b/lang/python3/files/python3-package.mk
@@ -5,12 +5,6 @@
# See /LICENSE for more information.
#
-# Compatibility fallback for older OpenWrt and LEDE versions
-ifeq ($(STAGING_DIR_HOSTPKG),)
- $(warning STAGING_DIR_HOSTPKG is unset - falling back to $$(STAGING_DIR)/host)
- STAGING_DIR_HOSTPKG := $(STAGING_DIR)/host
-endif
-
$(call include_mk, python3-version.mk)
PYTHON3_DIR:=$(STAGING_DIR)/usr
@@ -22,22 +16,7 @@ PYTHON3_PKG_DIR:=/usr/lib/python$(PYTHON3_VERSION)/site-packages
PYTHON3:=python$(PYTHON3_VERSION)
-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
- ( export PYTHONPATH="$(PYTHON3PATH)"; \
- export PYTHONOPTIMIZE=""; \
- export PYTHONDONTWRITEBYTECODE=1; \
- export _python_sysroot="$(STAGING_DIR)"; \
- export _python_prefix="/usr"; \
- export _python_exec_prefix="/usr"; \
- $(1) \
- $(HOST_PYTHON3_BIN) $(2); \
- )
-endef
# These configure args are needed in detection of path to Python header files
# using autotools.
@@ -62,6 +41,15 @@ define Py3Package
endef
endif
+ ifndef Py3Package/$(1)/install
+ define Py3Package/$(1)/install
+ if [ -d $(PKG_INSTALL_DIR)/usr/bin ]; then \
+ $(INSTALL_DIR) $$(1)/usr/bin \
+ $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $$(1)/usr/bin/
+ fi
+ endef
+ endif
+
$(call shexport,Py3Package/$(1)/filespec)
define Package/$(1)/install
@@ -100,15 +88,17 @@ define Py3Package
endef
endef
-# $(1) => build subdir
-# $(2) => additional arguments to setup.py
+$(call include_mk, python3-host.mk)
+
+# $(1) => commands to execute before running pythons script
+# $(2) => python script and its arguments
# $(3) => additional variables
-define Build/Compile/Py3Mod
- $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
+define Build/Compile/HostPy3RunTarget
$(call HostPython3, \
- cd $(PKG_BUILD_DIR)/$(strip $(1)); \
+ $(if $(1),$(1);) \
CC="$(TARGET_CC)" \
CCSHARED="$(TARGET_CC) $(FPIC)" \
+ CXX="$(TARGET_CXX)" \
LD="$(TARGET_CC)" \
LDSHARED="$(TARGET_CC) -shared" \
CFLAGS="$(TARGET_CFLAGS)" \
@@ -118,8 +108,31 @@ define Build/Compile/Py3Mod
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
$(3) \
, \
- ./setup.py $(2) \
+ $(2) \
)
+endef
+
+# $(1) => build subdir
+# $(2) => additional arguments to setup.py
+# $(3) => additional variables
+define Build/Compile/Py3Mod
+ $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
+ $(call Build/Compile/HostPy3RunTarget, \
+ cd $(PKG_BUILD_DIR)/$(strip $(1)), \
+ ./setup.py $(2), \
+ $(3))
find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" -o -name "*\.exe" | xargs rm -f
endef
+define Py3Build/Compile/Default
+ $(call Build/Compile/Py3Mod,, \
+ install --prefix="/usr" --root="$(PKG_INSTALL_DIR)" \
+ --single-version-externally-managed \
+ )
+endef
+
+ifeq ($(BUILD_VARIANT),python3)
+define Build/Compile
+ $(call Py3Build/Compile/Default)
+endef
+endif # python3