1414import time
1515
1616from typing import Optional
17+
1718try :
1819 from toposort import toposort_flatten
1920except ImportError :
2728dep_graph = {
2829 "wasmer-types" : set ([]),
2930 "wasmer-derive" : set ([]),
30- "wasmer-vm" : set (["wasmer-types" ]),
31- "wasmer-compiler" : set (["wasmer-vm" , "wasmer-types" ]),
31+ "wasmer-vm" : set (["wasmer-types" , "wasmer-artifact" ]),
32+ "wasmer-compiler" : set (["wasmer-types" ]),
33+ "wasmer-compiler-cli" : set (
34+ [
35+ "wasmer-engine-universal-artifact" ,
36+ "wasmer-compiler" ,
37+ "wasmer-types" ,
38+ "wasmer-compiler-singlepass" ,
39+ "wasmer-compiler-cranelift" ,
40+ ]
41+ ),
42+ "wasmer-engine-universal-artifact" : set (
43+ ["wasmer-artifact" , "wasmer-types" , "wasmer-compiler" ]
44+ ),
45+ "wasmer-artifact" : set (["wasmer-types" , "wasmer-compiler" ]),
3246 "wasmer-object" : set (["wasmer-types" , "wasmer-compiler" ]),
33- "wasmer-engine" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" ]),
34- "wasmer-compiler-singlepass" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" ]),
35- "wasmer-compiler-cranelift" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" ]),
36- "wasmer-compiler-llvm" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" ]),
37- "wasmer-engine-universal" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" , "wasmer-engine" ]),
38- "wasmer-engine-dylib" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" , "wasmer-engine" ,
39- "wasmer-object" ]),
40- "wasmer-engine-staticlib" : set (["wasmer-types" , "wasmer-vm" , "wasmer-compiler" , "wasmer-engine" ,
41- "wasmer-object" ]),
42- "wasmer" : set (["wasmer-vm" , "wasmer-compiler-singlepass" , "wasmer-compiler-cranelift" ,
43- "wasmer-compiler-llvm" , "wasmer-compiler" , "wasmer-engine" , "wasmer-engine-universal" ,
44- "wasmer-engine-dylib" , "wasmer-engine-staticlib" , "wasmer-types" , "wasmer-derive" ]),
47+ "wasmer-engine" : set (
48+ ["wasmer-types" , "wasmer-compiler" , "wasmer-artifact" , "wasmer-vm" ]
49+ ),
50+ "wasmer-compiler-singlepass" : set (["wasmer-types" , "wasmer-compiler" ]),
51+ "wasmer-compiler-cranelift" : set (["wasmer-types" , "wasmer-compiler" ]),
52+ "wasmer-compiler-llvm" : set (["wasmer-compiler" , "wasmer-vm" , "wasmer-types" ]),
53+ "wasmer-engine-universal" : set (
54+ [
55+ "wasmer-engine-universal-artifact" ,
56+ "wasmer-types" ,
57+ "wasmer-compiler" ,
58+ "wasmer-vm" ,
59+ "wasmer-engine" ,
60+ ]
61+ ),
62+ "wasmer-engine-dylib" : set (
63+ [
64+ "wasmer-artifact" ,
65+ "wasmer-types" ,
66+ "wasmer-compiler" ,
67+ "wasmer-vm" ,
68+ "wasmer-engine" ,
69+ "wasmer-object" ,
70+ ]
71+ ),
72+ "wasmer-engine-staticlib" : set (
73+ [
74+ "wasmer-artifact" ,
75+ "wasmer-types" ,
76+ "wasmer-compiler" ,
77+ "wasmer-vm" ,
78+ "wasmer-engine" ,
79+ "wasmer-object" ,
80+ ]
81+ ),
82+ "wasmer" : set (
83+ [
84+ "wasmer-artifact" ,
85+ "wasmer-vm" ,
86+ "wasmer-compiler" ,
87+ "wasmer-derive" ,
88+ "wasmer-engine" ,
89+ "wasmer-types" ,
90+ "wasmer-compiler-singlepass" ,
91+ "wasmer-compiler-cranelift" ,
92+ "wasmer-compiler-llvm" ,
93+ "wasmer-engine-universal" ,
94+ "wasmer-engine-dylib" ,
95+ ]
96+ ),
4597 "wasmer-vfs" : set ([]),
4698 "wasmer-cache" : set (["wasmer" ]),
4799 "wasmer-wasi" : set (["wasmer" , "wasmer-wasi-types" , "wasmer-vfs" ]),
48100 "wasmer-wasi-types" : set (["wasmer-types" ]),
49101 "wasmer-wasi-experimental-io-devices" : set (["wasmer-wasi" ]),
50102 "wasmer-emscripten" : set (["wasmer" ]),
51- "wasmer-c-api" : set (["wasmer" , "wasmer-compiler" , "wasmer-compiler-cranelift" , "wasmer-compiler-singlepass" ,
52- "wasmer-compiler-llvm" , "wasmer-emscripten" , "wasmer-engine" , "wasmer-engine-universal" ,
53- "wasmer-engine-dylib" , "wasmer-engine-staticlib" , "wasmer-wasi" , "wasmer-types" ]),
103+ "wasmer-c-api" : set (
104+ [
105+ "wasmer" ,
106+ "wasmer-compiler" ,
107+ "wasmer-compiler-cranelift" ,
108+ "wasmer-compiler-singlepass" ,
109+ "wasmer-compiler-llvm" ,
110+ "wasmer-emscripten" ,
111+ "wasmer-engine" ,
112+ "wasmer-engine-universal" ,
113+ "wasmer-engine-dylib" ,
114+ "wasmer-engine-staticlib" ,
115+ "wasmer-middlewares" ,
116+ "wasmer-wasi" ,
117+ "wasmer-types" ,
118+ ]
119+ ),
54120 "wasmer-middlewares" : set (["wasmer" , "wasmer-types" , "wasmer-vm" ]),
55121 "wasmer-wast" : set (["wasmer" , "wasmer-wasi" , "wasmer-vfs" ]),
56- "wasmer-cli" : set (["wasmer" , "wasmer-compiler" , "wasmer-compiler-cranelift" , "wasmer-compiler-singlepass" ,
57- "wasmer-compiler-llvm" , "wasmer-emscripten" , "wasmer-engine" , "wasmer-engine-universal" ,
58- "wasmer-engine-dylib" , "wasmer-engine-staticlib" , "wasmer-vm" , "wasmer-wasi" ,
59- "wasmer-wasi-experimental-io-devices" , "wasmer-wast" , "wasmer-cache" , "wasmer-types" ,
60- "wasmer-vfs" ]),
122+ "wasmer-cli" : set (
123+ [
124+ "wasmer" ,
125+ "wasmer-compiler" ,
126+ "wasmer-compiler-cranelift" ,
127+ "wasmer-compiler-singlepass" ,
128+ "wasmer-compiler-llvm" ,
129+ "wasmer-emscripten" ,
130+ "wasmer-engine" ,
131+ "wasmer-engine-universal" ,
132+ "wasmer-engine-dylib" ,
133+ "wasmer-engine-staticlib" ,
134+ "wasmer-vm" ,
135+ "wasmer-wasi" ,
136+ "wasmer-wasi-experimental-io-devices" ,
137+ "wasmer-wast" ,
138+ "wasmer-cache" ,
139+ "wasmer-types" ,
140+ "wasmer-vfs" ,
141+ ]
142+ ),
61143}
62144
63145# where each crate is located in the `lib` directory
64146# TODO: this could also be generated from the toml files
65147location = {
148+ "wasmer-artifact" : "artifact" ,
149+ "wasmer-engine-universal-artifact" : "universal-artifact" ,
150+ "wasmer-compiler-cli" : "cli-compiler" ,
66151 "wasmer-types" : "types" ,
67152 "wasmer-derive" : "derive" ,
68153 "wasmer-vm" : "vm" ,
91176
92177no_dry_run = False
93178
179+
94180def get_latest_version_for_crate (crate_name : str ) -> Optional [str ]:
95181 output = subprocess .run (["cargo" , "search" , crate_name ], capture_output = True )
96182 rexp_src = '^{} = "([^"]+)"' .format (crate_name )
@@ -101,13 +187,15 @@ def get_latest_version_for_crate(crate_name: str) -> Optional[str]:
101187 if result :
102188 return result .group (1 )
103189
190+
104191def is_crate_already_published (crate_name : str ) -> bool :
105192 found_string = get_latest_version_for_crate (crate_name )
106193 if found_string is None :
107194 return False
108195
109196 return target_version == found_string
110197
198+
111199def publish_crate (crate : str ):
112200 starting_dir = os .getcwd ()
113201 os .chdir ("lib/{}" .format (location [crate ]))
@@ -117,18 +205,26 @@ def publish_crate(crate: str):
117205 output = subprocess .run (["cargo" , "publish" ])
118206 else :
119207 print ("In dry-run: not publishing crate `{}`" .format (crate ))
208+ output = subprocess .run (["cargo" , "publish" , "--dry-run" ])
120209
121210 os .chdir (starting_dir )
122211
212+
123213def main ():
124- os .environ ['WASMER_PUBLISH_SCRIPT_IS_RUNNING' ] = '1'
125- parser = argparse .ArgumentParser (description = 'Publish the Wasmer crates to crates.io' )
126- parser .add_argument ('--no-dry-run' , default = False , action = 'store_true' ,
127- help = 'Run the script without actually publishing anything to crates.io' )
214+ os .environ ["WASMER_PUBLISH_SCRIPT_IS_RUNNING" ] = "1"
215+ parser = argparse .ArgumentParser (
216+ description = "Publish the Wasmer crates to crates.io"
217+ )
218+ parser .add_argument (
219+ "--no-dry-run" ,
220+ default = False ,
221+ action = "store_true" ,
222+ help = "Run the script without actually publishing anything to crates.io" ,
223+ )
128224 args = vars (parser .parse_args ())
129225
130226 global no_dry_run
131- no_dry_run = args [' no_dry_run' ]
227+ no_dry_run = args [" no_dry_run" ]
132228
133229 # get the order to publish the crates in
134230 order = list (toposort_flatten (dep_graph , sort = True ))
0 commit comments