-
Notifications
You must be signed in to change notification settings - Fork 8
/
noxfile.py
89 lines (80 loc) · 3.22 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import shutil
import nox
import os
import sys
@nox.session
def example_projects(session: nox.Session):
session.install("-U", "pip", "build", "pytest")
dist_dir = os.getenv('PY_BUILD_CMAKE_WHEEL_DIR')
if dist_dir is None:
session.run("python", "-m", "build", ".")
dist_dir = "dist"
session.env["PIP_FIND_LINKS"] = os.path.abspath(dist_dir)
session.install("py-build-cmake~=0.1.8")
with session.chdir("examples/minimal"):
shutil.rmtree('.py-build-cmake_cache', ignore_errors=True)
session.run("python", "-m", "build", ".")
session.install(".")
session.run("pytest")
with session.chdir("examples/pybind11-project"):
shutil.rmtree('.py-build-cmake_cache', ignore_errors=True)
session.run("python", "-m", "build", ".")
session.install(".")
session.run("pytest")
if sys.version_info >= (3, 8):
with session.chdir("examples/nanobind-project"):
shutil.rmtree('.py-build-cmake_cache', ignore_errors=True)
session.run("python", "-m", "build", ".")
session.install(".")
session.run("pytest")
with session.chdir("examples/minimal-program"):
shutil.rmtree('.py-build-cmake_cache', ignore_errors=True)
session.run("python", "-m", "build", ".")
session.install(".")
session.run("pytest")
@nox.session
def component(session: nox.Session):
session.install("-U", "pip", "build", "pytest")
dist_dir = os.getenv('PY_BUILD_CMAKE_WHEEL_DIR')
if dist_dir is None:
session.run("python", "-m", "build", ".")
dist_dir = "dist"
session.env["PIP_FIND_LINKS"] = os.path.abspath(dist_dir)
session.install("py-build-cmake~=0.1.8")
with session.chdir("examples/minimal-debug-component"):
shutil.rmtree('.py-build-cmake_cache', ignore_errors=True)
session.install(".")
session.install("./debug")
session.run("pytest")
def test_editable(session: nox.Session, mode: str):
tmpdir = os.path.realpath(session.create_tmp())
try:
with session.chdir("examples/pybind11-project"):
shutil.rmtree('.py-build-cmake_cache', ignore_errors=True)
with open(os.path.join(tmpdir, f"{mode}.toml"), "w") as f:
f.write(f"[editable]\nmode = \"{mode}\"")
session.install("-e", ".", "--config-settings=--local=" + f.name)
session.run("pytest")
finally:
shutil.rmtree(tmpdir, ignore_errors=True)
@nox.session
def editable(session: nox.Session):
session.install("-U", "pip", "build", "pytest")
dist_dir = os.getenv('PY_BUILD_CMAKE_WHEEL_DIR')
if dist_dir is None:
session.run("python", "-m", "build", ".")
dist_dir = "dist"
session.env["PIP_FIND_LINKS"] = os.path.abspath(dist_dir)
session.install("py-build-cmake~=0.1.8")
for mode in ("wrapper", "hook", "symlink"):
test_editable(session, mode)
@nox.session
def tests(session: nox.Session):
session.install("-U", "pip", "pytest")
dist_dir = os.getenv('PY_BUILD_CMAKE_WHEEL_DIR')
if dist_dir:
session.env["PIP_FIND_LINKS"] = os.path.abspath(dist_dir)
session.install("py-build-cmake~=0.1.8")
else:
session.install(".")
session.run('pytest')