1+ import argparse
12from itertools import product
23from json import dumps
34import logging
910# add parent folder to python path so that we can import noxfile_utils.py
1011# note that you need to "pip install -r noxfile-requiterements.txt" for this file to work.
1112sys .path .append (str (Path (__file__ ).parent / "ci_tools" ))
12- from nox_utils import PY27 , PY37 , PY36 , PY35 , PY38 , PY39 , PY310 , power_session , rm_folder , rm_file , PowerSession # noqa
13+ from nox_utils import PY27 , PY37 , PY36 , PY35 , PY38 , PY39 , PY310 , PY311 , PY312 , power_session , rm_folder , rm_file , PowerSession , DONT_INSTALL # noqa
1314
1415
1516pkg_name = "makefun"
1617gh_org = "smarie"
1718gh_repo = "python-makefun"
1819
1920ENVS = {
20- # python 3.10 is not available on conda yet
21- # PY310: {"coverage": False, "pkg_specs": {"pip": ">19"}},
21+ PY312 : {"coverage" : False , "pkg_specs" : {"pip" : ">19" }},
22+ PY311 : {"coverage" : False , "pkg_specs" : {"pip" : ">19" }},
23+ PY310 : {"coverage" : False , "pkg_specs" : {"pip" : ">19" }},
2224 PY39 : {"coverage" : False , "pkg_specs" : {"pip" : ">19" }},
2325 PY38 : {"coverage" : False , "pkg_specs" : {"pip" : ">19" }},
2426 PY27 : {"coverage" : False , "pkg_specs" : {"pip" : ">10" }},
3032
3133
3234# set the default activated sessions, minimal for CI
33- nox .options .sessions = ["tests" , "flake8" ] # , "docs", "gh_pages"
35+ nox .options .sessions = ["tests" , "flake8" , "docs" ] # , "docs", "gh_pages"
36+ nox .options .error_on_missing_interpreters = True
3437nox .options .reuse_existing_virtualenvs = True # this can be done using -r
3538# if platform.system() == "Windows": >> always use this for better control
36- nox .options .default_venv_backend = "conda "
39+ nox .options .default_venv_backend = "virtualenv "
3740# os.environ["NO_COLOR"] = "True" # nox.options.nocolor = True does not work
3841# nox.options.verbose = True
3942
@@ -95,10 +98,10 @@ def tests(session: PowerSession, coverage, pkg_specs):
9598
9699 # list all (conda list alone does not work correctly on github actions)
97100 # session.run2("conda list")
98- conda_prefix = Path (session .bin )
99- if conda_prefix .name == "bin" :
100- conda_prefix = conda_prefix .parent
101- session .run2 ("conda list" , env = {"CONDA_PREFIX" : str (conda_prefix ), "CONDA_DEFAULT_ENV" : session .get_session_id ()})
101+ # conda_prefix = Path(session.bin)
102+ # if conda_prefix.name == "bin":
103+ # conda_prefix = conda_prefix.parent
104+ # session.run2("conda list", env={"CONDA_PREFIX": str(conda_prefix), "CONDA_DEFAULT_ENV": session.get_session_id()})
102105
103106 # Fail if the assumed python version is not the actual one
104107 session .run2 ("python ci_tools/check_python_version.py %s" % session .python )
@@ -111,7 +114,6 @@ def tests(session: PowerSession, coverage, pkg_specs):
111114 if not coverage :
112115 # install self so that it is recognized by pytest
113116 session .run2 ("pip install . --no-deps" )
114- # session.install(".", "--no-deps")
115117
116118 # simple: pytest only
117119 session .run2 ("python -m pytest --cache-clear -v tests/" )
@@ -141,7 +143,7 @@ def tests(session: PowerSession, coverage, pkg_specs):
141143 session .run2 ("genbadge coverage -i %s -o %s" % (Folders .coverage_xml , Folders .coverage_badge ))
142144
143145
144- @power_session (python = PY38 , logsdir = Folders .runlogs )
146+ @power_session (python = PY39 , logsdir = Folders .runlogs )
145147def flake8 (session : PowerSession ):
146148 """Launch flake8 qualimetry."""
147149
@@ -162,7 +164,7 @@ def flake8(session: PowerSession):
162164 rm_file (Folders .flake8_intermediate_file )
163165
164166
165- @power_session (python = [PY37 ])
167+ @power_session (python = [PY39 ])
166168def docs (session : PowerSession ):
167169 """Generates the doc and serves it on a local http server. Pass '-- build' to build statically instead."""
168170
@@ -175,11 +177,11 @@ def docs(session: PowerSession):
175177 session .run2 ("mkdocs serve" )
176178
177179
178- @power_session (python = [PY37 ])
180+ @power_session (python = [PY39 ])
179181def publish (session : PowerSession ):
180182 """Deploy the docs+reports on github pages. Note: this rebuilds the docs"""
181183
182- session .install_reqs (phase = "mkdocs " , phase_reqs = ["mkdocs-material" , "mkdocs" , "pymdown-extensions" , "pygments" ])
184+ session .install_reqs (phase = "publish " , phase_reqs = ["mkdocs-material" , "mkdocs" , "pymdown-extensions" , "pygments" ])
183185
184186 # possibly rebuild the docs in a static way (mkdocs serve does not build locally)
185187 session .run2 ("mkdocs build" )
@@ -200,7 +202,7 @@ def publish(session: PowerSession):
200202 # session.run2('codecov -t %s -f %s' % (codecov_token, Folders.coverage_xml))
201203
202204
203- @power_session (python = [PY37 ])
205+ @power_session (python = [PY39 ])
204206def release (session : PowerSession ):
205207 """Create a release on github corresponding to the latest tag"""
206208
@@ -261,19 +263,36 @@ def gha_list(session):
261263
262264 # see https://stackoverflow.com/q/66747359/7262247
263265
266+ # The options
267+ parser = argparse .ArgumentParser ()
268+ parser .add_argument ("-s" , "--session" , help = "The nox base session name" )
269+ parser .add_argument (
270+ "-v" ,
271+ "--with_version" ,
272+ action = "store_true" ,
273+ default = False ,
274+ help = "Return a list of lists where the first element is the python version and the second the nox session." ,
275+ )
276+ additional_args = parser .parse_args (session .posargs )
277+
264278 # get the desired base session to generate the list for
265- if len (session .posargs ) != 1 :
266- raise ValueError ("This session has a mandatory argument: <base_session_name>" )
267- session_func = globals ()[session .posargs [0 ]]
279+ session_func = globals ()[additional_args .session ]
268280
269281 # list all sessions for this base session
270282 try :
271283 session_func .parametrize
272284 except AttributeError :
273- sessions_list = ["%s-%s" % (session_func .__name__ , py ) for py in session_func .python ]
285+ if additional_args .with_version :
286+ sessions_list = [{"python" : py , "session" : "%s-%s" % (session_func .__name__ , py )} for py in session_func .python ]
287+ else :
288+ sessions_list = ["%s-%s" % (session_func .__name__ , py ) for py in session_func .python ]
274289 else :
275- sessions_list = ["%s-%s(%s)" % (session_func .__name__ , py , param )
276- for py , param in product (session_func .python , session_func .parametrize )]
290+ if additional_args .with_version :
291+ sessions_list = [{"python" : py , "session" : "%s-%s(%s)" % (session_func .__name__ , py , param )}
292+ for py , param in product (session_func .python , session_func .parametrize )]
293+ else :
294+ sessions_list = ["%s-%s(%s)" % (session_func .__name__ , py , param )
295+ for py , param in product (session_func .python , session_func .parametrize )]
277296
278297 # print the list so that it can be caught by GHA.
279298 # Note that json.dumps is optional since this is a list of string.
0 commit comments