{"thread":{"id":"32393","subject":"[PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes","startedAt":"2012-12-18T19:00:07Z","lastAt":"2012-12-19T00:14:51Z","messageCount":3,"participants":["Christian Couder","Pete Wyckoff","Junio C Hamano"],"isPatch":true,"patchVersion":5,"patchTotal":3},"messages":[{"id":"205146","messageId":"20121218190009.29910.39426.chriscool@tuxfamily.org","threadId":"32393","inReplyTo":null,"subject":"[PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2012-12-18T19:00:07Z","receivedAt":"2012-12-18T19:00:07Z","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 64a454b..56a4b2b 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"},{"id":"205166","messageId":"20121218234202.GA13151@padd.com","threadId":"32393","inReplyTo":"20121218190009.29910.39426.chriscool@tuxfamily.org","subject":"Re: [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2012-12-18T23:42:02Z","receivedAt":"2012-12-18T23:42:02Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"chriscool@tuxfamily.org wrote on Tue, 18 Dec 2012 20:00 +0100:\n> When make is run, the python scripts are created from *.py files that\n> are changed to use the python given by PYTHON_PATH. And PYTHON_PATH\n> is set by default to /usr/bin/python on Linux.\n> \n> This is nice except when you run make another time setting a\n> different PYTHON_PATH, because, as the python scripts have already\n> been created, make finds nothing to do.\n> \n> The goal of this patch is to detect when the PYTHON_PATH changes and\n> to create the python scripts again when this happens. To do that we\n> use the same trick that is done to track other variables like prefix,\n> flags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file\n> with the PYTHON_PATH and check if it changed.\n> \n> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n\nI played around with this a bit in the context of git-p4; and it\nseems to work fine.\n\nIt's interesting that the code in git_remote_helpers/Makefile\ndoes not work with python3, but that's not a problem to solve\nhere.  If you get interested in looking, that approach to\ninstalling always struck me as a bit odd.  If it is the right\nway, though, maybe we should try to unify the approach to git-p4\nand potential future .py scripts in git.\n\nAcked-by: Pete Wyckoff <pw@padd.com>\n\nThanks for fixing this bug.\n\n\t\t-- Pete\n"},{"id":"205167","messageId":"7v38z2ew3o.fsf@alter.siamese.dyndns.org","threadId":"32393","inReplyTo":"20121218234202.GA13151@padd.com","subject":"Re: [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-12-19T00:14:51Z","receivedAt":"2012-12-19T00:14:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}