-
Notifications
You must be signed in to change notification settings - Fork 25
/
noxfile.py
59 lines (50 loc) · 1.83 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
import os
import sys
import nox
from radcad import Backend
# Ensure the Nox virtualenv is used instead of PDM's
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
# Select the Python versions to test against (these must be installed on the system)
python_versions = ['3.8', '3.9', '3.10', '3.11', '3.12']
# Configure radCAD for tests
if sys.platform.startswith('win'):
# Use the multiprocessing backend on Windows to avoid recursion depth errors
# TODO Remove this once the recursion depth issue is resolved
os.environ['RADCAD_BACKEND'] = Backend.MULTIPROCESSING.name
def select_lockfile(session):
'''Select the PDM package manager lockfile based on the Python version'''
if session.python == '3.8':
return 'pdm-py38.lock'
return 'pdm.lock'
def install_dependencies(session):
'''Install the dependencies for the current Python version'''
lockfile = select_lockfile(session)
session.install('pdm') # 'pytest-xdist', 'pytest-benchmark'
session.run_always(
'pdm', 'sync', '-d',
'-G', 'compat',
'-G', 'extension-backend-ray',
'--lockfile', lockfile,
)
@nox.session(python=python_versions)
def tests(session):
install_dependencies(session)
session.run(
'pdm', 'run', 'pytest',
# Currently failing on Windows due to recursion depth limit
# '-n', 'auto', # Run tests in parallel using pytest-xdist
'tests'
)
@nox.session(python=python_versions)
def benchmarks(session):
install_dependencies(session)
session.run(
'pdm', 'run', 'pytest',
'benchmarks/benchmark_radcad.py',
f'--benchmark-save=py{session.python}',
)
session.notify("compare_benchmarks")
@nox.session(python='3.10')
def compare_benchmarks(session):
install_dependencies(session)
session.run('pdm', 'run', 'pytest-benchmark', 'compare')