MCPcopy
hub / github.com/astral-sh/python-build-standalone / copy_file_to_container

Function copy_file_to_container

pythonbuild/docker.py:101–111  ·  view source on GitHub ↗

Copy a path on the local filesystem to a running container.

(path, container, container_path, archive_path=None)

Source from the content-addressed store, hash-verified

99
100
101def copy_file_to_container(path, container, container_path, archive_path=None):
102 """Copy a path on the local filesystem to a running container."""
103 buf = io.BytesIO()
104 tf = tarfile.open("irrelevant", "w", buf)
105
106 dest_path = archive_path or path.name
107 tf.add(str(path), dest_path)
108 tf.close()
109
110 log("copying %s to container:%s/%s" % (path, container_path, dest_path))
111 container.put_archive(container_path, buf.getvalue())
112
113
114@contextlib.contextmanager

Callers 1

copy_fileMethod · 0.85

Calls 1

logFunction · 0.90

Tested by

no test coverage detected