MCPcopy Index your code
hub / github.com/apache/tvm / tar

Function tar

python/tvm/support/tar.py:28–58  ·  view source on GitHub ↗

Create tarball containing all files in root. Parameters ---------- output : str The target shared library. files : list List of files to be bundled.

(output, files)

Source from the content-addressed store, hash-verified

26
27
28def tar(output, files):
29 """Create tarball containing all files in root.
30
31 Parameters
32 ----------
33 output : str
34 The target shared library.
35
36 files : list
37 List of files to be bundled.
38 """
39 cmd = ["tar"]
40 cmd += ["-czf"]
41 temp = utils.tempdir()
42 fset = set()
43 for fname in files:
44 base = os.path.basename(fname)
45 if base in fset:
46 raise ValueError(f"duplicate file name {base}")
47 fset.add(base)
48 shutil.copy(fname, temp.relpath(base))
49 cmd += [output]
50 cmd += ["-C", temp.temp_dir]
51 cmd += temp.listdir()
52 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
53 (out, _) = proc.communicate()
54
55 if proc.returncode != 0:
56 msg = "Tar error:\n"
57 msg += out.decode("utf-8", errors="replace")
58 raise RuntimeError(msg)
59
60
61# assign output format

Callers 2

saveMethod · 0.90
saveMethod · 0.90

Calls 5

relpathMethod · 0.80
addMethod · 0.45
copyMethod · 0.45
listdirMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected