Skip to content

Commit

Permalink
Add Python existence check to Makefile (streamlit#9930)
Browse files Browse the repository at this point in the history
## Describe your changes

When executing a make command, check if python command is available and, if not, write a warning message in red to the console for better visibility.

## GitHub Issue Link (if applicable)

[Makefile fails when Python is not detected; add missing prompt and
Python version check
streamlit#9914](streamlit#9914)

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.

Co-authored-by: Benjamin Raethlein <[email protected]>
  • Loading branch information
EclidFundgue and raethlein authored Dec 9, 2024
1 parent 7cad288 commit 2124e7f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ CONSTRAINTS_URL ?= https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/${CONS
# Black magic to get module directories
PYTHON_MODULES := $(foreach initpy, $(foreach dir, $(wildcard lib/*), $(wildcard $(dir)/__init__.py)), $(realpath $(dir $(initpy))))

# Check if Python is installed and can be executed, otherwise show an error message in red (but continue)
ifeq ($(PYTHON_VERSION),)
error_message="Error: Python version is not detected. Please ensure Python is installed and accessible in your PATH."
error_message_red_colored=$(shell echo -e "\033[0;31m ${error_message} \033[0m")
$(warning ${error_message_red_colored})
endif

.PHONY: help
help:
@# Magic line used to create self-documenting makefiles.
Expand Down

0 comments on commit 2124e7f

Please sign in to comment.