-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
167 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,72 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
from os.path import exists | ||
from os.path import join | ||
from os.path import dirname | ||
from os.path import abspath | ||
|
||
|
||
if __name__ == "__main__": | ||
base_path = dirname(dirname(abspath(__file__))) | ||
str_to_bool = {"false": False, "true": True} | ||
|
||
base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
print("Project path: {0}".format(base_path)) | ||
env_path = join(base_path, ".tox", "bootstrap") | ||
|
||
env_path = os.path.join(base_path, ".tox", "bootstrap") | ||
if sys.platform == "win32": | ||
bin_path = join(env_path, "Scripts") | ||
bin_path = os.path.join(env_path, "Scripts") | ||
else: | ||
bin_path = join(env_path, "bin") | ||
if not exists(env_path): | ||
import subprocess | ||
bin_path = os.path.join(env_path, "bin") | ||
|
||
if not os.path.exists(env_path): | ||
print("Making bootstrap env in: {0} ...".format(env_path)) | ||
try: | ||
subprocess.check_call(["virtualenv", env_path]) | ||
except Exception: | ||
subprocess.check_call([sys.executable, "-m", "virtualenv", env_path]) | ||
subprocess.check_call([sys.executable, "-m", "virtualenv", | ||
env_path]) | ||
|
||
print("Installing `jinja2` and `matrix` into bootstrap environment ...") | ||
subprocess.check_call([join(bin_path, "pip"), "install", "jinja2", "matrix"]) | ||
activate = join(bin_path, "activate_this.py") | ||
exec(compile(open(activate, "rb").read(), activate, "exec"), dict(__file__=activate)) | ||
subprocess.check_call([os.path.join(bin_path, "pip"), "install", | ||
"jinja2", "matrix"]) | ||
|
||
activate = os.path.join(bin_path, "activate_this.py") | ||
act_dict = {__file__: activate} | ||
|
||
# tox requires activation with exec | ||
exec(compile(open(activate, "rb").read(), activate, "exec"), act_dict) | ||
|
||
# Import here to ensure success, since they may have just been installed | ||
import jinja2 | ||
import matrix | ||
|
||
jinja = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")), | ||
trim_blocks=True, | ||
lstrip_blocks=True, | ||
keep_trailing_newline=True | ||
) | ||
loader=jinja2.FileSystemLoader(os.path.join(base_path, "ci", | ||
"templates")), | ||
trim_blocks=True, lstrip_blocks=True, keep_trailing_newline=True) | ||
tox_environments = {} | ||
for (alias, conf) in matrix.from_file(join(base_path, "setup.cfg")).items(): | ||
setup_matrix = matrix.from_file(os.path.join(base_path, | ||
"setup.cfg")).items() | ||
for (alias, conf) in setup_matrix: | ||
python = conf["python_versions"] | ||
deps = conf["dependencies"] if "dependencies" in conf.keys() else "" | ||
if "coverage_flags" in conf: | ||
cover = {"false": False, "true": True}[conf["coverage_flags"].lower()] | ||
if "environment_variables" in conf: | ||
if "coverage_flags" in conf.keys(): | ||
cover = str_to_bool[conf["coverage_flags"].lower()] | ||
if "environment_variables" in conf.keys(): | ||
env_vars = conf["environment_variables"] | ||
|
||
tox_environments[alias] = { | ||
"python": "python" + python if "py" not in python else python, | ||
"deps": deps.split(), | ||
} | ||
if "coverage_flags" in conf: | ||
"deps": deps.split()} | ||
|
||
if "coverage_flags" in conf.keys(): | ||
tox_environments[alias].update(cover=cover) | ||
if "environment_variables" in conf: | ||
if "environment_variables" in conf.keys(): | ||
tox_environments[alias].update(env_vars=env_vars.split()) | ||
|
||
for name in os.listdir(join("ci", "templates")): | ||
with open(join(base_path, name), "w") as fh: | ||
fh.write(jinja.get_template(name).render(tox_environments=tox_environments)) | ||
for name in os.listdir(os.path.join("ci", "templates")): | ||
with open(os.path.join(base_path, name), "w") as fh: | ||
fh.write(jinja.get_template(name).render( | ||
tox_environments=tox_environments)) | ||
print("Wrote {}".format(name)) | ||
print("DONE.") |
Oops, something went wrong.