5
5
6
6
7
7
def usage ():
8
- print ('Web installer build script' )
9
- print ('build.py <installer version> <tag version>' )
10
- print ('The installer verison is the version number used within the conda constructor script' )
11
- print ('The tag verison is the version of cadquery that will be pulled from github' )
8
+ print ("Web installer build script" )
9
+ print ("build.py <installer version> <tag version>" )
10
+ print (
11
+ "The installer verison is the version number used within the conda constructor script"
12
+ )
13
+ print ("The tag verison is the version of cadquery that will be pulled from github" )
14
+
12
15
13
16
def write_file (destpath , contents ):
14
- with open (destpath , "w" ) as destfile :
15
- destfile .write (contents )
17
+ with open (destpath , "w" ) as destfile :
18
+ destfile .write (contents )
19
+
16
20
17
21
def run_cmd (cmdarray , workingdir , captureout = False ):
18
22
stdout = stderr = None
19
23
if captureout :
20
24
stdout = stderr = subprocess .PIPE
21
- proc = subprocess .Popen (cmdarray , cwd = workingdir , stdout = stdout , stderr = stderr , universal_newlines = True )
25
+ proc = subprocess .Popen (
26
+ cmdarray , cwd = workingdir , stdout = stdout , stderr = stderr , universal_newlines = True
27
+ )
22
28
proc_out , proc_err = proc .communicate ()
23
29
if proc .returncode != 0 :
24
- raise RuntimeError (' Failure to run command' )
30
+ raise RuntimeError (" Failure to run command" )
25
31
return stdout , stderr
26
32
33
+
27
34
def generate_templates (installer_version , tag_version ):
28
- print ('Generating Scripts' )
29
- env = Environment (
30
- loader = FileSystemLoader ("." ),
31
- autoescape = select_autoescape ()
32
- )
35
+ print ("Generating Scripts" )
36
+ env = Environment (loader = FileSystemLoader ("." ), autoescape = select_autoescape ())
33
37
34
38
template = env .get_template ("construct.yaml.jinja2" )
35
39
output = template .render (installer_version = installer_version )
36
- write_file (' construct.yaml' , output )
40
+ write_file (" construct.yaml" , output )
37
41
38
42
template = env .get_template ("post-install.bat.jinja2" )
39
43
output = template .render (tag_version = tag_version )
40
- write_file (' post-install.bat' , output )
44
+ write_file (" post-install.bat" , output )
41
45
42
46
template = env .get_template ("post-install.sh.jinja2" )
43
47
output = template .render (tag_version = tag_version )
44
- write_file (' post-install.sh' , output )
48
+ write_file (" post-install.sh" , output )
45
49
46
50
47
51
def run_constructor ():
48
- print (' Running constructor' )
52
+ print (" Running constructor" )
49
53
scriptdir = os .path .dirname (os .path .realpath (__file__ ))
50
54
builddir = os .path .join (scriptdir , 'build' )
51
55
if not os .path .exists (builddir ):
52
56
os .makedirs (builddir )
53
57
run_cmd (['constructor' , scriptdir ], builddir )
54
58
55
- # TODO
56
59
57
60
def main ():
58
61
if len (sys .argv ) < 2 :
@@ -63,4 +66,5 @@ def main():
63
66
generate_templates (installer_version , tag_version )
64
67
run_constructor ()
65
68
69
+
66
70
main ()
0 commit comments