From 50f2bea9cf6f45d7da87ff0d3bfd57a57e471d1a Mon Sep 17 00:00:00 2001
From: Andreas Tolfsen <ato@sny.no>
Date: Wed, 14 Jul 2021 15:05:59 +0200
Subject: [PATCH] build: add shorthands for interacting with the build system

We have a bootstrapping problem on most operating systems because
the Poetry build system is not available as a distribution package.
This is a problem for some users because it hinders developer
productivity and automation.

This introduces a Makefile wrapper that installs Poetry into a venv
(under ./venv/ by default, or configurable with the VENV environment
variable).  Various tasks can be added to this Makefile so one can
easily interact with the build system without first having to
activate the venv.  This is useful for development environments
where you do not have access to an interactive terminal.

It is important to note that the Makefile is not actually a dependent
in the build process.  Using "poetry build", or any compatible
Python build system, should still work.  The Makefile is, then,
merely a set of shorthand helpers to make development somewhat more
enjoyable.

Fixes: GREG-12
---
 Makefile | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 Makefile

diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..b73509f0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,24 @@
+PIP ?= pip -q
+POETRY ?= poetry
+PYTHON ?= python3.9
+VENV ?= venv
+
+pip = python -m $(PIP)
+poetry = python -m $(POETRY)
+venv = . $(VENV)/bin/activate &&
+
+.PHONY: clean
+clean:
+	$(RM) -r $(VENV)
+
+$(VENV): $(VENV)/touchfile
+$(VENV)/touchfile:
+	test -d $(VENV) || $(PYTHON) -m venv $(VENV)
+	$(venv) $(pip) install -U pip
+	$(venv) $(pip) install poetry
+	$(venv) $(poetry) install
+	touch $@
+
+.PHONY: test
+test: $(VENV)
+	$(venv) python manage.py test
-- 
GitLab