Browse Source

python3: Remove HostPython3 in python3-host.mk

HostPython3 only adds a few environment variables before running host
Python. It has only two users, Build/Compile/HostPy3RunHost and
Build/Compile/HostPy3RunTarget.

HostPython3 also accesses $(PYTHON3PATH), even though python3-host.mk
does not include python3-package.mk, where the variable is defined.

This removes HostPython3 and has its two users run host Python directly.
This also combines the environment variables of HostPython3 and the two
users into HOST_PYTHON3_VARS and PYTHON3_VARS.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lilik-openwrt-22.03
Jeffery To 5 years ago
parent
commit
3642b18441
3 changed files with 39 additions and 52 deletions
  1. +13
    -32
      lang/python/python3-host.mk
  2. +25
    -19
      lang/python/python3-package.mk
  3. +1
    -1
      net/uwsgi/Makefile

+ 13
- 32
lang/python/python3-host.mk View File

@ -22,23 +22,7 @@ HOST_PYTHON3_BIN:=$(HOST_PYTHON3_DIR)/bin/python$(PYTHON3_VERSION)
HOST_PYTHON3PATH:=$(HOST_PYTHON3_LIB_DIR):$(HOST_PYTHON3_PKG_DIR) 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
define host_python3_settings
HOST_PYTHON3_VARS = \
ARCH="$(HOST_ARCH)" \ ARCH="$(HOST_ARCH)" \
CC="$(HOSTCC)" \ CC="$(HOSTCC)" \
CCSHARED="$(HOSTCC) $(HOST_FPIC)" \ CCSHARED="$(HOSTCC) $(HOST_FPIC)" \
@ -48,22 +32,19 @@ define host_python3_settings
CFLAGS="$(HOST_CFLAGS)" \ CFLAGS="$(HOST_CFLAGS)" \
CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \ CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \ LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath=$(STAGING_DIR_HOSTPKG)/lib" \
_PYTHON_HOST_PLATFORM=linux2
endef
_PYTHON_HOST_PLATFORM=linux2 \
PYTHONPATH="$(HOST_PYTHON3PATH)" \
PYTHONDONTWRITEBYTECODE=0 \
PYTHONOPTIMIZE=""
# $(1) => commands to execute before running pythons script
# $(1) => directory of python script
# $(2) => python script and its arguments # $(2) => python script and its arguments
# $(3) => additional variables # $(3) => additional variables
define Build/Compile/HostPy3RunHost define Build/Compile/HostPy3RunHost
$(call HostPython3, \
$(if $(1),$(1);) \
$(call host_python3_settings) \
$(3) \
, \
$(2) \
, \
HOST \
)
cd "$(if $(strip $(1)),$(strip $(1)),.)" && \
$(HOST_PYTHON3_VARS) \
$(3) \
$(HOST_PYTHON3_BIN) $(2)
endef endef
# Note: I shamelessly copied this from Yousong's logic (from python-packages); # Note: I shamelessly copied this from Yousong's logic (from python-packages);
@ -71,7 +52,7 @@ HOST_PYTHON3_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON3_VERSION)
# $(1) => packages to install # $(1) => packages to install
define Build/Compile/HostPy3PipInstall define Build/Compile/HostPy3PipInstall
$(call host_python3_settings) \
$(HOST_PYTHON3_VARS) \
$(HOST_PYTHON3_PIP) \ $(HOST_PYTHON3_PIP) \
--disable-pip-version-check \ --disable-pip-version-check \
--cache-dir "$(DL_DIR)/pip-cache" \ --cache-dir "$(DL_DIR)/pip-cache" \
@ -84,7 +65,7 @@ endef
# $(3) => additional variables # $(3) => additional variables
define Build/Compile/HostPy3Mod define Build/Compile/HostPy3Mod
$(call Build/Compile/HostPy3RunHost, \ $(call Build/Compile/HostPy3RunHost, \
cd $(HOST_BUILD_DIR)/$(strip $(1)), \
./setup.py $(2), \
$(HOST_BUILD_DIR)/$(strip $(1)), \
setup.py $(2), \
$(3)) $(3))
endef endef

+ 25
- 19
lang/python/python3-package.mk View File

@ -96,26 +96,32 @@ define Py3Package
endif # Package/$(1)/install endif # Package/$(1)/install
endef endef
# $(1) => commands to execute before running pythons script
PYTHON3_VARS = \
CC="$(TARGET_CC)" \
CCSHARED="$(TARGET_CC) $(FPIC)" \
CXX="$(TARGET_CXX)" \
LD="$(TARGET_CC)" \
LDSHARED="$(TARGET_CC) -shared" \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
_PYTHON_HOST_PLATFORM=linux2 \
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
PYTHONPATH="$(PYTHON3PATH)" \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONOPTIMIZE="" \
_python_sysroot="$(STAGING_DIR)" \
_python_prefix="/usr" \
_python_exec_prefix="/usr"
# $(1) => directory of python script
# $(2) => python script and its arguments # $(2) => python script and its arguments
# $(3) => additional variables # $(3) => additional variables
define Build/Compile/HostPy3RunTarget define Build/Compile/HostPy3RunTarget
$(call HostPython3, \
$(if $(1),$(1);) \
CC="$(TARGET_CC)" \
CCSHARED="$(TARGET_CC) $(FPIC)" \
CXX="$(TARGET_CXX)" \
LD="$(TARGET_CC)" \
LDSHARED="$(TARGET_CC) -shared" \
CFLAGS="$(TARGET_CFLAGS)" \
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
_PYTHON_HOST_PLATFORM=linux2 \
__PYVENV_LAUNCHER__="/usr/bin/$(PYTHON3)" \
$(3) \
, \
$(2) \
)
cd "$(if $(strip $(1)),$(strip $(1)),.)" && \
$(PYTHON3_VARS) \
$(3) \
$(HOST_PYTHON3_BIN) $(2)
endef endef
# $(1) => build subdir # $(1) => build subdir
@ -124,8 +130,8 @@ endef
define Build/Compile/Py3Mod define Build/Compile/Py3Mod
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR) $(INSTALL_DIR) $(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
$(call Build/Compile/HostPy3RunTarget, \ $(call Build/Compile/HostPy3RunTarget, \
cd $(PKG_BUILD_DIR)/$(strip $(1)), \
./setup.py $(2), \
$(PKG_BUILD_DIR)/$(strip $(1)), \
setup.py $(2), \
$(3)) $(3))
endef endef


+ 1
- 1
net/uwsgi/Makefile View File

@ -109,7 +109,7 @@ define Build/Compile
$(call Build/Compile/Default,plugin.syslog PROFILE=openwrt) $(call Build/Compile/Default,plugin.syslog PROFILE=openwrt)
$(call Build/Compile/Default,plugin.cgi PROFILE=openwrt) $(call Build/Compile/Default,plugin.cgi PROFILE=openwrt)
$(call Build/Compile/HostPy3RunTarget, \ $(call Build/Compile/HostPy3RunTarget, \
cd $(PKG_BUILD_DIR), \
$(PKG_BUILD_DIR), \
uwsgiconfig.py --plugin plugins/python openwrt, \ uwsgiconfig.py --plugin plugins/python openwrt, \
CPP="$(TARGET_CROSS)cpp" \ CPP="$(TARGET_CROSS)cpp" \
LINUX_UNAME_VERSION=$(LINUX_UNAME_VERSION) \ LINUX_UNAME_VERSION=$(LINUX_UNAME_VERSION) \


Loading…
Cancel
Save