|
| 1 | +# noxfile.py |
| 2 | +import nox |
| 3 | +import sys |
| 4 | +import os |
| 5 | + |
| 6 | +ARTIFACTS = ( |
| 7 | + "*.egg-info", |
| 8 | + ".hypothesis", |
| 9 | + "build", |
| 10 | + "dist", |
| 11 | + "src/*.so", |
| 12 | +) |
| 13 | + |
| 14 | +# Optional: set defaults so `nox` with no args runs tests. |
| 15 | +# Comment this out if you don't want defaults. |
| 16 | +nox.options.sessions = ["test"] |
| 17 | + |
| 18 | +@nox.session(python=False) # run in the current environment |
| 19 | +def clean(session): |
| 20 | + """Clean build artifacts and uninstall arraykit.""" |
| 21 | + session.run( |
| 22 | + sys.executable, "-m", "pip", |
| 23 | + "--disable-pip-version-check", "uninstall", "--yes", "arraykit", |
| 24 | + external=True |
| 25 | + ) |
| 26 | + for artifact in sorted(ARTIFACTS): |
| 27 | + session.run("rm", "-rf", artifact, external=True) |
| 28 | + |
| 29 | +@nox.session(python=False) |
| 30 | +def build(session): |
| 31 | + """Build/install locally without build isolation (keeps verbose for warnings).""" |
| 32 | + session.run( |
| 33 | + sys.executable, "-m", "pip", |
| 34 | + "--disable-pip-version-check", "-v", |
| 35 | + "install", "--no-build-isolation", ".", |
| 36 | + external=True |
| 37 | + ) |
| 38 | + |
| 39 | +@nox.session(python=False) |
| 40 | +def test(session): |
| 41 | + """Run pytest with native traceback.""" |
| 42 | + session.run( |
| 43 | + "pytest", "-s", "--disable-pytest-warnings", "--tb=native", |
| 44 | + external=True |
| 45 | + ) |
| 46 | + |
| 47 | +@nox.session(python=False) |
| 48 | +def performance(session): |
| 49 | + """Run performance benches. Pass names via env: NAMES='foo,bar' nox -s performance""" |
| 50 | + names = os.environ.get("NAMES", "") |
| 51 | + args = [sys.executable, "-m", "performance"] |
| 52 | + if names: |
| 53 | + args.extend(["--names", names]) |
| 54 | + session.run(*args, external=True) |
| 55 | + |
| 56 | +@nox.session(python=False) |
| 57 | +def lint(session): |
| 58 | + """Run pylint static analysis.""" |
| 59 | + session.run( |
| 60 | + "pylint", "-f", "colorized", "*.py", "performance", "src", "test", |
| 61 | + external=True |
| 62 | + ) |
0 commit comments