@@ -22,10 +22,19 @@ def main():
22
22
parser .add_argument ('in_yml' , default = '.travis.yml' , nargs = '?' ,
23
23
help = 'input travis YAML file '
24
24
'(default is ".travis.yml")' )
25
+ parser .add_argument ('--no-py-env' , action = 'store_true' ,
26
+ help = 'omit Python virtualenv building'
27
+ ' and substitute env vars that usually result' )
25
28
parser .add_argument ('--out-sh' ,
26
29
help = 'output sh file name '
27
- '(default is input name with .sh extension)' )
30
+ '(default is input name with .sh extension) '
31
+ '("-" means stdout)' )
32
+ parser .add_argument ('-L' , '--local' , action = 'store_true' ,
33
+ help = 'shortcut for "--no-py-env --out-sh -"' )
28
34
args = parser .parse_args ()
35
+ if args .local :
36
+ args .out_sh = '-'
37
+ args .no_py_env = True
29
38
with open (args .in_yml , 'rt' ) as fobj :
30
39
travis_dict = yaml .load (fobj )
31
40
out_sh = (splitext (args .in_yml )[0 ] + '.sh' if args .out_sh is None
@@ -37,8 +46,19 @@ def main():
37
46
warnings .warn ('Could not get travis vars from file' )
38
47
parts += ['# install' ] + get_yaml_entry (travis_dict , 'install' )
39
48
parts += ['# test' ] + get_yaml_entry (travis_dict , 'script' )
49
+ if args .no_py_env :
50
+ parts = [part for part in parts
51
+ if not part .startswith ('get_python_environment' )]
52
+ parts = ['# Variables usually set by `get_python_environment`' ,
53
+ 'export PIP_CMD=pip' ,
54
+ 'export PYTHON_EXE=python' ,
55
+ 'export VIRTUALENV_CMD=virtualenv' ] + parts
56
+ content = '\n ' .join (parts )
57
+ if out_sh == '-' :
58
+ print (content )
59
+ return
40
60
with open (out_sh , 'wt' ) as fobj :
41
- fobj .write (' \n ' . join ( parts ) + ' \n ' )
61
+ fobj .write (content )
42
62
print ('Written ' + out_sh )
43
63
44
64
0 commit comments