Skip to content

Commit 8e56ebb

Browse files
authored
[infra] update poetry if necessary (#1656)
make install should use the correct poetry version Previously, make install just check if `poetry` was installed and might run with an older version. This would lead to a lot of changes in the poetry.lock file and merge conflicts for other PRs
1 parent b066180 commit 8e56ebb

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Makefile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@
1919
help: ## Display this help
2020
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
2121

22-
install-poetry: ## Install poetry if the user has not done that yet.
23-
@if ! command -v poetry &> /dev/null; then \
24-
echo "Poetry could not be found. Installing..."; \
25-
pip install --user poetry==2.0.1; \
26-
else \
27-
echo "Poetry is already installed."; \
28-
fi
22+
POETRY_VERSION = 2.0.1
23+
install-poetry: ## Ensure Poetry is installed and the correct version is being used.
24+
@if ! command -v poetry &> /dev/null; then \
25+
echo "Poetry could not be found. Installing..."; \
26+
pip install --user poetry==$(POETRY_VERSION); \
27+
else \
28+
INSTALLED_VERSION=$$(pip show poetry | grep Version | awk '{print $$2}'); \
29+
if [ "$$INSTALLED_VERSION" != "$(POETRY_VERSION)" ]; then \
30+
echo "Poetry version $$INSTALLED_VERSION does not match required version $(POETRY_VERSION). Updating..."; \
31+
pip install --user --upgrade poetry==$(POETRY_VERSION); \
32+
else \
33+
echo "Poetry version $$INSTALLED_VERSION is already installed."; \
34+
fi \
35+
fi
2936

3037
install-dependencies: ## Install dependencies including dev, docs, and all extras
3138
poetry install --all-extras

0 commit comments

Comments
 (0)