* [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes
@ 2012-12-18 19:00 Christian Couder
2012-12-18 23:42 ` Pete Wyckoff
0 siblings, 1 reply; 3+ messages in thread
From: Christian Couder @ 2012-12-18 19:00 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
When make is run, the python scripts are created from *.py files that
are changed to use the python given by PYTHON_PATH. And PYTHON_PATH
is set by default to /usr/bin/python on Linux.
This is nice except when you run make another time setting a
different PYTHON_PATH, because, as the python scripts have already
been created, make finds nothing to do.
The goal of this patch is to detect when the PYTHON_PATH changes and
to create the python scripts again when this happens. To do that we
use the same trick that is done to track other variables like prefix,
flags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file
with the PYTHON_PATH and check if it changed.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
.gitignore | 1 +
Makefile | 16 ++++++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index 64a454b..56a4b2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
/GIT-CFLAGS
/GIT-LDFLAGS
/GIT-PREFIX
+/GIT-PYTHON-VARS
/GIT-SCRIPT-DEFINES
/GIT-USER-AGENT
/GIT-VERSION-FILE
diff --git a/Makefile b/Makefile
index 585b2eb..7db8445 100644
--- a/Makefile
+++ b/Makefile
@@ -2245,7 +2245,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
endif # NO_PERL
ifndef NO_PYTHON
-$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
$(QUIET_GEN)$(RM) $@ $@+ && \
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2624,6 +2624,18 @@ ifdef GIT_PERF_MAKE_OPTS
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_PERF_MAKE_OPTS)))'\' >>$@
endif
+### Detect Python interpreter path changes
+ifndef NO_PYTHON
+TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
+
+GIT-PYTHON-VARS: FORCE
+ @VARS='$(TRACK_PYTHON)'; \
+ if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
+ echo 1>&2 " * new Python interpreter location"; \
+ echo "$$VARS" >$@; \
+ fi
+endif
+
test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2899,7 +2911,7 @@ ifndef NO_TCLTK
$(MAKE) -C git-gui clean
endif
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
- $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
+ $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
.PHONY: all install profile-clean clean strip
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
--
1.8.1.rc1.2.g8740035
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes
2012-12-18 19:00 [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes Christian Couder
@ 2012-12-18 23:42 ` Pete Wyckoff
2012-12-19 0:14 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Pete Wyckoff @ 2012-12-18 23:42 UTC (permalink / raw)
To: Christian Couder; +Cc: Junio C Hamano, git
chriscool@tuxfamily.org wrote on Tue, 18 Dec 2012 20:00 +0100:
> When make is run, the python scripts are created from *.py files that
> are changed to use the python given by PYTHON_PATH. And PYTHON_PATH
> is set by default to /usr/bin/python on Linux.
>
> This is nice except when you run make another time setting a
> different PYTHON_PATH, because, as the python scripts have already
> been created, make finds nothing to do.
>
> The goal of this patch is to detect when the PYTHON_PATH changes and
> to create the python scripts again when this happens. To do that we
> use the same trick that is done to track other variables like prefix,
> flags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file
> with the PYTHON_PATH and check if it changed.
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
I played around with this a bit in the context of git-p4; and it
seems to work fine.
It's interesting that the code in git_remote_helpers/Makefile
does not work with python3, but that's not a problem to solve
here. If you get interested in looking, that approach to
installing always struck me as a bit odd. If it is the right
way, though, maybe we should try to unify the approach to git-p4
and potential future .py scripts in git.
Acked-by: Pete Wyckoff <pw@padd.com>
Thanks for fixing this bug.
-- Pete
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes
2012-12-18 23:42 ` Pete Wyckoff
@ 2012-12-19 0:14 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2012-12-19 0:14 UTC (permalink / raw)
To: Pete Wyckoff; +Cc: Christian Couder, git
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-19 0:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18 19:00 [PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes Christian Couder
2012-12-18 23:42 ` Pete Wyckoff
2012-12-19 0:14 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).