[Reproducible-commits] [cdbs] 23/41: Refactor python snippets: Handle runtimes separate from flavors. Introduce new variables cdbs_expand_pythonruntime cdbs_curpythonruntime. Drop unused variable cdbs_curpython. Deprecate variables cdbs_curpythonindepbinary cdbs_curpythonpribinary cdbs_python_binary.

Mattia Rizzolo mattia at debian.org
Tue May 10 14:42:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch reproducible
in repository cdbs.

commit d236abf977bb9cfd2b183e42712a14fa3177f343
Author: Jonas Smedegaard <dr at jones.dk>
Date:   Mon Jan 20 09:43:22 2014 +0100

    Refactor python snippets: Handle runtimes separate from flavors. Introduce new variables cdbs_expand_pythonruntime cdbs_curpythonruntime. Drop unused variable cdbs_curpython. Deprecate variables cdbs_curpythonindepbinary cdbs_curpythonpribinary cdbs_python_binary.
    
    Dropped variable verified against <http://codesearch.debian.net>.
---
 1/class/python-autotools.mk.in |  7 ++--
 1/class/python-distutils.mk.in | 31 ++++++++------
 1/class/python-sugar.mk.in     |  4 +-
 1/class/python-vars.mk.in      | 91 ++++++++++++++++++++++++++++++++----------
 4 files changed, 94 insertions(+), 39 deletions(-)

diff --git a/1/class/python-autotools.mk.in b/1/class/python-autotools.mk.in
index 5c7c758..da78d96 100644
--- a/1/class/python-autotools.mk.in
+++ b/1/class/python-autotools.mk.in
@@ -42,12 +42,11 @@ CDBS_BUILD_DEPENDS_class_python-autotools_python ?= $(cdbs_python_builddeps)
 CDBS_BUILD_DEPENDS += , $(CDBS_BUILD_DEPENDS_class_python-autotools_python)
 
 # (prepend "python" to digit flavors to stay compatible with CDBS << 0.5)
-cdbs_make_curpythonruntime = $(or $(strip \
-	$(_cdbs_$(cdbs_curpython)_altflavor)),$(strip \
-	$(call cdbs_python_binary,$(strip \
+cdbs_make_curpythonruntime = $(strip \
+	$(call cdbs_expand_pythonruntime,$(cdbs_curpkg),$(strip \
 		$(patsubst 2%,python2%,\
 			$(patsubst 3%,python3%,\
-				$(cdbs_make_curflavor)))))))
+				$(cdbs_make_curflavor))))))
 
 DEB_CONFIGURE_SCRIPT_ENV_PYTHON ?= PYTHON="$(cdbs_make_curpythonruntime)"
 cdbs_autotools_configure_env += $(DEB_CONFIGURE_SCRIPT_ENV_PYTHON)
diff --git a/1/class/python-distutils.mk.in b/1/class/python-distutils.mk.in
index e99b5f1..aed8d79 100644
--- a/1/class/python-distutils.mk.in
+++ b/1/class/python-distutils.mk.in
@@ -30,7 +30,7 @@ DEB_PYTHON_SETUP_CMD ?= setup.py
 DEB_PYTHON_BUILD_ARGS ?= --build-base="$(CURDIR)/$(cdbs_curbuilddir)/build"
 DEB_PYTHON_INSTALL_ARGS_ALL ?= --no-compile -O0
 DEB_PYTHON_CLEAN_ARGS ?= -a
-#DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL = /usr/lib/@PYTHONBINARY@/dist-packages/
+#DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL = /usr/lib/@PYTHONFLAVOR@/dist-packages/
 
 _cdbs_deprecated_vars += DEB_PYTHON_SETUP_CMD,0.4.89
 _cdbs_deprecated_DEB_PYTHON_SETUP_CMD_default := $(DEB_PYTHON_SETUP_CMD)
@@ -57,8 +57,12 @@ cdbs_python_build_args = $(call cdbs_expand_curvar,DEB_PYTHON_BUILD_ARGS)
 cdbs_python_install_args = $(call cdbs_expand_curvar,DEB_PYTHON_INSTALL_ARGS)
 cdbs_python_clean_args = $(call cdbs_expand_curvar,DEB_PYTHON_CLEAN_ARGS)
 _cdbs_expand_python_distutils_skeldir = $(strip \
-	$(subst @PYTHONBINARY@,$1,\
-		$(DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL)))
+	$(subst @PYTHONBINARY@,$(strip \
+		$1 \
+		$(call cdbs_warn_deprecated,\
+			@PYTHONBINARY@,0.5, at PYTHONFLAVOR@)),\
+		$(subst @PYTHONFLAVOR@,$1,\
+			$(DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL))))
 
 # prepare sanity checks
 cdbs_python_packages_pre := $(cdbs_python_arch_packages)$(cdbs_python_indep_packages)
