Skip to content

Commit e4ed4f2

Browse files
committed
1 parent 4dc0d39 commit e4ed4f2

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*.svg
66
*.swp
77
.DS_Store
8+
.venv-pre-commit
89
_*
910
build
1011
dist

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This software was developed at the National Institute of Standards
2+
# and Technology by employees of the Federal Government in the course
3+
# of their official duties. Pursuant to title 17 Section 105 of the
4+
# United States Code this software is not subject to copyright
5+
# protection and is in the public domain. NIST assumes no
6+
# responsibility whatsoever for its use by other parties, and makes
7+
# no guarantees, expressed or implied, about its quality,
8+
# reliability, or any other characteristic.
9+
#
10+
# We would appreciate acknowledgement if the software is used.
11+
12+
repos:
13+
- repo: https://github.com/psf/black
14+
rev: 22.3.0
15+
hooks:
16+
- id: black

Makefile

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ SHELL := /bin/bash
1616
PYTHON3 ?= python3
1717

1818
all: \
19-
.git_submodule_init.done.log
19+
.git_submodule_init.done.log \
20+
.venv-pre-commit/var/.pre-commit-built.log
2021
$(MAKE) \
2122
PYTHON3=$(PYTHON3) \
2223
--directory tests
@@ -37,8 +38,32 @@ all: \
3738
.git_submodule_init.done.log
3839
touch $@
3940

41+
# This virtual environment is meant to be built once and then persist, even through 'make clean'.
42+
# If a recipe is written to remove this flag file, it should first run `pre-commit uninstall`.
43+
.venv-pre-commit/var/.pre-commit-built.log:
44+
rm -rf .venv-pre-commit
45+
test -r .pre-commit-config.yaml \
46+
|| (echo "ERROR:Makefile:pre-commit is expected to install for this repository, but .pre-commit-config.yaml does not expect to exist." >&2 ; exit 1)
47+
$(PYTHON3) -m venv \
48+
.venv-pre-commit
49+
source .venv-pre-commit/bin/activate \
50+
&& pip install \
51+
--upgrade \
52+
pip \
53+
setuptools \
54+
wheel
55+
source .venv-pre-commit/bin/activate \
56+
&& pip install \
57+
pre-commit
58+
source .venv-pre-commit/bin/activate \
59+
&& pre-commit install
60+
mkdir -p \
61+
.venv-pre-commit/var
62+
touch $@
63+
4064
check: \
41-
.git_submodule_init.done.log
65+
.git_submodule_init.done.log \
66+
.venv-pre-commit/var/.pre-commit-built.log
4267
$(MAKE) \
4368
PYTHON3=$(PYTHON3) \
4469
--directory tests \

0 commit comments

Comments
 (0)