blob: 372ec84a048e897d9aa2a8a8b548ed704260ad2d [file] [log] [blame]
#!/usr/bin/env python
"""
Rebuilds the .travis.yml file based on the output of ``tox --listenvs``
"""
import subprocess as sp
template = """\
# !!! WARNING !!!
# This file is automatically generated by ./rebuild-travis-yaml
# !!! WARNING !!!
language: python
sudo: false
matrix:
include:
{env_list}
install: pip install tox==3.7.0
script: tox
# !!! WARNING !!!
# This file is automatically generated by ./rebuild-travis-yaml
# !!! WARNING !!!
"""
# Maps tox python versions (ex, "py27") to Travis Python versions (ex, "2.7")
py_version_map = {
"py26": "2.6",
"py27": "2.7",
"py35": "3.5",
"py36": "3.6",
"py37": "3.7",
"pypy": "pypy",
}
def main():
tox_envs = sp.check_output("tox --listenvs", shell=True).splitlines()
env_list = []
for env in tox_envs:
if not env.strip():
continue
py_ver, _, _ = env.partition("-")
env_list.append("""\
- env: "TOXENV=%s"
python: "%s"
""" %(env, py_version_map[py_ver]))
with open(".travis.yml", "w") as f:
f.write(template.format(env_list="".join(env_list)))
if __name__ == "__main__":
main()