@@ -110,7 +114,7 @@ $(patsubst %,build/%,$(cdbs_python_indep_packages) $(cdbs_python_arch_packages))
 
 $(patsubst %,debian/python-module-stampdir/%,$(cdbs_python_indep_packages)) :: debian/python-module-stampdir/%:
 	cd $(cdbs_python_distutils_srcdir) && \
-		$(cdbs_curpythonindepbinary) \
+		$(cdbs_curpythonruntime) \
 			$(cdbs_python_setup_cmd) build \
 			$(cdbs_python_build_args)
 	touch $@
@@ -119,7 +123,7 @@ $(patsubst %,debian/python-module-stampdir/%,$(cdbs_python_arch_packages)) :: de
 	set -e; \
 	cd $(cdbs_python_distutils_srcdir) && \
 		$(foreach flavor,$(cdbs_curpythonflavors),\
-			$(call cdbs_python_binary,$(flavor)) \
+			$(call cdbs_expand_pythonruntime,$(cdbs_curpkg),$(flavor)) \
 				$(cdbs_python_setup_cmd) build \
 				$(cdbs_python_build_args); )
 	touch $@
@@ -128,19 +132,19 @@ $(patsubst %,debian/python-module-stampdir/%,$(cdbs_python_arch_packages)) :: de
 # install stage
 $(patsubst %,install/%,$(cdbs_python_indep_packages)) :: install/%:
 	cd $(cdbs_python_distutils_srcdir) && \
