From 0ebebfc000cec6d2f974f26074bc6ff3c7f304d7 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 14 Oct 2019 11:22:16 +0100 Subject: [PATCH] pysetup.mk: Run commands on multiple `python's, possibly in parallel. Most targets delegated to `setup.py' are now run, in parallel, on multiple Python versions listed in the new Makefile variable `PYTHONS'. The exceptions are `gen' and `dist', which only make sense with a single Python. Targets which can run multiple Python versions now support per-version options for targets: set the variable OPTS-TARGET/PYTHON (e.g., `OPTS-install/python3.5'). --- pysetup.mk | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/pysetup.mk b/pysetup.mk index 09dd7b0..633e96c 100644 --- a/pysetup.mk +++ b/pysetup.mk @@ -5,6 +5,7 @@ default: all PYTHON ?= python +PYTHONS ?= $(PYTHON) prefix ?= /usr/local ###-------------------------------------------------------------------------- @@ -15,18 +16,18 @@ distdir := $(shell $(PYTHON) setup.py -q distdir) ###-------------------------------------------------------------------------- ### Useful targets implemented by the `setup.py' program. -PYTARGETS += gen +SINGLE_PYTARGETS += gen CMD-gen ?= build_gen PYTARGETS += all CMD-all ?= build -all:: gen +$(foreach p,$(PYTHONS),all/$p):: all/%: gen PYTARGETS += clean OPTS-clean ?= --all clean-hook::; rm -f MANIFEST RELEASE -PYTARGETS += dist +SINGLE_PYTARGETS += dist CMD-dist ?= sdist OPTS-dist += --dist-dir . @@ -38,15 +39,25 @@ PYTARGETS += check ###-------------------------------------------------------------------------- ### Interfacing `setup.py' to make. -pysetup = $(PYTHON) setup.py \ +pysetup = $(or $2,$(PYTHON)) setup.py \ $(if $(filter-out undefined,$(origin CMD-$1)),$(CMD-$1),$1) \ - $(OPTS-$1) + $(OPTS-$1) $(OPTS-$1/$(or $2,$(PYTHON))) -$(foreach t, $(PYTARGETS), $t-hook):: %: -$(PYTARGETS):: %: %-hook setup.py +PYTHON_PYTARGETS = $(foreach t, $(PYTARGETS), \ + $(foreach p, $(PYTHONS), \ + $t/$p)) +ALL_PYTARGETS = $(PYTARGETS) +ALL_PYTARGETS += $(SINGLE_PYTARGETS) $(PYTHON_PYTARGETS) + +$(foreach t, $(ALL_PYTARGETS), $t-hook):: %: + +$(SINGLE_PYTARGETS):: %: %-hook setup.py $(call pysetup,$*) +$(PYTARGETS):: %: %-hook $(foreach p, $(PYTHONS), %/$p) +$(PYTHON_PYTARGETS):: %: %-hook setup.py + $(call pysetup,$(patsubst %/,%,$(dir $*)),$(notdir $*)) -.PHONY: $(PYTARGETS) +.PHONY: $(ALL_PYTARGETS) ###-------------------------------------------------------------------------- ### Release builds. -- 2.11.0