diff --git a/package/pkg-python.mk b/package/pkg-python.mk index 59a48e5a87..8b24aeb3b1 100644 --- a/package/pkg-python.mk +++ b/package/pkg-python.mk @@ -92,11 +92,25 @@ HOST_PKG_PYTHON_SETUPTOOLS_INSTALL_OPTS = \ --root=/ \ --single-version-externally-managed +# Make sure python _sysconfigdata*.py files only reference the current +# per-package directory. +# +# Can't use $(foreach d, $(HOST_DIR)/lib/python* $(STAGING_DIR)/usr/lib/python*, ...) +# because those directories may be created in the same recipe this macro will +# be expanded in. +# Additionally, either or both may be missing, which would make find whine and +# fail. +# So we just use HOST_DIR as a starting point, and filter on the two directories +# of interest. ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y) define PKG_PYTHON_FIXUP_SYSCONFIGDATA - find $(HOST_DIR)/lib/python* $(STAGING_DIR)/usr/lib/python* \ - -name "_sysconfigdata*.py" | xargs --no-run-if-empty \ - $(SED) "s:$(PER_PACKAGE_DIR)/[^/]\+/:$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/:g" + $(Q)find $(HOST_DIR) \ + \( -path '$(HOST_DIR)/lib/python*' \ + -o -path '$(STAGING_DIR)/usr/lib/python*' \ + \) \ + -name "_sysconfigdata*.py" -print0 \ + | xargs -0 --no-run-if-empty \ + $(SED) 's:$(PER_PACKAGE_DIR)/[^/]\+/:$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/:g' endef endif