-
Notifications
You must be signed in to change notification settings - Fork 5
/
noxfile.py
60 lines (47 loc) · 1.36 KB
/
noxfile.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os
from pathlib import Path
import nox
# Default sessions to run if no session handles are passed
nox.options.sessions = ["lock"]
DIR = Path(__file__).parent.resolve()
@nox.session(reuse_venv=True)
def lock(session: nox.Session) -> None:
"""
Build a lock file with pip-tools
Examples:
$ nox --session lock
"""
session.install("--upgrade", "pip", "setuptools", "wheel")
session.install("--upgrade", "pip-tools")
out = session.run(
"cat",
f"{DIR / 'binder' / 'requirements.txt'}",
f"{DIR / 'book' / 'requirements.txt'}",
external=True,
silent=True,
)
intermediate_requirements = DIR / "requirements.txt"
with open(f"{intermediate_requirements}", "w", encoding="utf8") as out_file:
out_file.write(out.strip() + "\n")
session.run(
"pip-compile",
"--resolver=backtracking",
"--generate-hashes",
"--output-file",
"book/requirements.lock",
intermediate_requirements.name,
)
if intermediate_requirements.exists():
intermediate_requirements.unlink()
@nox.session(venv_backend="none")
def docker(session: nox.Session) -> None:
"""
Build a lock file with pip-tools using Docker
Examples:
$ nox --session docker
"""
session.run(
"bash",
"lock.sh",
external=True,
)