mwchase

When you're not ready to give up on an idea

Oct 13th, 2019
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.18 KB | None | 0 0
  1. @nox.session
  2. def bootstrap(session):
  3.     session.install("jinja2", "matrix")
  4.     session.run("python", "-c", """\
  5. import os.path
  6.  
  7. import jinja2
  8. import matrix
  9.  
  10. jinja = jinja2.Environment(
  11.    loader=jinja2.FileSystemLoader(os.path.join("ci", "templates")),
  12.    trim_blocks=True,
  13.    lstrip_blocks=True,
  14.    keep_trailing_newline=True
  15. )
  16.  
  17. nox_environments = {}
  18.  
  19. for (alias, conf) in matrix.from_file("setup.cfg").items():
  20.    python = conf["python_versions"]
  21.    deps = conf["dependencies"]
  22.    nox_environments[alias] = {
  23.        "python": "python" + python if "py" not in python else python,
  24.        "deps": deps.split(),
  25.    }
  26.    if "coverage_flags" in conf:
  27.        cover = {"false": False, "true": True}[conf["coverage_flags"].lower()]
  28.        nox_environments[alias].update(cover=cover)
  29.    if "environment_variables" in conf:
  30.        env_vars = conf["environment_variables"]
  31.        nox_environments[alias].update(env_vars=env_vars.split())
  32.  
  33. for name in os.listdir(os.path.join("ci", "templates")):
  34.    with open(name, "w") as fh:
  35.        fh.write(jinja.get_template(name).render(nox_environments=nox_environments))
  36.    print("Wrote {}".format(name))
  37. print("DONE.")
  38. """)
Advertisement
Add Comment
Please, Sign In to add comment