1 # Build and safety-check requirements.txt
3 # skjold needs a personal github access token. This needs no permissions,
4 # it is only required to query the GitHub GraphQL API v4.
5 # See: https://pythonawesome.com/security-audit-python-project-dependencies-against-security-advisory-databases/
6 # We attempt to get it from the environment variable SKJOLD_GITHUB_API_TOKEN
8 # It can also be passed to this Makefile via either:
10 # make GITHUB_TOKEN=... (build-and-)check-requirements
11 # make SKJOLD_GITHUB_API_TOKEN=... (build-and-)check-requirements
14 SKJOLD_GITHUB_API_TOKEN ?
= ${GITHUB_TOKEN}
16 .PHONY
: build-and-check-requirements
17 build-and-check-requirements
: requirements.txt check-requirements
19 # Always rebuild requirements.txt
20 .PHONY
: requirements.txt
21 # requirements.txt is generated from requirements.in
22 # via pip-compile included in the pip-tools package.
23 # See https://modelpredict.com/wht-requirements-txt-is-not-enough
24 requirements.txt
: requirements.in
25 . ..
/.python-sphinx-virtualenv
/bin
/activate \
26 && pip
install pip-tools \
27 && pip-compile requirements.in
29 # Check requirements.txt for security violations via skjold,
30 # configured in pyproject.toml.
31 # See: https://pythonawesome.com/security-audit-python-project-dependencies-against-security-advisory-databases/
32 .PHONY
: check-requirements
34 @if
[ -z
"$${SKJOLD_GITHUB_API_TOKEN}" ] \
36 echo
"WARNING: Neither SKJOLD_GITHUB_API_TOKEN nor GITHUB_TOKEN is set." \
37 ; echo
"Vulnerability check via skjold might fail when using the GitHub GraphQL API." \
39 . ..
/.python-sphinx-virtualenv
/bin
/activate \
40 && pip
install skjold \
42 # NB: For portability, we use '.' (sh etc.) instead of 'source' (bash).
44 # Debug print environment variables
46 @echo
"GITHUB_TOKEN = ${GITHUB_TOKEN}"
47 @echo
"SKJOLD_GITHUB_API_TOKEN = $${SKJOLD_GITHUB_API_TOKEN}"
48 @echo
"Is SKJOLD_GITHUB_API_TOKEN set? $${SKJOLD_GITHUB_API_TOKEN:+yes}"