-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathnoxfile.py
More file actions
90 lines (69 loc) · 2.43 KB
/
Copy pathnoxfile.py
File metadata and controls
90 lines (69 loc) · 2.43 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
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
90
import subprocess
import sys
from pathlib import Path
import nox
def _pypy311_interpreter() -> str:
"""Resolve PyPy3.11 executable explicitly on Windows.
Work around a nox/Windows issue where unresolved interpreter aliases can
trigger a hanging ``py -`` probe.
"""
if sys.platform == "win32":
try:
result = subprocess.run(
[
"py",
"-V:Astral/PyPy3.11.13",
"-c",
"import sys; print(sys.executable)",
],
check=False,
capture_output=True,
text=True,
timeout=10,
)
if result.returncode == 0 and result.stdout.strip():
return result.stdout.strip()
except (OSError, subprocess.TimeoutExpired):
pass
return "pypy3.11"
def _run_tests(session: nox.Session) -> None:
session.install(".[test]")
session.run(
"pytest",
*session.posargs,
env={"PYTHONPATH": str(Path(__file__).resolve().parent)},
)
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"])
def tests(session):
_run_tests(session)
@nox.session(name="tests-pypy3.11", python=_pypy311_interpreter())
def tests_pypy311(session):
_run_tests(session)
@nox.session
def flake8(session):
session.install("flake8")
session.run("flake8", "pytest_subprocess", "tests", *session.posargs)
@nox.session
def mypy(session):
session.install("mypy")
session.run("mypy", "--version")
session.run("mypy", "pytest_subprocess", "--config-file=setup.cfg")
session.run("mypy", "tests/test_typing.py", "--config-file=setup.cfg")
# Note sphinx-napoleon uses deprecated renames removed in 3.10
@nox.session(python="3.9")
def docs(session):
session.install(".[docs]")
session.run("sphinx-build", "-b", "html", "docs", "docs/_build", "-v", "-W")
@nox.session
def create_dist(session):
session.install("twine", "build")
session.run("python", "-m", "build")
session.run("twine", "check", "dist/*")
@nox.session
def publish(session):
"""Publish to pypi. Run `nox publish -- prod` to publish to the official repo."""
create_dist(session)
twine_command = ["twine", "upload", "dist/*"]
if "prod" not in session.posargs:
twine_command.extend(["--repository-url", "https://test.pypi.org/legacy/"])
session.run(*twine_command)