12
12
MODULE_NAME = "module_name"
13
13
TESTS_PATH = "tests"
14
14
COVERAGE_FAIL_UNDER = 50
15
- DEFAULT_PYTHON = "3.12"
16
15
VENV_PATH = "./.venv"
17
16
LINT_PATH = "./src"
18
17
REQUIREMENTS_PATH = "./requirements"
37
36
nox .options .sessions = ["lint" , "test" ]
38
37
39
38
40
- @nox .session (python = False )
39
+ @nox .session ()
41
40
def dev (session : nox .Session ) -> None :
42
41
"""Setup a development environment by creating the venv and installs dependencies."""
43
42
# Use the active environement if it exists, otherwise create a new one
44
43
venv_path = os .environ .get ("VIRTUAL_ENV" , VENV_PATH )
45
44
46
45
if sys .platform == "win32" :
47
- py_command = "py"
48
46
venv_path = f"{ venv_path } /Scripts"
49
47
activate_command = f"{ venv_path } /activate"
50
48
else :
51
- py_command = f"python{ DEFAULT_PYTHON } "
52
49
venv_path = f"{ venv_path } /bin"
53
50
activate_command = f"source { venv_path } /activate"
54
51
55
52
if not os .path .exists (VENV_PATH ):
56
- session .run (py_command , "-m" , "venv" , VENV_PATH , "--upgrade-deps" )
53
+ session .run ("python" , "-m" , "venv" , VENV_PATH , "--upgrade-deps" )
57
54
58
- python = f"{ venv_path } /python"
59
- requirement_files = get_requirement_files ()
55
+ python = partial (session .run , f"{ venv_path } /python" , "-m" )
60
56
61
- session . run ( python , "-m" , "pip" , "install" , "-e" , "." )
57
+ requirement_files = get_requirement_files ( )
62
58
for requirement_file in requirement_files :
63
- session .run (python , "-m" , "pip" , "install" , "-r" , requirement_file )
59
+ python ("pip" , "install" , "-r" , requirement_file , external = True )
60
+ python ("pip" , "install" , "--editable" , "." , external = True )
64
61
65
- session . run ( python , "-m" , " pip" , "install" , "pre-commit" )
66
- session .run (f"{ venv_path } /pre-commit" , "install" )
62
+ python ( " pip" , "install" , "pre-commit" , external = True )
63
+ session .run (f"{ venv_path } /pre-commit" , "install" , external = True )
67
64
68
65
if not os .environ .get ("VIRTUAL_ENV" ):
69
66
session .log (f"\n \n Run '{ activate_command } ' to enter the virtual environment.\n " )
@@ -74,8 +71,7 @@ def run_tests_with_coverage(session: nox.Session) -> None:
74
71
"""Run pytest with coverage, outputs console report and json."""
75
72
print_standard_logs (session )
76
73
77
- session .install ("." )
78
- session .install ("-r" , f"{ REQUIREMENTS_PATH } /requirements-test.txt" )
74
+ session .install ("." , "-r" , f"{ REQUIREMENTS_PATH } /requirements-test.txt" )
79
75
80
76
coverage = partial (session .run , "python" , "-m" , "coverage" )
81
77
@@ -129,7 +125,7 @@ def run_linters_and_formatters(session: nox.Session) -> None:
129
125
python ("mypy" , "--no-incremental" , "--package" , MODULE_NAME )
130
126
131
127
132
- @nox .session (python = DEFAULT_PYTHON )
128
+ @nox .session ()
133
129
def build (session : nox .Session ) -> None :
134
130
"""Build distribution files."""
135
131
print_standard_logs (session )
@@ -138,7 +134,7 @@ def build(session: nox.Session) -> None:
138
134
session .run ("python" , "-m" , "build" )
139
135
140
136
141
- @nox .session (python = DEFAULT_PYTHON , name = "update-deps" )
137
+ @nox .session (name = "update-deps" )
142
138
def update_deps (session : nox .Session ) -> None :
143
139
"""Process requirement*.txt files, updating only additions/removals."""
144
140
print_standard_logs (session )
@@ -156,7 +152,7 @@ def update_deps(session: nox.Session) -> None:
156
152
)
157
153
158
154
159
- @nox .session (python = DEFAULT_PYTHON , name = "upgrade-deps" )
155
+ @nox .session (name = "upgrade-deps" )
160
156
def upgrade_deps (session : nox .Session ) -> None :
161
157
"""Process requirement*.txt files and upgrade all libraries as possible."""
162
158
print_standard_logs (session )
0 commit comments