-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnoxfile.py
More file actions
45 lines (36 loc) · 1.34 KB
/
noxfile.py
File metadata and controls
45 lines (36 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import os
from pathlib import Path
import nox
HERE = Path(__file__).resolve(strict=True).parent
PYTHON_VERSION = HERE.joinpath(".python-version").read_text().strip()
nox.options.pythons = [PYTHON_VERSION]
nox.options.sessions = ["run"]
nox.options.reuse_existing_virtualenvs = True
nox.options.error_on_missing_interpreters = True
@nox.session(python=PYTHON_VERSION)
def lint(session: nox.Session) -> None:
"""Run the linter."""
session.install("-U", "pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)
@nox.session(python=PYTHON_VERSION)
def update_requirements(session: nox.Session) -> None:
"""Update requirements.txt."""
session.install("-U", "pip-tools")
env = os.environ.copy()
# CUSTOM_COMPILE_COMMAND is a pip-compile option that tells users how to
# regenerate the constraints files
env["CUSTOM_COMPILE_COMMAND"] = f"nox -s {session.name}"
session.run(
"pip-compile",
"--allow-unsafe",
"--upgrade",
"--generate-hashes",
"requirements.in",
env=env,
)
@nox.session(python=PYTHON_VERSION)
def run(session: nox.Session) -> None:
"""Run pep600_compliance."""
session.install("--upgrade", "pip")
session.install("--require-hashes", "-r", "requirements.txt")
session.run("python", "-m", "pep600_compliance", *session.posargs)