Skip to content

Commit 022250a

Browse files
chriscoolgitster
authored andcommitted
Makefile: detect when PYTHON_PATH changes
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. However, next time make is run with a different value in PYTHON_PATH, we failed to regenerate these scripts. Signed-off-by: Christian Couder <[email protected]> Acked-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f6f3921 commit 022250a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/GIT-LDFLAGS
44
/GIT-GUI-VARS
55
/GIT-PREFIX
6+
/GIT-PYTHON-VARS
67
/GIT-SCRIPT-DEFINES
78
/GIT-USER-AGENT
89
/GIT-VERSION-FILE

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
22452245
endif # NO_PERL
22462246

22472247
ifndef NO_PYTHON
2248-
$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
2248+
$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
22492249
$(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
22502250
$(QUIET_GEN)$(RM) $@ $@+ && \
22512251
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2636,6 +2636,18 @@ GIT-GUI-VARS: FORCE
26362636
fi
26372637
endif
26382638

2639+
### Detect Python interpreter path changes
2640+
ifndef NO_PYTHON
2641+
TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
2642+
2643+
GIT-PYTHON-VARS: FORCE
2644+
@VARS='$(TRACK_PYTHON)'; \
2645+
if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
2646+
echo 1>&2 " * new Python interpreter location"; \
2647+
echo "$$VARS" >$@; \
2648+
fi
2649+
endif
2650+
26392651
test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
26402652

26412653
all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2911,7 +2923,7 @@ ifndef NO_TCLTK
29112923
$(MAKE) -C git-gui clean
29122924
endif
29132925
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2914-
$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
2926+
$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
29152927

29162928
.PHONY: all install profile-clean clean strip
29172929
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell

0 commit comments

Comments
 (0)