Skip to content

Commit

Permalink
python: Better host pip options
Browse files Browse the repository at this point in the history
pip by default will read system-wide and per-user configuration
files[1]. Setting PIP_CONFIG_FILE=/dev/null instructs pip to not read
any config files[2].

pip will spawn child processes of itself to do work, but not all options
are passed down to the child processes[3]. Setting global options as
environment variables[4] ensures they are passed down to any child
processes.

[1]: https://pip.pypa.io/en/stable/topics/configuration/#configuration-files
[2]: https://pip.pypa.io/en/stable/topics/configuration/#pip-config-file
[3]: pypa/pip#9081 (comment)
[4]: https://pip.pypa.io/en/stable/topics/configuration/#environment-variables

Signed-off-by: Jeffery To <[email protected]>
  • Loading branch information
jefferyto committed Mar 15, 2023
1 parent 685dca9 commit a72c7db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lang/python/python3-host.mk
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ HOST_PYTHON3_PIP:=$(STAGING_DIR_HOSTPKG)/bin/pip$(PYTHON3_VERSION)

HOST_PYTHON3_PIP_CACHE_DIR:=$(DL_DIR)/pip-cache

HOST_PYTHON3_PIP_VARS:= \
PIP_CACHE_DIR="$(HOST_PYTHON3_PIP_CACHE_DIR)" \
PIP_CONFIG_FILE=/dev/null \
PIP_DISABLE_PIP_VERSION_CHECK=1

define SetupPyShim
if [ -f $(1)/pyproject.toml ] && [ ! -f $(1)/setup.py ] ; then \
$(CP) $(python3_mk_path)setup.py.shim $(1)setup.py ; \
Expand All @@ -104,11 +109,11 @@ endef
define HostPython3/PipInstall
$(call locked, \
$(HOST_PYTHON3_VARS) \
$(HOST_PYTHON3_PIP_VARS) \
$(HOST_PYTHON3_PIP) \
--cache-dir "$(HOST_PYTHON3_PIP_CACHE_DIR)" \
--disable-pip-version-check \
install \
--no-binary :all: \
--progress-bar off \
--require-hashes \
$(1) \
$(if $(CONFIG_PYTHON3_HOST_PIP_CACHE_WORLD_READABLE), \
Expand Down
8 changes: 4 additions & 4 deletions lang/python/python3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,11 @@ endif

ifeq ($(PYTHON3_SETUPTOOLS_BUILD),1)
define Build/Compile/python3-setuptools
$(HOST_PYTHON3_PIP_VARS) \
$(HOST_PYTHON3_PIP) \
--disable-pip-version-check \
--cache-dir "$(DL_DIR)/pip-cache" \
install \
--ignore-installed \
--progress-bar off \
--root=$(PKG_BUILD_DIR)/install-setuptools \
--prefix=/usr \
$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/setuptools-$(PYTHON3_SETUPTOOLS_VERSION)-py3-none-any.whl
Expand All @@ -197,11 +197,11 @@ endif # CONFIG_PACKAGE_python3-setuptools

ifdef CONFIG_PACKAGE_python3-pip
define Build/Compile/python3-pip
$(HOST_PYTHON3_PIP_VARS) \
$(HOST_PYTHON3_PIP) \
--disable-pip-version-check \
--cache-dir "$(DL_DIR)/pip-cache" \
install \
--ignore-installed \
--progress-bar off \
--root=$(PKG_BUILD_DIR)/install-pip \
--prefix=/usr \
$(PKG_BUILD_DIR)/Lib/ensurepip/_bundled/pip-$(PYTHON3_PIP_VERSION)-py3-none-any.whl
Expand Down

0 comments on commit a72c7db

Please sign in to comment.