mwchase icon

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

mwchase | PRO | 10/14/19 12:35:31 AM UTC | 0 ⭐ | 848 👁️ | Never ⏰ | []
Python |

1.18 KB

|

None

|

0 👍

/

0 👎

@nox.session
def bootstrap(session):
    session.install("jinja2", "matrix")
    session.run("python", "-c", """\
import os.path
 
import jinja2
import matrix
 
jinja = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.join("ci", "templates")),
    trim_blocks=True,
    lstrip_blocks=True,
    keep_trailing_newline=True
)
 
nox_environments = {}
 
for (alias, conf) in matrix.from_file("setup.cfg").items():
    python = conf["python_versions"]
    deps = conf["dependencies"]
    nox_environments[alias] = {
        "python": "python" + python if "py" not in python else python,
        "deps": deps.split(),
    }
    if "coverage_flags" in conf:
        cover = {"false": False, "true": True}[conf["coverage_flags"].lower()]
        nox_environments[alias].update(cover=cover)
    if "environment_variables" in conf:
        env_vars = conf["environment_variables"]
        nox_environments[alias].update(env_vars=env_vars.split())
 
for name in os.listdir(os.path.join("ci", "templates")):
    with open(name, "w") as fh:
        fh.write(jinja.get_template(name).render(nox_environments=nox_environments))
    print("Wrote {}".format(name))
print("DONE.")
""")

Comments