Specify the version of Poetry itself in a version-controlled project? #10251
-
Hello. I'm fairly new to using Poetry and I was using it to manage dependencies and their versions for a Python software project that is version-controlled with Git/GitHub. However, the most recent major version of Poetry introduced a breaking change in the To avoid this problem (and similar problems that might arise in the future), I wanted to know if there is a way to specify the version of Poetry to be used in my project repository by the GitHub workflow that installs Poetry. I know that the version of Python can be specified in a variety of ways (such as a I understand that I can just hard-code the Poetry installation command on the GitHub workflow to install an older version of Poetry with pipx/pip, but I was wondering if there is a better way of storing this information. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I suggest using a POETRY_VERSION := 2.1.1 # Your poetry version
.PHONY: install
install:
pip install poetry==$(POETRY_VERSION)
.PHONY: check
check:
@which poetry > /dev/null 2>&1 && poetry --version | grep $(POETRY_VERSION) || echo "Poetry not installed or wrong version"
.PHONY: help
help:
@echo "Makefile commands:"
@echo " make install - Install Poetry version $(POETRY_VERSION)"
@echo " make check - Check if Poetry is installed and matches $(POETRY_VERSION)" |
Beta Was this translation helpful? Give feedback.
I see the problem, but you can't pin Poetry's version within Poetry itself. A more Pythonic approach would be to use a straightforward
requirements-poetry.txt
file to pin Poetry's version.Also, take a look at tools like
tox
orinvoke
, they might be helpful.