forked from conan-io/conan-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime_zip_deploy.py
26 lines (24 loc) · 1.06 KB
/
runtime_zip_deploy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os, shutil
import zipfile
# USE **KWARGS to be robust against changes
def deploy(graph, output_folder, **kwargs):
conanfile = graph.root.conanfile
files = []
for r, d in conanfile.dependencies.items():
if d.package_folder is None:
continue
# look for .dlls and .exes in the bin folder
for dir in [d.cpp_info.bindir, d.cpp_info.libdir]:
search_dir = os.path.join(d.package_folder, dir)
if not os.path.isdir(search_dir):
continue
for f in os.listdir(search_dir):
src = os.path.join(search_dir, f)
if f.endswith(".dll") or f.endswith(".exe") or f.endswith(".dylib") or os.access(src, os.X_OK):
dst = os.path.join(output_folder, f)
shutil.copy2(src, dst)
files.append(dst)
with zipfile.ZipFile(os.path.join(output_folder, 'runtime.zip'), 'w') as myzip:
for f in files:
myzip.write(f, os.path.basename(f), compress_type=zipfile.ZIP_DEFLATED)
os.remove(f)