-		$(cdbs_curpythonindepbinary) \
+		$(cdbs_curpythonruntime) \
 			$(cdbs_python_setup_cmd) install \
 			--root="$(cdbs_python_destdir)" \
 			--install-layout=deb \
 			$(if $(DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL),\
-				--install-lib=$(call _cdbs_expand_python_distutils_skeldir,$(cdbs_curpythonpribinary))) \
+				--install-lib=$(call _cdbs_expand_python_distutils_skeldir,$(cdbs_curpythonflavor))) \
 			$(cdbs_python_install_args)
 
 $(patsubst %,install/%,$(cdbs_python_arch_packages)) :: install/%:
 	set -e; \
 	cd $(cdbs_python_distutils_srcdir) && \
 		$(foreach flavor,$(cdbs_curpythonflavors),\
-			$(call cdbs_python_binary,$(flavor)) \
+			$(call cdbs_expand_pythonruntime,$(cdbs_curpkg),$(flavor)) \
 				$(cdbs_python_setup_cmd) install \
 				--root="$(cdbs_python_destdir)" \
 				--install-layout=deb \
@@ -154,14 +158,14 @@ clean:: $(patsubst %,python-module-clean/%,$(cdbs_python_indep_packages) $(cdbs_
 
 $(patsubst %,python-module-clean/%,$(cdbs_python_indep_packages)) :: python-module-clean/%:
 	-cd $(cdbs_python_distutils_srcdir) && \
-		$(cdbs_curpythonindepbinary) \
+		$(cdbs_curpythonruntime) \
 			$(cdbs_python_setup_cmd) clean \
 			$(cdbs_python_clean_args)
 
 $(patsubst %,python-module-clean/%,$(cdbs_python_arch_packages)) :: python-module-clean/%:
 	-cd $(cdbs_python_distutils_srcdir) && \
 		$(foreach flavor,$(cdbs_curpythonflavors),\
-			$(call cdbs_python_binary,$(flavor)) \
+			$(call cdbs_expand_pythonruntime,$(cdbs_curpkg),$(flavor)) \
 				$(cdbs_python_setup_cmd) clean \
 				$(cdbs_python_clean_args); )
 
@@ -184,8 +188,9 @@ clean::
 # deprecated variables
 cdbs_expand_python_distutils_installdir = $(strip $(call cdbs_warn_deprecated,\
 	cdbs_expand_python_distutils_installdir,0.5)\
-	$(subst @PYTHONBINARY@,$1,$(or $(strip \
-		$(DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL)),$(strip \
-		/usr/lib/@PYTHONBINARY@/dist-packages/))))
+	$(subst @PYTHONBINARY@,$1,$(strip \
+		$(subst @PYTHONFLAVOR@,$1,$(or $(strip \
+			$(DEB_PYTHON_DISTUTILS_INSTALLDIR_SKEL)),$(strip \
+			/usr/lib/@PYTHONFLAVOR@/dist-packages/))))))
 
 endif
diff --git a/1/class/python-sugar.mk.in b/1/class/python-sugar.mk.in
index c62b823..8873e4f 100644
--- a/1/class/python-sugar.mk.in
+++ b/1/class/python-sugar.mk.in
@@ -101,7 +101,7 @@ $(patsubst %,build/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: build/%:
 			> $(cdbs_cursrcdir)/MANIFEST
 	set -e; \
 	$(foreach flavor,$(cdbs_curpythonflavors),\
-		$(call cdbs_python_binary,$(flavor)) \
+		$(call cdbs_expand_pythonruntime,$(cdbs_curpkg),$(flavor)) \
 			$(cdbs_cursrcdir)/setup.py build; )
 	[ ! -e $(cdbs_cursrcdir)/MANIFEST.upstream ] \
 		|| IFS="`printf '\n'`" find "$(cdbs_cursrcdir)/locale" \
@@ -117,7 +117,7 @@ $(patsubst %,install/%,$(DEB_PYTHON_SUGAR_PACKAGES)) :: install/%:
 	set -e; \
 	$(foreach flavor,$(cdbs_curpythonflavors),\
 		LANG=C XDG_DATA_HOME="$(DEB_DESTDIR)/usr/share" \
-			$(call cdbs_python_binary,$(flavor)) \
+			$(call cdbs_expand_pythonruntime,$(cdbs_curpkg),$(flavor)) \
 			$(cdbs_cursrcdir)/setup.py install \
 			--prefix="$(DEB_DESTDIR)/usr"; )
 
diff --git a/1/class/python-vars.mk.in b/1/class/python-vars.mk.in
index b8cc665..bd128b1 100644
--- a/1/class/python-vars.mk.in
+++ b/1/class/python-vars.mk.in
@@ -69,6 +69,11 @@ _cdbs_expand_python3_allflavors = $(shell py3versions -r)
 _cdbs_expand_python2_defaultflavor = $(shell pyversions -d)
 _cdbs_expand_python3_defaultflavor = $(shell py3versions -d)
 
+# runtimes
+# runtime to use for default flavor (if different from implementation name)
+# (see bug#377964)
+_cdbs_python2_defaultruntime = python
+
 # binary packages in use
 cdbs_python_potential_packages = $(strip \
 	$(filter-out %-doc %-dev %-common,$(DEB_PACKAGES)))
@@ -120,12 +125,18 @@ _cdbs_python_singlesystem = $(strip \
 	or suppress the binary packages to operate on using either \
 	DEB_PYTHON3_PACKAGES or another DEB_*_PACKAGES variable)))
 
-# all/default flavors to use
-# variables _cdbs_$p_allflavors _cdbs_$p_defaultflavor
+# implementation to use with legacy system
+#  * resolve system to validate, then just use only valid implementation
+_cdbs_python_legacy = $(strip \
+	$(if $(filter $(_CDBS_PYTHONSYSTEMS_legacy),$(cdbs_python_systems)), \
+		python2))
+
+# all/default flavors and default runtimes to use
+# variables _cdbs_$p_allflavors _cdbs_$p_defaultflavor _cdbs_$p_defaultruntime
 #  1. resolved from _cdbs_expand_$p_*
 #  2. name of python implementation
 $(foreach p,$(_CDBS_PYTHONS),$(if $(cdbs_$p_packages),\
-	$(foreach v,allflavors defaultflavor,\
+	$(foreach v,allflavors defaultflavor defaultruntime,\
 		$(eval _cdbs_$p_$v := $(or $(call _cdbs_expand_$p_$v),$p)))))
 
 # flavors to use
@@ -151,29 +162,58 @@ cdbs_python_flavors = $(strip \
 	$(foreach p,$(_CDBS_PYTHONS),\
 		$(_cdbs_$p_flavors)))
 
+# resolve from binary package
+_cdbs_expand_python = $(or $(strip \
+	$(_cdbs_python_legacy)),$(strip \
+	$(if $(cdbs_python_single_system),\
+		$(if $(filter $1,$(cdbs_$(cdbs_python_singlesystem)_packages)),\
+			$(cdbs_python_singlesystem)))),$(strip \
+	$(foreach p,$(_CDBS_PYTHONS),\
+		$(if $(filter $1,$(cdbs_$p_packages)),\
+			$p))),\
+	$(error no python implementation resolved from binary package "$1"))
+_cdbs_expand_pythonflavors = $(or $(strip \
+	$(cdbs_$(call _cdbs_expand_python,$1)_flavors),\
+	$(error no python flavors resolved from binary package "$1")))
+
 # runtime to use
 # resolve from binary package and optional flavor
-cdbs_python_binary = $(strip \
-	$(if $(call cdbs_streq,$(cdbs_$(cdbs_curpython)_defaultflavor),$1),\
-		$(cdbs_curpython),\
-		$1))
+# (flavor needed only for arch-dep packages)
+#  1. arch-indep w/ default flavor unsupported: name of first supported flavor
+#  2. default flavor or arch-indep: _cdbs_$python_defaultruntime
+#  3. name of flavor
+cdbs_expand_pythonruntime = $(or $(strip \
+	$(foreach p,$(call _cdbs_expand_python,$1),$(or $(strip \
+		$(_cdbs_$p_altflavor)),$(strip \
+		$(if $(filter $1,$(cdbs_python_indep_packages)),\
+			$(_cdbs_$p_defaultruntime))),$(strip \
+		$(if $2,$(or $(strip \
+			$(if $(filter $2,$(_cdbs_$p_defaultflavor)),\
+				$(_cdbs_$p_defaultruntime))),$(strip \
+			$2)))),$(strip \
+		$(if word 2,$(_cdbs_$p_allflavors),\
+			$(error no python runtime resolved from binary \
+				package "$1": Too many flavors),\
+			$(or $(strip \
+				$(if $(filter $f,$(_cdbs_$p_defaultflavor)),\
+					$(_cdbs_$p_defaultruntime))),$(strip \
+				$f))))))),\
+	$(error no python runtime resolved from binary package "$1" \
+		$(if $2,and flavor "$2")))
+
+_cdbs_expand_pythonflavor2python = $(or $(strip \
+	$(_cdbs_python_legacy)),$(strip \
+	$(foreach p,$(_CDBS_PYTHONS),\
+		$(if $(filter $1,$(cdbs_$p_flavors)),$p))),\
+	$(error no python implementation resolved from flavor "$1"))
 
 # resolve (implicitly) from binary package
 cdbs_curpythonsystems = $(strip $(foreach s,$(cdbs_python_systems),\
 	$(foreach p,$(or $(_cdbs_pythonsystempythons_$s),$s),\
 		$(if $(filter $(cdbs_curpkg),$(_cdbs_$p_packages)),\
 			$s))))
-cdbs_curpython = $(strip \
-	$(if $(cdbs_python_single_system),\
-		$(_cdbs_python_singlesystem),\
-		$(foreach p,$(_CDBS_PYTHONS),\
-			$(if $(filter $(cdbs_curpkg),$(_cdbs_$p_packages)),\
-				$p))))
-cdbs_curpythonindepbinary = $(or $(strip \
-	$(_cdbs_$(cdbs_curpython)_altflavor)),$(strip \
-	$(cdbs_curpython)))
-cdbs_curpythonpribinary = $(cdbs_$(cdbs_curpython)_mainflavor)
-cdbs_curpythonflavors = $(_cdbs_$(cdbs_curpython)_flavors)
+cdbs_curpythonruntime = $(call cdbs_expand_pythonruntime,$(cdbs_curpkg))
+cdbs_curpythonflavors = $(call _cdbs_expand_pythonflavors,$(cdbs_curpkg))
 
 # package relations
 # Python-related dependencies according to Python policy, appendix A
@@ -223,8 +263,8 @@ cdbs_python_selected_pyversions = $(strip $(call cdbs_warn_deprecated,\
 			cat debian/pyversions; \
 		fi)))
 cdbs_curpythonstem = $(strip $(call cdbs_warn_deprecated,\
-	cdbs_curpythonstem,0.5,cdbs_curpython)\
-	$(filter 3,$(cdbs_curpython:python%=%)))
+	cdbs_curpythonstem,0.5)\
+	$(if $(filter python3,$(call _cdbs_expand_python,$(cdbs_curpkg))),3))
 cdbs_python_current_binary = $(strip $(call cdbs_warn_deprecated,\
 	cdbs_python_current_binary,0.5)\
 	$(_cdbs_python2_defaultflavor))
@@ -246,5 +286,16 @@ cdbs_python3_supported_versions = $(strip $(call cdbs_warn_deprecated,\
 cdbs_python_build_versions = $(strip $(call cdbs_warn_deprecated,\
 	cdbs_python_build_versions,0.5,cdbs_python_flavors)\
 	$(_cdbs_python2_flavors))
+cdbs_curpythonindepbinary = $(strip $(call cdbs_warn_deprecated,\
+	cdbs_curpythonindepbinary,0.5,cdbs_curpythonruntime)\
+	$(cdbs_curpythonruntime))
+cdbs_curpythonpribinary = $(strip $(call cdbs_warn_deprecated,\
+	cdbs_curpythonpribinary,0.5,cdbs_curpythonruntime)\
+	$(cdbs_curpythonruntime))
+cdbs_python_binary = $(strip $(call cdbs_warn_deprecated,\
+	cdbs_python_binary,0.5,cdbs_curpythonruntime or cdbs_expand_pythonruntime)\
+	$(call cdbs_expand_pythonruntime,\
+		$(call _cdbs_expand_pythonflavor2python,$1),\
+		$1))
 
 endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/cdbs.git



More information about the Reproducible-commits mailing list