1212MODULE_NAME = "module_name"
1313TESTS_PATH = "tests"
1414COVERAGE_FAIL_UNDER = 50
15- DEFAULT_PYTHON = "3.12"
1615VENV_PATH = "./.venv"
1716LINT_PATH = "./src"
1817REQUIREMENTS_PATH = "./requirements"
3736nox .options .sessions = ["lint" , "test" ]
3837
3938
40- @nox .session (python = False )
39+ @nox .session ()
4140def dev (session : nox .Session ) -> None :
4241 """Setup a development environment by creating the venv and installs dependencies."""
4342 # Use the active environement if it exists, otherwise create a new one
4443 venv_path = os .environ .get ("VIRTUAL_ENV" , VENV_PATH )
4544
4645 if sys .platform == "win32" :
47- py_command = "py"
4846 venv_path = f"{ venv_path } /Scripts"
4947 activate_command = f"{ venv_path } /activate"
5048 else :
51- py_command = f"python{ DEFAULT_PYTHON } "
5249 venv_path = f"{ venv_path } /bin"
5350 activate_command = f"source { venv_path } /activate"
5451
5552 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" )
5754
58- python = f"{ venv_path } /python"
59- requirement_files = get_requirement_files ()
55+ python = partial (session .run , f"{ venv_path } /python" , "-m" )
6056
61- session . run ( python , "-m" , "pip" , "install" , "-e" , "." )
57+ requirement_files = get_requirement_files ( )
6258 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 )
6461
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 )
6764
6865 if not os .environ .get ("VIRTUAL_ENV" ):
6966 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:
7471 """Run pytest with coverage, outputs console report and json."""
7572 print_standard_logs (session )
7673
77- session .install ("." )
78- session .install ("-r" , f"{ REQUIREMENTS_PATH } /requirements-test.txt" )
74+ session .install ("." , "-r" , f"{ REQUIREMENTS_PATH } /requirements-test.txt" )
7975
8076 coverage = partial (session .run , "python" , "-m" , "coverage" )
8177
@@ -129,7 +125,7 @@ def run_linters_and_formatters(session: nox.Session) -> None:
129125 python ("mypy" , "--no-incremental" , "--package" , MODULE_NAME )
130126
131127
132- @nox .session (python = DEFAULT_PYTHON )
128+ @nox .session ()
133129def build (session : nox .Session ) -> None :
134130 """Build distribution files."""
135131 print_standard_logs (session )
@@ -138,7 +134,7 @@ def build(session: nox.Session) -> None:
138134 session .run ("python" , "-m" , "build" )
139135
140136
141- @nox .session (python = DEFAULT_PYTHON , name = "update-deps" )
137+ @nox .session (name = "update-deps" )
142138def update_deps (session : nox .Session ) -> None :
143139 """Process requirement*.txt files, updating only additions/removals."""
144140 print_standard_logs (session )
@@ -156,7 +152,7 @@ def update_deps(session: nox.Session) -> None:
156152 )
157153
158154
159- @nox .session (python = DEFAULT_PYTHON , name = "upgrade-deps" )
155+ @nox .session (name = "upgrade-deps" )
160156def upgrade_deps (session : nox .Session ) -> None :
161157 """Process requirement*.txt files and upgrade all libraries as possible."""
162158 print_standard_logs (session )
0 commit comments