Skip to content

Commit 1871a92

Browse files
SpotlightKiddpgeorge
authored andcommitted
py/mkenv.mk: Use $(PYTHON) consistently when calling Python tools.
Rationale: * Calling Python build tool scripts from makefiles should be done consistently using `python </path/to/script>`, instead of relying on the correct she-bang line in the script [1] and the executable bit on the script being set. This is more platform-independent. * The name/path of the Python executable should always be used via the makefile variable `PYTHON` set in `py/mkenv.mk`. This way it can be easily overwritten by the user with `make PYTHON=/path/to/my/python`. * The Python executable name should be part of the value of the makefile variable, which stands for the build tool command (e.g. `MAKE_FROZEN` and `MPY_TOOL`), not part of the command line where it is used. If a Python tool is substituted by another (non-python) program, no change to the Makefiles is necessary, except in `py/mkenv.mk`. * This also solves adafruit#3369 and adafruit#1616. [1] There are systems, where even the assumption that `/usr/bin/env` always exists, doesn't hold true, for example on Android (where otherwise the unix port compiles perfectly well).
1 parent 564a95c commit 1871a92

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

py/mkenv.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ CXX += -m32
5858
LD += -m32
5959
endif
6060

61-
MAKE_FROZEN = $(TOP)/tools/make-frozen.py
61+
MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py
6262
MPY_CROSS = $(TOP)/mpy-cross/mpy-cross
63-
MPY_TOOL = $(TOP)/tools/mpy-tool.py
63+
MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py
6464

6565
all:
6666
.PHONY: all

py/mkrules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ $(BUILD)/frozen_mpy/%.mpy: $(FROZEN_MPY_DIR)/%.py $(TOP)/mpy-cross/mpy-cross
119119
# to build frozen_mpy.c from all .mpy files
120120
$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h
121121
@$(ECHO) "Creating $@"
122-
$(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@
122+
$(Q)$(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@
123123
endif
124124

125125
ifneq ($(PROG),)

0 commit comments

Comments
 (0)