Skip to content

Commit dc15d0d

Browse files
committed
Install: Add checks to ensure installer dependencies are available (#702)
**Why?** When running the make / install process of ADF, we need to ensure it will not continue if some of the tools are not installed yet. For example, in the past, if you did not install jq, it would still continue with the build process. Resulting in a broken template at deployment time. As reported in #696, the Python version in the environment was set to v3.8, which resulted in a broken installation process too. **What?** * Updated the documentation to indicate that `jq` needs to be available too. * Added checks in the build process to exit and warn the user about missing dependencies. * Updated the version number of the Makefile.
1 parent 6380170 commit dc15d0d

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-4
lines changed

Makefile

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
# Makefile versions
5-
MAKEFILE_VERSION := 2.0
5+
MAKEFILE_VERSION := 2.1
66
UPDATE_VERSION := make/latest
77

8+
# This Makefile requires Python version 3.9 or later
9+
REQUIRED_PYTHON_MAJOR_VERSION := 3
10+
REQUIRED_PYTHON_MINOR_VERSION := 9
11+
PYTHON_EXECUTABLE := "python$(REQUIRED_PYTHON_MAJOR_VERSION)"
12+
813
# Repository versions
914
SRC_VERSION := $(shell git describe --tags --match 'v[0-9]*')
1015
SRC_VERSION_TAG_ONLY := $(shell git describe --tags --abbrev=0 --match 'v[0-9]*')
@@ -50,7 +55,7 @@ all: build
5055

5156
.venv/is_ready:
5257
( \
53-
test -d .venv || python3 -m venv .venv; \
58+
test -d .venv || $(PYTHON_EXECUTABLE) -m venv .venv; \
5459
touch .venv/is_ready; \
5560
)
5661

@@ -175,6 +180,48 @@ docs:
175180
@echo "* $(CLR_BLUE)$(SRC_TAGGED_URL_BASE)/docs/user-guide.md$(CLR_END)"
176181
@echo ""
177182

183+
verify_tooling: .venv
184+
@( \
185+
. .venv/bin/activate; \
186+
$(PYTHON_EXECUTABLE) --version &> /dev/null && \
187+
( \
188+
$(PYTHON_EXECUTABLE) -c "import sys; sys.version_info < ($(REQUIRED_PYTHON_MAJOR_VERSION),$(REQUIRED_PYTHON_MINOR_VERSION)) and sys.exit(1)" || \
189+
( \
190+
$(PYTHON_EXECUTABLE) --version && \
191+
echo '$(CLR_RED)Python version is too old!$(CLR_END)' && \
192+
echo '$(CLR_RED)Python v$(REQUIRED_PYTHON_MAJOR_VERSION).$(REQUIRED_PYTHON_MINOR_VERSION) or later is required.$(CLR_END)' && \
193+
exit 1 \
194+
) \
195+
) || ( \
196+
echo '$(CLR_RED)Python is not installed!$(CLR_END)' && \
197+
exit 1 \
198+
); \
199+
)
200+
@( \
201+
docker --version &> /dev/null || ( \
202+
echo '$(CLR_RED)Docker is not installed!$(CLR_END)' && \
203+
exit 1 \
204+
); \
205+
)
206+
@( \
207+
git --version &> /dev/null || ( \
208+
echo '$(CLR_RED)Git is not installed!$(CLR_END)' && \
209+
exit 1 \
210+
); \
211+
)
212+
@( \
213+
sed --version &> /dev/null || ( \
214+
echo '$(CLR_RED)Sed is not installed!$(CLR_END)' && \
215+
exit 1 \
216+
); \
217+
)
218+
@( \
219+
jq --version &> /dev/null || ( \
220+
echo '$(CLR_RED)Jq is not installed!$(CLR_END)' && \
221+
exit 1 \
222+
); \
223+
)
224+
178225
pre_build: build_deps docker version_number git_ignore
179226

180227
pre_deps_build: deps docker version_number git_ignore
@@ -194,7 +241,7 @@ post_build:
194241
@echo "$(CLR_GREEN)To deploy ADF, please run:$(CLR_END) make deploy"
195242
@echo ""
196243

197-
build: pre_build sam_build post_build
244+
build: verify_tooling pre_build sam_build post_build
198245

199246
deps_build: pre_deps_build sam_build post_build
200247

docs/installation-guide.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ Please note that building on *Windows* is not supported, please use the
7373
This should return 4.3 or later.
7474
- [python 3](https://www.python.org/downloads/)
7575
- To test if it is available, run `python --version`.
76-
This should return 3.11 or later.
76+
This should return 3.9 or later.
77+
- [jq](https://github.com/jqlang/jq)
78+
- To test if it is available, run `jq --version`.
79+
This version should be 1.6 or later.
7780
- [sed](https://www.gnu.org/software/sed/)
7881
- To test if it is available, run `sed --version`.
7982
This should return 4.3 or later.

0 commit comments

Comments
 (0)