electionguard-api-python icon indicating copy to clipboard operation
electionguard-api-python copied to clipboard

Ideal Version of Enforcing Poetry Version

Open keithrfung opened this issue 5 years ago • 2 comments

This issue is somewhat related to #111 and #112 . The concern is to solve issues with poetry itself, both the DockerFile and MakeFile contain a reference to a specific version of poetry. The ideal version:

Running make environment for the first time would install a specific version of poetry (call it vX.Y) Running make environment on an existing environment would ensure the correct version of poetry is installed The docker container would use the correct poetry version in all cases Our linting or CI could include some verification that the lock file is generated for the correct version of poetry (I haven't looked deeply enough at the lock file to know how hard this would be).

keithrfung avatar Oct 01 '20 18:10 keithrfung

I had an idea how to possibly approach this issue.

POETRY_VERSION = 1.0.10

all: environment lint start

environment:
	@echo 🔧 SETUP
	make install-gmp
	@echo Check if need cleanup
	[ -f ./.env ] && rm -r .env || echo env file not found
	[ -f ./poetry.lock ] && rm -r poetry.lock || echo lock file not found
	touch .env
	@echo Install Poetry Version $(POETRY_VERSION)
	pip install --upgrade --force-reinstall 'poetry==$(POETRY_VERSION)'
	@echo Install Dependencies
	poetry install
	@echo POETRY_VERSION==$(POETRY_VERSION) > .env

Something like this would possibly tackle the first two points of enforcing that the existing environment is always correct regenerating lock files and re-installing dependencies on version change. Also, generate .env with that specific Poetry version defined in the makefile (could be used for other future constants).

This .env file would be used in docker-compose.yml and in dockerfile to pass the correct Poetry version (other constants) when generating containers. This would ensure the third point of containers always having the right Poetry version passed. All that is taken care of when you use "make environment".

And lastly, for the fourth point, this approach regenerates a lock file on every "make environment" call so that way there shouldn't be any version conflicts and incompatible lock files. Let me know if I'm missing something here.

TuTomasz avatar Oct 08 '20 15:10 TuTomasz

@TuTomasz You really hit it out of the park with that answer. I'm sorry I missed it. This seems like right approach.

keithrfung avatar Oct 06 '21 15:10 keithrfung