Browse Source

python: unify HostPython and HostHostPython functions

That means basically moving the host Python from $(STAGING_DIR_HOST)
to $(STAGING_DIR_HOST)/usr and making the PYTHONPATH var
as an argument.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
lilik-openwrt-22.03
Alexandru Ardelean 9 years ago
parent
commit
c55641331e
3 changed files with 22 additions and 24 deletions
  1. +5
    -5
      lang/python/Makefile
  2. +12
    -7
      lang/python/files/python-host.mk
  3. +5
    -12
      lang/python/files/python-package.mk

+ 5
- 5
lang/python/Makefile View File

@ -140,13 +140,13 @@ define Build/InstallDev
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \ $(PKG_INSTALL_DIR)/usr/include/python$(PYTHON_VERSION) \
$(1)/usr/include/ $(1)/usr/include/
$(CP) \ $(CP) \
$(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION) \
$(STAGING_DIR_HOST)/usr/lib/python$(PYTHON_VERSION) \
$(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \ $(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON_VERSION).so* \
$(1)/usr/lib/ $(1)/usr/lib/
$(CP) \ $(CP) \
$(STAGING_DIR_HOST)/lib/pkgconfig/python.pc \
$(STAGING_DIR_HOST)/lib/pkgconfig/python2.pc \
$(STAGING_DIR_HOST)/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
$(STAGING_DIR_HOST)/usr/lib/pkgconfig/python.pc \
$(STAGING_DIR_HOST)/usr/lib/pkgconfig/python2.pc \
$(STAGING_DIR_HOST)/usr/lib/pkgconfig/python-$(PYTHON_VERSION).pc \
$(1)/usr/lib/pkgconfig $(1)/usr/lib/pkgconfig
$(CP) \ $(CP) \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \ $(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON_VERSION)/config \
@ -219,8 +219,8 @@ HOST_CONFIGURE_ARGS+= \
--without-cxx-main \ --without-cxx-main \
--without-pymalloc \ --without-pymalloc \
--with-threads \ --with-threads \
--prefix=$(STAGING_DIR_HOST)/usr \
--with-system-expat=$(STAGING_DIR_HOST) \ --with-system-expat=$(STAGING_DIR_HOST) \
--prefix=$(STAGING_DIR_HOST) \
--with-ensurepip=upgrade \ --with-ensurepip=upgrade \
CONFIG_SITE= \ CONFIG_SITE= \
CFLAGS="$(HOST_CFLAGS)" CFLAGS="$(HOST_CFLAGS)"


+ 12
- 7
lang/python/files/python-host.mk View File

@ -7,11 +7,14 @@
HOST_PYTHON_INC_DIR:=$(STAGING_DIR_HOST)/include/python$(PYTHON_VERSION) HOST_PYTHON_INC_DIR:=$(STAGING_DIR_HOST)/include/python$(PYTHON_VERSION)
HOST_PYTHON_PKG_DIR:=/lib/python$(PYTHON_VERSION)/site-packages
HOST_PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR_HOST)/$(HOST_PYTHON_PKG_DIR) HOST_PYTHONPATH:=$(HOST_PYTHON_LIB_DIR):$(STAGING_DIR_HOST)/$(HOST_PYTHON_PKG_DIR)
define HostHostPython
( export PYTHONPATH="$(HOST_PYTHONPATH)"; \
define HostPython
ifeq ($(3),)
$(3):=$(PYTHONPATH)
endif
( export PYTHONPATH="$(3)"; \
export PYTHONOPTIMIZE=""; \ export PYTHONOPTIMIZE=""; \
export PYTHONDONTWRITEBYTECODE=1; \ export PYTHONDONTWRITEBYTECODE=1; \
export _python_sysroot="$(STAGING_DIR_HOST)"; \ export _python_sysroot="$(STAGING_DIR_HOST)"; \
@ -25,15 +28,15 @@ endef
# These configure args are needed in detection of path to Python header files # These configure args are needed in detection of path to Python header files
# using autotools. # using autotools.
HOST_CONFIGURE_ARGS += \ HOST_CONFIGURE_ARGS += \
_python_sysroot="$(STAGING_DIR_HOST)" \
_python_prefix="" \
_python_exec_prefix=""
_python_sysroot="$(STAGING_DIR_HOST)/usr" \
_python_prefix="/usr" \
_python_exec_prefix="/usr"
# $(1) => build subdir # $(1) => build subdir
# $(2) => additional arguments to setup.py # $(2) => additional arguments to setup.py
# $(3) => additional variables # $(3) => additional variables
define Build/Compile/HostPyMod define Build/Compile/HostPyMod
$(call HostHostPython, \
$(call HostPython, \
cd $(HOST_BUILD_DIR)/$(strip $(1)); \ cd $(HOST_BUILD_DIR)/$(strip $(1)); \
CC="$(HOSTCC)" \ CC="$(HOSTCC)" \
CCSHARED="$(HOSTCC) $(HOST_FPIC)" \ CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
@ -48,6 +51,8 @@ define Build/Compile/HostPyMod
$(3) \ $(3) \
, \ , \
./setup.py $(2) \ ./setup.py $(2) \
, \
$(HOST_PYTHONPATH) \
) )
endef endef

+ 5
- 12
lang/python/files/python-package.mk View File

@ -17,21 +17,10 @@ PYTHON_PKG_DIR:=/usr/lib/python$(PYTHON_VERSION)/site-packages
PYTHON:=python$(PYTHON_VERSION) PYTHON:=python$(PYTHON_VERSION)
HOST_PYTHON_LIB_DIR:=$(STAGING_DIR_HOST)/lib/python$(PYTHON_VERSION)
HOST_PYTHON_LIB_DIR:=$(STAGING_DIR_HOST)/usr/lib/python$(PYTHON_VERSION)
HOST_PYTHON_BIN:=$(STAGING_DIR_HOST)/bin/python2 HOST_PYTHON_BIN:=$(STAGING_DIR_HOST)/bin/python2
PYTHONPATH:=$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR) PYTHONPATH:=$(PYTHON_LIB_DIR):$(STAGING_DIR)/$(PYTHON_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON_PKG_DIR)
define HostPython
( export PYTHONPATH="$(PYTHONPATH)"; \
export PYTHONOPTIMIZE=""; \
export PYTHONDONTWRITEBYTECODE=1; \
export _python_sysroot="$(STAGING_DIR)"; \
export _python_prefix="/usr"; \
export _python_exec_prefix="/usr"; \
$(1) \
$(HOST_PYTHON_BIN) $(2); \
)
endef
# These configure args are needed in detection of path to Python header files # These configure args are needed in detection of path to Python header files
# using autotools. # using autotools.
@ -94,6 +83,8 @@ define PyPackage
endef endef
endef endef
$(call include_mk, python-host.mk)
# $(1) => build subdir # $(1) => build subdir
# $(2) => additional arguments to setup.py # $(2) => additional arguments to setup.py
# $(3) => additional variables # $(3) => additional variables
@ -114,6 +105,8 @@ define Build/Compile/PyMod
$(3) \ $(3) \
, \ , \
./setup.py $(2) \ ./setup.py $(2) \
, \
$(PYTHONPATH) \
) )
find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f find $(PKG_INSTALL_DIR) -name "*\.pyc" -o -name "*\.pyo" | xargs rm -f
endef endef


Loading…
Cancel
Save