README (2550B)
1 This is set of make rules to ease maintenance of python projects. 2 3 It allows you to define multiple virtualenvs, each built from set of 4 requirements.in files, which you can then depend on from your own rules so you 5 always work with up-to-date version of the environment. 6 7 It automatically determines python version, ABI, and platform tags 8 (as per pep-0427) and maintains pinned versions of requirement files for each. 9 Subsequently it uses those pinned requirement files to fetch or build wheels for 10 all dependencies and then updates each virtualenv from those. 11 12 This should maximize the chances of being able to reproduce specific 13 configuration later and minimize needless dependency rebuilds or fetches. 14 15 It's expected to live in "gmake_python_helpers" subdirectory besides your main makefile. 16 Add it as git submodule as follows: 17 18 git submodule add https://ccx.te2000.cz/git/gmake_python_helpers ./gmake_python_helpers 19 20 You will also likely want to add following patterns to your .gitignore: 21 22 virtualenvs 23 wheels 24 python_vars_*.mk 25 venv-* 26 27 -------------------------- 28 Example makefile contents: 29 -------------------------- 30 31 default: py-requirements venv-dev test 32 33 # for use with git submodules, automatically checks out this repo 34 gmake_python_helpers/pip-tools.mk gmake_python_helpers/pycodestyle.mk: 35 git submodule update --init gmake_python_helpers 36 37 # define which python interpreter to use, defaults to "python3" 38 # PYTHON_EXE:=python3.11 39 40 include gmake_python_helpers/pip-tools.mk 41 42 # -- pip-compile / requirements specification 43 44 # create "release" environment from "release-requirements.in" file 45 $(eval $(call PIP_COMPILE_RULE,release,release-requirements.in)) 46 47 # create "dev" environment from both "release-requirements.in" and "dev-requirements.in" files 48 $(eval $(call PIP_COMPILE_RULE,dev,release-requirements.in dev-requirements.in)) 49 50 # -- formatting & linting 51 52 # all python files to be formatted and checked 53 PY_SRC:=$(wildcard *.py) $(wildcard my_module/*.py) 54 55 # use `make pycodestyle` to reformat and lint python source code 56 # see pycodestyle.mk for details 57 include gmake_python_helpers/pycodestyle.mk 58 59 # -- test runner example 60 61 PYTEST_ARGS?=-vsx --strict-config --ff 62 test: $(venv_dev)/.done 63 '$(venv_dev)/bin/pytest' $(PYTEST_ARGS) 64 65 # -- application run example 66 67 run: $(venv_release)/.done 68 '$(venv_release)/bin/python' -m my_module.run 69 70 # -- sphinx-doc example 71 72 doc/make.%: $(venv_dev)/.done 73 $(MAKE) -C doc '$*' SPHINXBUILD=../$(venv_dev)/bin/sphinx-build 74 75 doc: doc/make.html doc/make.man 76 77 .PHONY: default doc doc/make.html doc/make.man