From 1bf7679211425bb0f63f22ce00c700c7d84eb2d4 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 5 Feb 2019 12:04:43 +0200 Subject: python,python3: make deletion tolerant for paths with spaces Piping to xargs does not handle spaces in paths too well, because it splits up the paths. For deleting empty dirs, we also need to do several retries, otherwise `find` will try to go through the directories after they're deleted. Signed-off-by: Alexandru Ardelean --- lang/python/python3/files/python3-package-pip.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lang/python/python3/files/python3-package-pip.mk') diff --git a/lang/python/python3/files/python3-package-pip.mk b/lang/python/python3/files/python3-package-pip.mk index 1aaeaf2ee..8e209e139 100644 --- a/lang/python/python3/files/python3-package-pip.mk +++ b/lang/python/python3/files/python3-package-pip.mk @@ -21,7 +21,10 @@ define Package/python3-pip/install $(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON3_VERSION)/site-packages/pip \ $(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON3_VERSION)/site-packages/pip-$(PYTHON3_PIP_VERSION).dist-info \ $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/ - find $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/ -name __pycache__ | xargs rm -rf + for _ in \$(seq 1 10) ; do \ + find $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages/ -name __pycache__ -exec rm -rf {} \; || continue ; \ + break ; \ + done endef $(eval $(call Py3BasePackage,python3-pip, \ -- cgit From ed862da9367a6f488a9afee78bfc99dbc9b6906a Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Mon, 4 Feb 2019 16:36:25 +0200 Subject: python,python3: move shebang handle in install script This extends the Python[3] shebang fixup to all packages. Only Python scripts in `/usr/bin` will be handled at the moment. Later it may make sense to also cover executables in `/bin`, though typically Python executables shouldn't be placed there. Previously the shebang handling was only done for python[3]-pip & python[3]-setuptools. Signed-off-by: Alexandru Ardelean --- lang/python/python-package-install.sh | 6 ++++++ lang/python/python/files/python-package-pip.mk | 2 -- lang/python/python/files/python-package-setuptools.mk | 2 -- lang/python/python3/files/python3-package-pip.mk | 2 -- lang/python/python3/files/python3-package-setuptools.mk | 2 -- 5 files changed, 6 insertions(+), 8 deletions(-) (limited to 'lang/python/python3/files/python3-package-pip.mk') diff --git a/lang/python/python-package-install.sh b/lang/python/python-package-install.sh index 30373751c..a1b21e49f 100644 --- a/lang/python/python-package-install.sh +++ b/lang/python/python-package-install.sh @@ -65,6 +65,12 @@ process_filespec "$src_dir" "$dst_dir" "$filespec" || { exit 1 } +usr_bin_dir="$dst_dir/usr/bin" + +if [ -d "$usr_bin_dir" ] ; then + sed "1"'!'"b;s,^#"'!'".*python.*,#"'!'"/usr/bin/python${ver}," -i $usr_bin_dir/* +fi + if [ "$mode" == "sources" ] ; then # Copy only python source files find "$dst_dir" -not -type d -not -name "*\.py" -exec rm -f {} \; diff --git a/lang/python/python/files/python-package-pip.mk b/lang/python/python/files/python-package-pip.mk index b08256464..e0c6de978 100644 --- a/lang/python/python/files/python-package-pip.mk +++ b/lang/python/python/files/python-package-pip.mk @@ -14,8 +14,6 @@ endef define PyPackage/python-pip/install $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages - # Adjust shebang to proper python location on target - sed "1s@.*@#\!/usr/bin/python$(PYTHON_VERSION)@" -i $(PKG_BUILD_DIR)/install-pip/bin/* $(CP) $(PKG_BUILD_DIR)/install-pip/bin/* $(1)/usr/bin $(CP) \ $(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON_VERSION)/site-packages/pip \ diff --git a/lang/python/python/files/python-package-setuptools.mk b/lang/python/python/files/python-package-setuptools.mk index 413ec7979..f90b01864 100644 --- a/lang/python/python/files/python-package-setuptools.mk +++ b/lang/python/python/files/python-package-setuptools.mk @@ -14,8 +14,6 @@ endef define PyPackage/python-setuptools/install $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON_VERSION)/site-packages - # Adjust shebang to proper python location on target - sed "1s@.*@#\!/usr/bin/python$(PYTHON_VERSION)@" -i $(PKG_BUILD_DIR)/install-setuptools/bin/* $(CP) $(PKG_BUILD_DIR)/install-setuptools/bin/* $(1)/usr/bin $(CP) \ $(PKG_BUILD_DIR)/install-setuptools/lib/python$(PYTHON_VERSION)/site-packages/pkg_resources \ diff --git a/lang/python/python3/files/python3-package-pip.mk b/lang/python/python3/files/python3-package-pip.mk index 8e209e139..fd1cd59d5 100644 --- a/lang/python/python3/files/python3-package-pip.mk +++ b/lang/python/python3/files/python3-package-pip.mk @@ -14,8 +14,6 @@ endef define Package/python3-pip/install $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages - # Adjust shebang to proper python location on target - sed "1s@.*@#\!/usr/bin/python$(PYTHON3_VERSION)@" -i $(PKG_BUILD_DIR)/install-pip/bin/* $(CP) $(PKG_BUILD_DIR)/install-pip/bin/pip3* $(1)/usr/bin $(CP) \ $(PKG_BUILD_DIR)/install-pip/lib/python$(PYTHON3_VERSION)/site-packages/pip \ diff --git a/lang/python/python3/files/python3-package-setuptools.mk b/lang/python/python3/files/python3-package-setuptools.mk index 472f5a620..5cb5f58de 100644 --- a/lang/python/python3/files/python3-package-setuptools.mk +++ b/lang/python/python3/files/python3-package-setuptools.mk @@ -14,8 +14,6 @@ endef define Py3Package/python3-setuptools/install $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/python$(PYTHON3_VERSION)/site-packages - # Adjust shebang to proper python location on target - sed "1s@.*@#\!/usr/bin/python$(PYTHON3_VERSION)@" -i $(PKG_BUILD_DIR)/install-setuptools/bin/* $(CP) $(PKG_BUILD_DIR)/install-setuptools/bin/easy_install-* $(1)/usr/bin $(LN) easy_install-$(PYTHON3_VERSION) $(1)/usr/bin/easy_install-3 $(CP) \ -- cgit