{"thread":{"id":"32360","subject":"[PATCH v2 2/2] Makefile: detect when PYTHON_PATH changes","startedAt":"2012-12-16T19:38:49Z","lastAt":"2012-12-16T19:38:49Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"204985","messageId":"20121216193850.23461.10354.chriscool@tuxfamily.org","threadId":"32360","inReplyTo":null,"subject":"[PATCH v2 2/2] Makefile: detect when PYTHON_PATH changes","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2012-12-16T19:38:49Z","receivedAt":"2012-12-16T19:38:49Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"When make is run, the python scripts are created from *.py files that\nare changed to use the python given by PYTHON_PATH. And PYTHON_PATH\nis set by default to /usr/bin/python on Linux.\n\nThis is nice except when you run make another time setting a\ndifferent PYTHON_PATH, because, as the python scripts have already\nbeen created, make finds nothing to do.\n\nThe goal of this patch is to detect when the PYTHON_PATH changes and\nto create the python scripts again when this happens. To do that we\nuse the same trick that is done to track other variables like prefix,\nflags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file\nwith the PYTHON_PATH and check if it changed.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n .gitignore |  1 +\n Makefile   | 16 ++++++++++++++--\n 2 files changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/.gitignore b/.gitignore\nindex 6d69ae1..086c5af 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -2,6 +2,7 @@\n /GIT-CFLAGS\n /GIT-LDFLAGS\n /GIT-PREFIX\n+/GIT-PYTHON-VARS\n /GIT-SCRIPT-DEFINES\n /GIT-USER-AGENT\n /GIT-VERSION-FILE\ndiff --git a/Makefile b/Makefile\nindex 585b2eb..7db8445 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2245,7 +2245,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh\n endif # NO_PERL\n \n ifndef NO_PYTHON\n-$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX\n+$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS\n $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tINSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \\\n@@ -2624,6 +2624,18 @@ ifdef GIT_PERF_MAKE_OPTS\n \t@echo GIT_PERF_MAKE_OPTS=\\''$(subst ','\\'',$(subst ','\\'',$(GIT_PERF_MAKE_OPTS)))'\\' >>$@\n endif\n \n+### Detect Python interpreter path changes\n+ifndef NO_PYTHON\n+TRACK_PYTHON = $(subst ','\\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')\n+\n+GIT-PYTHON-VARS: FORCE\n+\t@VARS='$(TRACK_PYTHON)'; \\\n+\t    if test x\"$$VARS\" != x\"`cat $@ 2>/dev/null`\" ; then \\\n+\t\techo 1>&2 \"    * new Python interpreter location\"; \\\n+\t\techo \"$$VARS\" >$@; \\\n+            fi\n+endif\n+\n test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))\n \n all:: $(TEST_PROGRAMS) $(test_bindir_programs)\n@@ -2899,7 +2911,7 @@ ifndef NO_TCLTK\n \t$(MAKE) -C git-gui clean\n endif\n \t$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS\n-\t$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES\n+\t$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS\n \n .PHONY: all install profile-clean clean strip\n .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell\n-- \n1.8.1.rc1.2.g8740035\n"}]}