-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Demo of no-setup Makefile (standardized virtualenv handling)
This allows a developer to run `make test` or other targets without having to manually set up a virtualenv or install requirements. The virtualenv is set up for them as a hidden subdirectory and requirements are automatically installed as needed. The goal here is larger: The new base.mk would be pulled in via git subtree from some centralized repository. Over time, this standardized base Makefile would grow and the Makefiles in regular repositories would shrink. By centralizing Makefile logic, we would gain the following: - Standardized names for make targets. Currently there is no universal way to install Python dependencies, to run all tests and quality checks, or to build docs. Developers have to learn what is used in each repo. We have standards for some of this, but they're not always followed. By composing Makefiles, we can ensure new repos always follow the standard, even as the standard changes. - Faster onboarding of developers who have not yet set up their own personalized virtualenv toolchains. Experienced Python developers already have these tools set up, but newer developers stumble on virtualenv creation. - A way to update repos to the latest Makefile improvements without having to manually update several hundreds of repos by hand. Automating the update of a git subtree reference still requires making and merging PRs but it does not require manual review of each PR, let alone manual PR creation.
- Loading branch information
Showing
3 changed files
with
73 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
__pycache__ | ||
.pytest_cache | ||
|
||
/.venv-3.8 | ||
|
||
# C extensions | ||
*.so | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Base Makefile components to build on. | ||
# | ||
# Ideally, this would be pulled in from another repo by a `git subtree` | ||
# reference and would include most of the Makefile so that upgrading | ||
# repos to the latest functionality (and keeping them standardized) | ||
# would be fast and simple. | ||
|
||
PYTHON_VER := 3.8 | ||
|
||
# These are required for bootstrapping a virtualenv to the point where | ||
# requirements can be installed. | ||
|
||
VENV := .venv-$(PYTHON_VER) | ||
PIP := $(VENV)/bin/pip | ||
PIP-COMPILE := $(VENV)/bin/pip-compile | ||
PIP-SYNC := $(VENV)/bin/pip-sync | ||
|
||
$(VENV): ## Create the virtualenv, or recreate it if it already exists | ||
python$(PYTHON_VER) -m venv $(VENV) --clear | ||
|
||
$(PIP): $(VENV) | ||
pip install -r requirements/pip.txt | ||
|
||
$(PIP-COMPILE) $(PIP-SYNC): $(VENV) | ||
$(PIP) install -r requirements/pip-tools.txt | ||
|
||
# The rest of the Python tools are listed here, and all are fulfilled | ||
# by the same target. By calling them from their explicit virtualenv | ||
# paths, we ensure that the virtualenv will be used (including by | ||
# other tools they call). | ||
|
||
COVERAGE := $(VENV)/bin/coverage | ||
DIFF-COVER := $(VENV)/bin/diff-cover | ||
PYTEST := $(VENV)/bin/pytest | ||
TOX := $(VENV)/bin/tox | ||
|
||
$(VENV)/bin/%: $(VENV) | ||
make requirements |