From 1b67d1b408bc3ba91c95cdc8a9f341b88767bd45 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 8 Mar 2019 13:08:17 +0100 Subject: [PATCH] revisit ci/bootstrap.py --- ci/bootstrap.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ci/bootstrap.py b/ci/bootstrap.py index 885f20bc..d78c989b 100755 --- a/ci/bootstrap.py +++ b/ci/bootstrap.py @@ -1,14 +1,19 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import, print_function, unicode_literals +from __future__ import absolute_import +from __future__ import print_function +from __future__ import unicode_literals import os +import subprocess import sys from os.path import abspath from os.path import dirname from os.path import exists from os.path import join +import jinja2 + if __name__ == "__main__": base_path = dirname(dirname(abspath(__file__))) print("Project path: {0}".format(base_path)) @@ -18,8 +23,6 @@ else: bin_path = join(env_path, "bin") if not exists(env_path): - import subprocess - print("Making bootstrap env in: {0} ...".format(env_path)) try: subprocess.check_call(["virtualenv", env_path]) @@ -32,10 +35,6 @@ print("Re-executing with: {0}".format(python_executable)) os.execv(python_executable, [python_executable, __file__]) - import jinja2 - - import subprocess - jinja = jinja2.Environment( loader=jinja2.FileSystemLoader(join(base_path, "ci", "templates")), trim_blocks=True, @@ -48,11 +47,14 @@ # WARNING: 'tox' must be installed globally or in the project's virtualenv for line in subprocess.check_output(['tox', '--listenvs'], universal_newlines=True).splitlines() ] - tox_environments = [line for line in tox_environments if line not in ['clean', 'report', 'docs', 'check']] + tox_environments = [line for line in tox_environments + if line not in ['clean', 'report', 'docs', 'check']] template_vars = {'tox_environments': tox_environments} for py_ver in '27 34 35 py'.split(): - template_vars['py%s_environments' % py_ver] = [x for x in tox_environments if x.startswith('py' + py_ver)] + template_vars['py%s_environments' % py_ver] = [ + x for x in tox_environments + if x.startswith('py' + py_ver)] for name in os.listdir(join("ci", "templates")): with open(join(base_path, name), "w") as fh: