From da42c60307addba1a4cef609c339891028ca450d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 21 May 2018 10:24:26 -0700 Subject: Makefile: Call contrib/python's clean regardless of HAS_PYTHON3 The only Python dependency in contrib/python's clean is: $(PYTHON) setup.py clean --all and our setup.pys work on both major Python versions: $ make -C contrib/python/podman PYTHON=python2 clean make: Entering directory `/.../libpod/contrib/python/podman' python2 setup.py clean --all /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) running clean 'build/lib' does not exist -- can't clean it 'build/bdist.linux-x86_64' does not exist -- can't clean it 'build/scripts-2.7' does not exist -- can't clean it rm -rf podman.egg-info dist find . -depth -name __pycache__ -exec rm -rf {} \; find . -depth -name \*.pyc -exec rm -f {} \; make: Leaving directory `/.../libpod/contrib/python/podman' $ echo $? 0 $ make -C contrib/python/pypodman PYTHON=python2 clean make: Entering directory `/.../libpod/contrib/python/pypodman' python2 setup.py clean --all /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires' warnings.warn(msg) running clean removing 'build/lib' (and everything under it) removing 'build/bdist.linux-x86_64' (and everything under it) 'build/scripts-2.7' does not exist -- can't clean it removing 'build' rm -rf pypodman.egg-info dist find . -depth -name __pycache__ -exec rm -rf {} \; find . -depth -name \*.pyc -exec rm -f {} \; make: Leaving directory `/.../libpod/contrib/python/pypodman' $ echo $? 0 This rolls back part of 390bd16d (tidy up the copr spec, 2018-05-20, #813). I've also shifted the submake cleans to the end of the main clean recipe. That way, if one of the submake cleans dies (e.g. because the system lacks Python entirely), the temp-file removal will still happen. The way I have it setup now, the podman clean dying will keep any of the pypodman clean from happening. You could probably work around that with something like: $(MAKE) -C contrib/python/podman clean & \ $(MAKE) -C contrib/python/pypodman clean & \ wait but that seems too fancy for such a corner case. Signed-off-by: W. Trevor King --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 0277c19b0..29884d824 100644 --- a/Makefile +++ b/Makefile @@ -138,12 +138,10 @@ clean: libpod/container_easyjson.go \ libpod/pod_easyjson.go \ $(MANPAGES) ||: -ifdef HAS_PYTHON3 - $(MAKE) -C contrib/python/podman clean - $(MAKE) -C contrib/python/pypodman clean -endif find . -name \*~ -delete find . -name \#\* -delete + $(MAKE) -C contrib/python/podman clean + $(MAKE) -C contrib/python/pypodman clean libpodimage: docker build -t ${LIBPOD_IMAGE} . -- cgit v1.2.3-54-g00ecf From af6d86dcdf5fbe3b7e2e673c9ae4ce80fb603a1b Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 21 May 2018 11:17:10 -0700 Subject: Makefile: Drop PYTHON This line landed in 8493dba2 (Initial varlink implementation, 2018-03-26, #627), but this Makefile has never consumed that variable. Signed-off-by: W. Trevor King --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 29884d824..c49233b36 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,6 @@ ifneq (,$(findstring varlink,$(BUILDTAGS))) PODMAN_VARLINK_DEPENDENCIES = cmd/podman/varlink/iopodman.go endif -PYTHON ?= /usr/bin/python3 HAS_PYTHON3 := $(shell command -v python3 2>/dev/null) BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions -- cgit v1.2.3-54-g00ecf From 356765aa959626d0d027484b2797958c24fe3c15 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 21 May 2018 11:23:00 -0700 Subject: contrib/python/*/Makefile: Fallback to unversioned 'python' And pull these from the PATH by default. This way systems like CentOS that don't have a python3 can still execute 'make clean', which doesn't care about the Python major version. The setup.py shebang, mode change, and ./ prefixing helps address cases where PYTHON is empty. This could be the result of improper user configuration: $ make PYTHON='' clean It could also be the state on systems with no Python installed, in which case you'll see: $ make PYTHON='' clean ./setup.py clean --all /usr/bin/env: 'python': No such file or directory make: *** [Makefile:13: clean] Error 127 I've also shifted the Python invocations to the end of the clean recipies so that as much as possible gets cleaned up even on systems without Python installed. Signed-off-by: W. Trevor King --- contrib/python/podman/Makefile | 4 ++-- contrib/python/podman/setup.py | 2 ++ contrib/python/pypodman/Makefile | 4 ++-- contrib/python/pypodman/setup.py | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) mode change 100644 => 100755 contrib/python/podman/setup.py mode change 100644 => 100755 contrib/python/pypodman/setup.py diff --git a/contrib/python/podman/Makefile b/contrib/python/podman/Makefile index e7e365a9c..64239755f 100644 --- a/contrib/python/podman/Makefile +++ b/contrib/python/podman/Makefile @@ -1,4 +1,4 @@ -PYTHON ?= /usr/bin/python3 +PYTHON ?= $(shell command -v python3 2>/dev/null || command -v python) DESTDIR ?= / .PHONY: python-podman @@ -26,7 +26,7 @@ uninstall: .PHONY: clean clean: - $(PYTHON) setup.py clean --all rm -rf podman.egg-info dist find . -depth -name __pycache__ -exec rm -rf {} \; find . -depth -name \*.pyc -exec rm -f {} \; + $(PYTHON) ./setup.py clean --all diff --git a/contrib/python/podman/setup.py b/contrib/python/podman/setup.py old mode 100644 new mode 100755 index 2953ba0dc..9d54bb3ac --- a/contrib/python/podman/setup.py +++ b/contrib/python/podman/setup.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import os from setuptools import find_packages, setup diff --git a/contrib/python/pypodman/Makefile b/contrib/python/pypodman/Makefile index fb25776fa..430231202 100644 --- a/contrib/python/pypodman/Makefile +++ b/contrib/python/pypodman/Makefile @@ -1,4 +1,4 @@ -PYTHON ?= /usr/bin/python3 +PYTHON ?= $(shell command -v python3 2>/dev/null || command -v python) DESTDIR := / .PHONY: python-pypodman @@ -25,7 +25,7 @@ clobber: uninstall clean .PHONY: clean clean: - $(PYTHON) setup.py clean --all rm -rf pypodman.egg-info dist find . -depth -name __pycache__ -exec rm -rf {} \; find . -depth -name \*.pyc -exec rm -f {} \; + $(PYTHON) ./setup.py clean --all diff --git a/contrib/python/pypodman/setup.py b/contrib/python/pypodman/setup.py old mode 100644 new mode 100755 index 0f80d4060..f07e89201 --- a/contrib/python/pypodman/setup.py +++ b/contrib/python/pypodman/setup.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import os from setuptools import find_packages, setup -- cgit v1.2.3-54-g00ecf